Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1612193rwb; Thu, 8 Dec 2022 12:58:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf46K4ITqxXb7Gnj4V5arQBmTbEHxgOuK6G8JH35p7+fMqRbHczoFNIUdy9CeyTe2M0vv+g0 X-Received: by 2002:aa7:c754:0:b0:46b:6096:a884 with SMTP id c20-20020aa7c754000000b0046b6096a884mr37822766eds.152.1670533113032; Thu, 08 Dec 2022 12:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670533113; cv=none; d=google.com; s=arc-20160816; b=tB6I1azDJc8798fNR8ejjvViTPlUODMmhySicTr7fB6KKBMV5iXtH6dNVcHtESe672 5BxsnawRCqkxNP3nPy2fqSXFJhbCcQH+TpQpDh/vEk9rm+lFW2y7dN5iMBSjNS9HhbMG 1jrNVPw0ED3f+SGvuyL32upxBIatPpg184dz24defq7BL9+YGwl8NvDFvnLavTRwosRT H/cVYEBONjnoNOKpDB24pSTDDea5Y2pXtP9GCBGZ7XxEC0+AQcOEG2Xe2OfAY6/kRTLy c6t7lijCTZDQzpc5ey5HDTULwL/h3rscb7uZF6YIEEPkKoQHc/M79FZOeVqW0YRRq5Bb Mc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GihlQcK9cYAm1zf1IIYdLzFrOYYpv+dPmFF2jtn2Pws=; b=Go5ggW5r9Tz6CJK+gCl8T2X0vb9PDEAw4OQtyxDBwCFQErmdxh1W4240QWQYSAJz4C 3fSBVoRL1rh6aav0ZRk1OPqdiKGqn1j62sL3OtZwmA77bb7Azxhy8f/ALl+Ccd6wyowI tQu6dZt08oH4p1maPsPitc84ZU9+if+6zQZEHJn79KSAfKFIp65LmcUuvHSo4hKaiCAc BjGiwJdHmqH5ZZOf6RKXte74WXXWNciV5/tBGB++BVh9Gz0P4wJqNDphEPrXle+Y+DaQ PNl7uLp73AF8lSQLKyFGKnMViLE+DaQZon1/AlaEhMmSk9PaX7jPWBp7wwU5+NdpmnjB bpkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EZK+2otC; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js18-20020a17090797d200b007c0969e429bsi9562933ejc.30.2022.12.08.12.58.08; Thu, 08 Dec 2022 12:58:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=EZK+2otC; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S229674AbiLHUvu (ORCPT + 99 others); Thu, 8 Dec 2022 15:51:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiLHUvt (ORCPT ); Thu, 8 Dec 2022 15:51:49 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64EDA2A0; Thu, 8 Dec 2022 12:51:48 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id t19-20020a9d7753000000b0066d77a3d474so1586318otl.10; Thu, 08 Dec 2022 12:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GihlQcK9cYAm1zf1IIYdLzFrOYYpv+dPmFF2jtn2Pws=; b=EZK+2otC2iqILdnHZbj+g1By8Y6vEnXt0GXdj2YlZ3P09tQP8QlXgRMgqfp9fALytB 7Ehs1e52eEdghndn6xfrkGDhdX3VAfha0ij15rYiwGVhylTV/hvy5WjUl/ODYy6NeF/n UZtbHLnvCwyf/+AYQeJqv0lfYv/hRGo8YJcxnSs1tfo4NYTWJaBQFrU7fUaLi6PUgDsP WpCh6iFUkbItA9kcadRvbJLtksow2/Mht5fX67hp0Ku+ev215c1OjK/OHsxccU4YaUYk 2+nHPTk9vYdHfoEhIHf5wRaQDU3xVR3teYnfv7gXu6u5i6r4vSWMRvdCBqx8fTOidCnp hbrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GihlQcK9cYAm1zf1IIYdLzFrOYYpv+dPmFF2jtn2Pws=; b=Ouyfu55zn7Zk//2UQRB53/KR8RSXkBJJh7EVBKKoloG7iTXcioZXCrHxVBO2ue1eaU qXtSs6uX+fMy5vRXx5sqG2mrEZllyJxLyq5CFpmHYXZhMHgqnWAB/68/QOXSnTABEx/E cnXI92vJbmsWNjSIVFH1SG+RrrMERL4M7ZyKdo2tty2rxKV6f7hKKyMlTGQG07YdBuFT Ksr2va1LP2iRSOBfK0fY2+NOegHro7VmWCw/vEuTYm36w80RFeqFIg2U/M3BmYW3zP66 vi/y2r+hS0zGVYc/tMunrmZYepZpay47r/u3U4eyjISTZCeaW5deqefmFPpUtKhBc0U5 INuQ== X-Gm-Message-State: ANoB5pnRI1IHXonqLcVM7AZHkOdPQZo9vaL9f+IdsxfgQ47rfs6B8r22 ys4OVi8GaqyyTrQ97G36Ogw= X-Received: by 2002:a9d:7699:0:b0:661:dfe6:9732 with SMTP id j25-20020a9d7699000000b00661dfe69732mr1338993otl.1.1670532707597; Thu, 08 Dec 2022 12:51:47 -0800 (PST) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id h5-20020a056830164500b00667ff6b7e9esm12285612otr.40.2022.12.08.12.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:51:47 -0800 (PST) Date: Thu, 8 Dec 2022 12:51:45 -0800 From: Yury Norov To: Tariq Toukan Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Andy Shevchenko , Barry Song , Ben Segall , haniel Bristot de Oliveira , Dietmar Eggemann , Gal Pressman , Greg Kroah-Hartman , Heiko Carstens , Ingo Molnar , Jakub Kicinski , Jason Gunthorpe , Jesse Brandeburg , Jonathan Cameron , Juri Lelli , Leon Romanovsky , Mel Gorman , Peter Zijlstra , Rasmus Villemoes , Saeed Mahameed , Steven Rostedt , Tariq Toukan , Tony Luck , Valentin Schneider , Vincent Guittot , linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH v3 0/5] cpumask: improve on cpumask_local_spread() locality Message-ID: References: <20221208183101.1162006-1-yury.norov@gmail.com> <1efd1d75-9c5d-4827-3d28-bef044801859@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1efd1d75-9c5d-4827-3d28-bef044801859@gmail.com> 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: X-Mailing-List: linux-crypto@vger.kernel.org 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 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