Message ID | 20221208183101.1162006-1-yury.norov@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp356709wrr; Thu, 8 Dec 2022 10:32:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf47WswkRehalShkz9j0uZDOyuq2vcdRCxQYl1/I0Fr19Fgn6Ag/Rk02KbrTCevILUPxkQAl X-Received: by 2002:a63:3192:0:b0:478:b5d4:22d7 with SMTP id x140-20020a633192000000b00478b5d422d7mr17118301pgx.604.1670524333742; Thu, 08 Dec 2022 10:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670524333; cv=none; d=google.com; s=arc-20160816; b=Q9KbbA3bSyotwyQmbYOhQsVucPPwuuW+e4IBa3RgRPMFQyBD58POVFXMQZVlGRZOoo hEyarqqYT0b4JkPNDoOYs8umkjD9x+9IvFOuaH/fAHmlE1Czzx7X7BHB08FDI4BfKFZg G1N2WVq3ntrhrnGAuM6d43R32igl0p2RSpuJXhBVMe6Iq3j5uj2BxpyrzlcROOOKwnpu XaeBiiNOIxs4ThwfxLF5Ntq3e87C4meilgrqfn0AROo/vHYwFSGuKW82sKRrAmJfR/RW eNOPyxLtCO3jezcHU8Ht5HHXO2S7/S74SOtwX2bUAepdmecqEmj6dGs8CSwWwD4d0yhN naZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XF7XmsI3z9Pewm9QLWRYHW1AFn4kiQyrTYitGbyYOV0=; b=ksfS5Kf6o5+hBG3HaINUcTupl9kE3Fz/8HIPhmkZAPo1nAUh3ddORT1ocr18bs7JbE A5/C00W5CNDTdITiYspwR0wIN1PAq0lFb0+1qNrGbMuGugsE18lI9A2dvSFnrA4qiJOP nw6DhVqo/SkkwiZgvnJWlMzA+B16CwQ8lr1xc1IZW0Qaf/a8UE0YBCmc2FZQXQLvAA1k ymUujeSxAyafX5CtK8p3R8YbM4V3xXZW21lHKTN/hPfm3WyYyJBxZLc13GYzYPXVK59Q y/9ezM9v3ByLH9cb7EgtDel6pbarRcPLjoQ5qkHDpF5lz3PE892cJvO+jL5vg4TeUuHY zhmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X7yZQIpn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pq3-20020a17090b3d8300b0021913493ab5si4917115pjb.78.2022.12.08.10.31.59; Thu, 08 Dec 2022 10:32:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X7yZQIpn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiLHSbI (ORCPT <rfc822;foxyelen666@gmail.com> + 99 others); Thu, 8 Dec 2022 13:31:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbiLHSbG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 8 Dec 2022 13:31:06 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD7D85D22; Thu, 8 Dec 2022 10:31:05 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-144bd860fdbso2851355fac.0; Thu, 08 Dec 2022 10:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XF7XmsI3z9Pewm9QLWRYHW1AFn4kiQyrTYitGbyYOV0=; b=X7yZQIpnNAhUiqJmYPIzNNFCNYaxiM7TSwgUizzX6q5+3xdIGn8EDYfOM5mh9JvgZm jau4dmjTy/lJ3MtqBD78OTglbxR7hkmpdWvHLaGkPZf4n/Ra9wxwDTKJKra0Ruc24HU+ IcPOPf2abIOtNRv74pFNGsNE7wCIo5Cz6RljxYJA4Kegwr4zv6g1IAHnAwT0PBPMM1ri 7wjhtnF58lTf/WfnpS5YiG2xCB9WE6SzLRkJrpn0rn+dMEAVZuyxb+TnWJRsfaI9CIWf 9s98bhjevgrcvTinBLHRrMx1w0x5nkTm5mez6BQLOvvcYkGetKouGqqHwd5U8CyAi/Dp 1nEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XF7XmsI3z9Pewm9QLWRYHW1AFn4kiQyrTYitGbyYOV0=; b=v6s2c2qwyazigahKn8SX9LpK737o65HOIzejwt+49GbZK4+LP45vQdsGl6sdjjn2Z3 KcP8OYaeEdCBHe8zVGmGFSm8UpCfe3DFgO1lfStO949BZdZZoHpUyjcWDhTWsoZjIy6U aCtysKDDUMLWxtJP3zB2L0qks/srJswcHSVSrt4NGsChGinC9DYj4cdn6kuZ+sJTl2ZH lQYDperSKjF/Qt6hlj9rzB5r48uiy+JsS2T5PFRC0Ae/IEchx7OTZvKPZYfzUnjpFuQJ KwNfnniRvSVdFsqGpdlMAK7C7x56QqVOOWYx3jyAvQta9ohI+SAn5JHsWqNwaYUHOwTu Leiw== X-Gm-Message-State: ANoB5pmrcHCUdieyN1tv+DmGHKCe1BeRPQt1D1VaT4RS/6Solt7qYeuF dsvzAsqyFOCE/E8qSBgiT0eqmN/ph9s= X-Received: by 2002:a05:6870:b9ca:b0:13b:d910:5001 with SMTP id iv10-20020a056870b9ca00b0013bd9105001mr1391780oab.1.1670524264577; Thu, 08 Dec 2022 10:31:04 -0800 (PST) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id k14-20020a0568080e8e00b0034d8abf42f1sm10910446oil.23.2022.12.08.10.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 10:31:03 -0800 (PST) From: Yury Norov <yury.norov@gmail.com> To: linux-kernel@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Barry Song <baohua@kernel.org>, Ben Segall <bsegall@google.com>, haniel Bristot de Oliveira <bristot@redhat.com>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Gal Pressman <gal@nvidia.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Heiko Carstens <hca@linux.ibm.com>, Ingo Molnar <mingo@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>, Jesse Brandeburg <jesse.brandeburg@intel.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com>, Juri Lelli <juri.lelli@redhat.com>, Leon Romanovsky <leonro@nvidia.com>, Mel Gorman <mgorman@suse.de>, Peter Zijlstra <peterz@infradead.org>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, Saeed Mahameed <saeedm@nvidia.com>, Steven Rostedt <rostedt@goodmis.org>, Tariq Toukan <tariqt@nvidia.com>, Tariq Toukan <ttoukan.linux@gmail.com>, Tony Luck <tony.luck@intel.com>, Valentin Schneider <vschneid@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org> Cc: Yury Norov <yury.norov@gmail.com>, linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH v3 0/5] cpumask: improve on cpumask_local_spread() locality Date: Thu, 8 Dec 2022 10:30:56 -0800 Message-Id: <20221208183101.1162006-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751671724062254940?= X-GMAIL-MSGID: =?utf-8?q?1751671724062254940?= |
Series |
cpumask: improve on cpumask_local_spread() locality
|
|
Message
Yury Norov
Dec. 8, 2022, 6:30 p.m. UTC
cpumask_local_spread() currently checks local node for presence of i'th CPU, and then if it finds nothing makes a flat search among all non-local CPUs. We can do it better by checking CPUs per NUMA hops. This series is inspired by Tariq Toukan and Valentin Schneider's "net/mlx5e: Improve remote NUMA preferences used for the IRQ affinity hints" https://patchwork.kernel.org/project/netdevbpf/patch/20220728191203.4055-3-tariqt@nvidia.com/ According to their measurements, for mlx5e: Bottleneck in RX side is released, reached linerate (~1.8x speedup). ~30% less cpu util on TX. This patch makes cpumask_local_spread() traversing CPUs based on NUMA distance, just as well, and I expect comparable improvement for its users, as in case of mlx5e. I tested new behavior on my VM with the following NUMA configuration: root@debian:~# numactl -H available: 4 nodes (0-3) node 0 cpus: 0 1 2 3 node 0 size: 3869 MB node 0 free: 3740 MB node 1 cpus: 4 5 node 1 size: 1969 MB node 1 free: 1937 MB node 2 cpus: 6 7 node 2 size: 1967 MB node 2 free: 1873 MB node 3 cpus: 8 9 10 11 12 13 14 15 node 3 size: 7842 MB node 3 free: 7723 MB node distances: node 0 1 2 3 0: 10 50 30 70 1: 50 10 70 30 2: 30 70 10 50 3: 70 30 50 10 And the cpumask_local_spread() for each node and offset traversing looks like this: node 0: 0 1 2 3 6 7 4 5 8 9 10 11 12 13 14 15 node 1: 4 5 8 9 10 11 12 13 14 15 0 1 2 3 6 7 node 2: 6 7 0 1 2 3 8 9 10 11 12 13 14 15 4 5 node 3: 8 9 10 11 12 13 14 15 4 5 6 7 0 1 2 3 v1: https://lore.kernel.org/lkml/20221111040027.621646-5-yury.norov@gmail.com/T/ v2: https://lore.kernel.org/all/20221112190946.728270-3-yury.norov@gmail.com/T/ v3: - fix typo in find_nth_and_andnot_bit(); - add 5th patch that simplifies cpumask_local_spread(); - address various coding style nits. Yury Norov (5): lib/find: introduce find_nth_and_andnot_bit cpumask: introduce cpumask_nth_and_andnot sched: add sched_numa_find_nth_cpu() cpumask: improve on cpumask_local_spread() locality lib/cpumask: reorganize cpumask_local_spread() logic include/linux/cpumask.h | 20 ++++++++++++++ include/linux/find.h | 33 +++++++++++++++++++++++ include/linux/topology.h | 8 ++++++ kernel/sched/topology.c | 57 ++++++++++++++++++++++++++++++++++++++++ lib/cpumask.c | 26 +++++------------- lib/find_bit.c | 9 +++++++ 6 files changed, 134 insertions(+), 19 deletions(-)
Comments
On 12/8/2022 10:30 AM, Yury Norov wrote: > cpumask_local_spread() currently checks local node for presence of i'th > CPU, and then if it finds nothing makes a flat search among all non-local > CPUs. We can do it better by checking CPUs per NUMA hops. > > This series is inspired by Tariq Toukan and Valentin Schneider's > "net/mlx5e: Improve remote NUMA preferences used for the IRQ affinity > hints" > > https://patchwork.kernel.org/project/netdevbpf/patch/20220728191203.4055-3-tariqt@nvidia.com/ > > According to their measurements, for mlx5e: > > Bottleneck in RX side is released, reached linerate (~1.8x speedup). > ~30% less cpu util on TX. > > This patch makes cpumask_local_spread() traversing CPUs based on NUMA > distance, just as well, and I expect comparable improvement for its > users, as in case of mlx5e. > > I tested new behavior on my VM with the following NUMA configuration: > > root@debian:~# numactl -H > available: 4 nodes (0-3) > node 0 cpus: 0 1 2 3 > node 0 size: 3869 MB > node 0 free: 3740 MB > node 1 cpus: 4 5 > node 1 size: 1969 MB > node 1 free: 1937 MB > node 2 cpus: 6 7 > node 2 size: 1967 MB > node 2 free: 1873 MB > node 3 cpus: 8 9 10 11 12 13 14 15 > node 3 size: 7842 MB > node 3 free: 7723 MB > node distances: > node 0 1 2 3 > 0: 10 50 30 70 > 1: 50 10 70 30 > 2: 30 70 10 50 > 3: 70 30 50 10 > > And the cpumask_local_spread() for each node and offset traversing looks > like this: > > node 0: 0 1 2 3 6 7 4 5 8 9 10 11 12 13 14 15 > node 1: 4 5 8 9 10 11 12 13 14 15 0 1 2 3 6 7 > node 2: 6 7 0 1 2 3 8 9 10 11 12 13 14 15 4 5 > node 3: 8 9 10 11 12 13 14 15 4 5 6 7 0 1 2 3 > > v1: https://lore.kernel.org/lkml/20221111040027.621646-5-yury.norov@gmail.com/T/ > v2: https://lore.kernel.org/all/20221112190946.728270-3-yury.norov@gmail.com/T/ > v3: > - fix typo in find_nth_and_andnot_bit(); > - add 5th patch that simplifies cpumask_local_spread(); > - address various coding style nits. > The whole series look reasonable to me! Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
On 12/8/2022 8:30 PM, Yury Norov wrote: > cpumask_local_spread() currently checks local node for presence of i'th > CPU, and then if it finds nothing makes a flat search among all non-local > CPUs. We can do it better by checking CPUs per NUMA hops. > > This series is inspired by Tariq Toukan and Valentin Schneider's > "net/mlx5e: Improve remote NUMA preferences used for the IRQ affinity > hints" > > https://patchwork.kernel.org/project/netdevbpf/patch/20220728191203.4055-3-tariqt@nvidia.com/ > > According to their measurements, for mlx5e: > > Bottleneck in RX side is released, reached linerate (~1.8x speedup). > ~30% less cpu util on TX. > > This patch makes cpumask_local_spread() traversing CPUs based on NUMA > distance, just as well, and I expect comparable improvement for its > users, as in case of mlx5e. > > I tested new behavior on my VM with the following NUMA configuration: > > root@debian:~# numactl -H > available: 4 nodes (0-3) > node 0 cpus: 0 1 2 3 > node 0 size: 3869 MB > node 0 free: 3740 MB > node 1 cpus: 4 5 > node 1 size: 1969 MB > node 1 free: 1937 MB > node 2 cpus: 6 7 > node 2 size: 1967 MB > node 2 free: 1873 MB > node 3 cpus: 8 9 10 11 12 13 14 15 > node 3 size: 7842 MB > node 3 free: 7723 MB > node distances: > node 0 1 2 3 > 0: 10 50 30 70 > 1: 50 10 70 30 > 2: 30 70 10 50 > 3: 70 30 50 10 > > And the cpumask_local_spread() for each node and offset traversing looks > like this: > > node 0: 0 1 2 3 6 7 4 5 8 9 10 11 12 13 14 15 > node 1: 4 5 8 9 10 11 12 13 14 15 0 1 2 3 6 7 > node 2: 6 7 0 1 2 3 8 9 10 11 12 13 14 15 4 5 > node 3: 8 9 10 11 12 13 14 15 4 5 6 7 0 1 2 3 > > v1: https://lore.kernel.org/lkml/20221111040027.621646-5-yury.norov@gmail.com/T/ > v2: https://lore.kernel.org/all/20221112190946.728270-3-yury.norov@gmail.com/T/ > v3: > - fix typo in find_nth_and_andnot_bit(); > - add 5th patch that simplifies cpumask_local_spread(); > - address various coding style nits. > > Yury Norov (5): > lib/find: introduce find_nth_and_andnot_bit > cpumask: introduce cpumask_nth_and_andnot > sched: add sched_numa_find_nth_cpu() > cpumask: improve on cpumask_local_spread() locality > lib/cpumask: reorganize cpumask_local_spread() logic > > include/linux/cpumask.h | 20 ++++++++++++++ > include/linux/find.h | 33 +++++++++++++++++++++++ > include/linux/topology.h | 8 ++++++ > kernel/sched/topology.c | 57 ++++++++++++++++++++++++++++++++++++++++ > lib/cpumask.c | 26 +++++------------- > lib/find_bit.c | 9 +++++++ > 6 files changed, 134 insertions(+), 19 deletions(-) > Acked-by: Tariq Toukan <tariqt@nvidia.com>
On Thu, Dec 08, 2022 at 10:22:22PM +0200, Tariq Toukan wrote: > > > On 12/8/2022 8:30 PM, Yury Norov wrote: > > cpumask_local_spread() currently checks local node for presence of i'th > > CPU, and then if it finds nothing makes a flat search among all non-local > > CPUs. We can do it better by checking CPUs per NUMA hops. > > > > This series is inspired by Tariq Toukan and Valentin Schneider's > > "net/mlx5e: Improve remote NUMA preferences used for the IRQ affinity > > hints" > > > > https://patchwork.kernel.org/project/netdevbpf/patch/20220728191203.4055-3-tariqt@nvidia.com/ > > > > According to their measurements, for mlx5e: > > > > Bottleneck in RX side is released, reached linerate (~1.8x speedup). > > ~30% less cpu util on TX. > > > > This patch makes cpumask_local_spread() traversing CPUs based on NUMA > > distance, just as well, and I expect comparable improvement for its > > users, as in case of mlx5e. > > > > I tested new behavior on my VM with the following NUMA configuration: > > > > root@debian:~# numactl -H > > available: 4 nodes (0-3) > > node 0 cpus: 0 1 2 3 > > node 0 size: 3869 MB > > node 0 free: 3740 MB > > node 1 cpus: 4 5 > > node 1 size: 1969 MB > > node 1 free: 1937 MB > > node 2 cpus: 6 7 > > node 2 size: 1967 MB > > node 2 free: 1873 MB > > node 3 cpus: 8 9 10 11 12 13 14 15 > > node 3 size: 7842 MB > > node 3 free: 7723 MB > > node distances: > > node 0 1 2 3 > > 0: 10 50 30 70 > > 1: 50 10 70 30 > > 2: 30 70 10 50 > > 3: 70 30 50 10 > > > > And the cpumask_local_spread() for each node and offset traversing looks > > like this: > > > > node 0: 0 1 2 3 6 7 4 5 8 9 10 11 12 13 14 15 > > node 1: 4 5 8 9 10 11 12 13 14 15 0 1 2 3 6 7 > > node 2: 6 7 0 1 2 3 8 9 10 11 12 13 14 15 4 5 > > node 3: 8 9 10 11 12 13 14 15 4 5 6 7 0 1 2 3 > > > > v1: https://lore.kernel.org/lkml/20221111040027.621646-5-yury.norov@gmail.com/T/ > > v2: https://lore.kernel.org/all/20221112190946.728270-3-yury.norov@gmail.com/T/ > > v3: > > - fix typo in find_nth_and_andnot_bit(); > > - add 5th patch that simplifies cpumask_local_spread(); > > - address various coding style nits. > > > > Yury Norov (5): > > lib/find: introduce find_nth_and_andnot_bit > > cpumask: introduce cpumask_nth_and_andnot > > sched: add sched_numa_find_nth_cpu() > > cpumask: improve on cpumask_local_spread() locality > > lib/cpumask: reorganize cpumask_local_spread() logic > > > > include/linux/cpumask.h | 20 ++++++++++++++ > > include/linux/find.h | 33 +++++++++++++++++++++++ > > include/linux/topology.h | 8 ++++++ > > kernel/sched/topology.c | 57 ++++++++++++++++++++++++++++++++++++++++ > > lib/cpumask.c | 26 +++++------------- > > lib/find_bit.c | 9 +++++++ > > 6 files changed, 134 insertions(+), 19 deletions(-) > > > > Acked-by: Tariq Toukan <tariqt@nvidia.com> Thanks Tariq, Jacob and Peter for review. I'll add the series in bitmap-for-next for testing. Still, I think that sched/numa branches would be more suitable. Thanks, Yury