Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4903692rdh; Wed, 29 Nov 2023 14:17:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxRxRnGt73XOxwCuuHLG6AtSDS0mxItM5w0b5QehNSpf95epuNR0F5xVwhZjmh2L3rAQ6h X-Received: by 2002:a05:6a00:2e9c:b0:6cb:6880:752 with SMTP id fd28-20020a056a002e9c00b006cb68800752mr23046905pfb.17.1701296271000; Wed, 29 Nov 2023 14:17:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701296270; cv=none; d=google.com; s=arc-20160816; b=v36RrcWesLdacTIXC3baAUkMXqpSt5lJ2PhpMo4f8KjhTjgonNi3zOgmjhBjLJkIDW 2sM9nRs0PZg9WwnYAw+9bMBx1HQzwvLsLv+KYkuFAYDLDGPlZFhsv40I4L+GjxcRy24D U5jMK8WU99qiRbKi9yq3emHOMn0TBFqLrsHFtYhm9mt4bFpBtV58RMHutRe10dxM3Atb cBBbXgxpummN2OZZZWxF6htdw/xHKh/XL7sp5HakkfdEo4g9+qrBx5b2+CaQaRPwMl9s ZYFmAPojw7IjcJIi+N7XzCIkn428qhLJlZGOLKp9PB81wMYi2Sjb18aisnBSdSrfK9ll 9Zlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=Zsx1oRRDG0ud+KYg27YMp0ZwJzk7FpHaUGfDgfFevRU=; fh=M0bx5crbp0DQcST1eOGS2uXGRZGNjPABYLY8O4kpTe8=; b=wLX8WAn2T0lQioz2KV4hXh+WR1eIPvU7Fq2/eULJxg8UmEWUr+VvcmBfBJyc32mdJs pwRF7dM3zEdUqBnuxVBJdvxAFGmYrP2PPPR42owYERZ0S7fTHbGRrOlOCk3IqhDwS0ku CbAC3ZTaNzQg2cTSvtTkTSt0NvDB2c6QUo9jXND8ysFKZQ3jHBIW/qZiF0GYMZNmfjFN VtXvohXzk/1SHGcGbgr/Sea6eFHw3xrUPZhPnU6EepWeKmK31AUTnRYt4Z7K5pviHbHo U6IGLcjQ4rUq8BTSztU0QUHmnA2lvuoi+tWu9z/6cc7B9dRc3uaywydwutZBFLMiUrWm JfiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=OjVaYLAy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x9-20020a63fe49000000b005bddb417affsi15068278pgj.291.2023.11.29.14.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 14:17:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=OjVaYLAy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B6DA68043AEB; Wed, 29 Nov 2023 14:17:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbjK2WRg (ORCPT + 99 others); Wed, 29 Nov 2023 17:17:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjK2WRe (ORCPT ); Wed, 29 Nov 2023 17:17:34 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 539B5A3; Wed, 29 Nov 2023 14:17:40 -0800 (PST) Received: by linux.microsoft.com (Postfix, from userid 1099) id A96B720B74C0; Wed, 29 Nov 2023 14:17:39 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A96B720B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1701296259; bh=Zsx1oRRDG0ud+KYg27YMp0ZwJzk7FpHaUGfDgfFevRU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OjVaYLAyvGNrgGT5XdUkbanydr+2zb91Ww6pBQ5v7UdvypeSsJzEFiwbBN4YUcoFd iRxOfYUrSOzPaW6u8WICfgphPuL+DCUWLY0RuJKcwQcuRJaa9zIdMunYSLQCHHaTLV 34olHXNtIiUoYZircMeYAoW1H3Tphn9/XH4vo8ys= Date: Wed, 29 Nov 2023 14:17:39 -0800 From: Souradeep Chakrabarti To: Jakub Kicinski Cc: Souradeep Chakrabarti , KY Srinivasan , Haiyang Zhang , "wei.liu@kernel.org" , Dexuan Cui , "davem@davemloft.net" , "edumazet@google.com" , "pabeni@redhat.com" , Long Li , "sharmaajay@microsoft.com" , "leon@kernel.org" , "cai.huoqing@linux.dev" , "ssengar@linux.microsoft.com" , "vkuznets@redhat.com" , "tglx@linutronix.de" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Paul Rosswurm Subject: Re: [EXTERNAL] Re: [PATCH V2 net-next] net: mana: Assigning IRQ affinity on HT cores Message-ID: <20231129221739.GA20858@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1700574877-6037-1-git-send-email-schakrabarti@linux.microsoft.com> <20231121154841.7fc019c8@kernel.org> <20231127100639.5f2f3d3e@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231127100639.5f2f3d3e@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 29 Nov 2023 14:17:48 -0800 (PST) On Mon, Nov 27, 2023 at 10:06:39AM -0800, Jakub Kicinski wrote: > On Mon, 27 Nov 2023 09:36:38 +0000 Souradeep Chakrabarti wrote: > > easier to keep things inside the mana driver code here > > Easier for who? Upstream we care about consistency and maintainability > across all drivers. I am refactoring the code and putting some of the changes in topology.h and in nodemask.h. I am sharing the proposed change here for those two files. Please let me know if they are acceptable. Added a new helper to iterate on numa nodes with cpu and start from a particular node, instead of first node. This helps when we want to iterate from the local numa node. diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 8d07116caaf1..6e4528376164 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -392,6 +392,15 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp, for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++) #endif /* MAX_NUMNODES */ +#if MAX_NUMNODES > 1 +#define for_each_node_next_mask(node_start, node_next, mask) \ + for ((node_next) = (node_start); \ + (node_next) < MAX_NUMNODES; \ + (node_next) = next_node((node_next), (mask))) +#else +#define for_each_node_next_mask(node_start, node_next, mask) \ + for_each_node_mask(node_next, mask) +#endif /* * Bitmasks that are kept for all the nodes. */ @@ -440,6 +449,8 @@ static inline int num_node_state(enum node_states state) #define for_each_node_state(__node, __state) \ for_each_node_mask((__node), node_states[__state]) +#define for_each_node_next_state(__node_start, __node_next, __state) \ + for_each_node_next_mask((__node_start), (__node_next), node_states[__state]) #define first_online_node first_node(node_states[N_ONLINE]) #define first_memory_node first_node(node_states[N_MEMORY]) @@ -489,7 +500,8 @@ static inline int num_node_state(enum node_states state) #define for_each_node_state(node, __state) \ for ( (node) = 0; (node) == 0; (node) = 1) - +#define for_each_node_next_state(node, next_node, _state) \ + for_each_node_state(node, __state) #define first_online_node 0 #define first_memory_node 0 #define next_online_node(nid) (MAX_NUMNODES) @@ -535,6 +547,8 @@ static inline int node_random(const nodemask_t *maskp) #define for_each_node(node) for_each_node_state(node, N_POSSIBLE) #define for_each_online_node(node) for_each_node_state(node, N_ONLINE) +#define for_each_online_node_next(node, next_node) \ + for_each_node_next_state(node, next_node, N_ONLINE) /* * For nodemask scratch area. diff --git a/include/linux/topology.h b/include/linux/topology.h index 52f5850730b3..a06b16e5a955 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -43,6 +43,9 @@ for_each_online_node(node) \ if (nr_cpus_node(node)) +#define for_each_next_node_with_cpus(node, next_node) \ + for_each_online_node_next(node, next_node) \ + if (nr_cpus_node(next_node)) int arch_update_cpu_topology(void); /* Conform to ACPI 2.0 SLIT distance definitions */