From nobody Sat Apr 11 02:17:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BEBBC32773 for ; Tue, 16 Aug 2022 18:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237001AbiHPSIX (ORCPT ); Tue, 16 Aug 2022 14:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236859AbiHPSHx (ORCPT ); Tue, 16 Aug 2022 14:07:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6BEC85A93 for ; Tue, 16 Aug 2022 11:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660673260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtzANJkF3fIKBG6pDjj83ztNrPxfzq+9oZeNYsNNuu8=; b=cmdKwSYy+8LcCi8BFbVzMR1/bAcyS+Kr9db9mdSJgzo0VNXu8sBw9YaEut/nwajIc+2HY2 +eZhCwKjCbuGlvcxGkIwuQQH6NFFdABkp/GNRKaRiw4XdhylEvwyelHs68TPp2uoKJkcvT jz8bs1giHvc1uzQj2cHWaaxpcI6UsYA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-177-POw_DprmOXKh4LJflHbH6w-1; Tue, 16 Aug 2022 14:07:39 -0400 X-MC-Unique: POw_DprmOXKh4LJflHbH6w-1 Received: by mail-wm1-f71.google.com with SMTP id c66-20020a1c3545000000b003a5f6dd6a25so2848631wma.1 for ; Tue, 16 Aug 2022 11:07:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=HtzANJkF3fIKBG6pDjj83ztNrPxfzq+9oZeNYsNNuu8=; b=Bmrv2RNT0ifBwSoYsF8FBqc+ITeQ5tukUyYBRxX9+p+ag5VCg5UOwp2Ae/KgmCuZPl eemS325/fy9WvvWap5feQasSNlO9NKCHsg/Zb9ndol4X5Jooj490TlmD6dZtHpBZYZqv VnuOIvMSAOmc68S+sMQsoPjGoXczM6lv/BgQs55YwKI1qPQgA2kdQswip9wSvwuDUV6H 1n/Tq5a95N9kdKAGJThvV9NLXDqpRjRTIGlienFyD2IZ4C0WtUlqJm97n9M9H1ZkCRKJ a6sF2iwQXx3EXTEQ6PbNyraUW2FtfeJWbnq5MKGoE+8ydkhfnpkrtN80Stqyh9G+dOOI 1V2g== X-Gm-Message-State: ACgBeo15kjCXJ9hjLD1wF0AvP9qrt5dBSCDZmjLQxPkktHTfBhrePUr1 idwnEei1Ar8fl2RcKD0Ghqpf150Py4vQU9GGqueh41s0wyl2uFKByrrAw+KvkbcXLQR7JpNWf/C zvfjsOsI3QhwG4eFvoAbM2LgT X-Received: by 2002:a05:600c:1c95:b0:3a5:c28a:df3e with SMTP id k21-20020a05600c1c9500b003a5c28adf3emr14330691wms.40.1660673258197; Tue, 16 Aug 2022 11:07:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7tWq3rhhkG9Yu7hBK0MmyUQOoH650N5a09JOyFV+MGIy/P/ZBBA1Gd0v6ZG1BSPs9ecxa4Yg== X-Received: by 2002:a05:600c:1c95:b0:3a5:c28a:df3e with SMTP id k21-20020a05600c1c9500b003a5c28adf3emr14330656wms.40.1660673257933; Tue, 16 Aug 2022 11:07:37 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a319bd3278sm14694961wmq.40.2022.08.16.11.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:07:37 -0700 (PDT) From: Valentin Schneider To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Barry Song , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan Subject: [PATCH 1/5] bitops: Introduce find_next_andnot_bit() Date: Tue, 16 Aug 2022 19:07:23 +0100 Message-Id: <20220816180727.387807-2-vschneid@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816180727.387807-1-vschneid@redhat.com> References: <20220816180727.387807-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In preparation of introducing for_each_cpu_andnot(), add a variant of find_next_bit() that negate the bits in @addr2 when ANDing them with the bits in @addr1. Signed-off-by: Valentin Schneider --- include/linux/find.h | 44 ++++++++++++++++++++++++++++++++++++++------ lib/find_bit.c | 16 +++++++++++----- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/include/linux/find.h b/include/linux/find.h index 424ef67d4a42..454cde69b30b 100644 --- a/include/linux/find.h +++ b/include/linux/find.h @@ -10,7 +10,8 @@ =20 extern unsigned long _find_next_bit(const unsigned long *addr1, const unsigned long *addr2, unsigned long nbits, - unsigned long start, unsigned long invert, unsigned long le); + unsigned long start, unsigned long invert, unsigned long le, + bool negate); extern unsigned long _find_first_bit(const unsigned long *addr, unsigned l= ong size); extern unsigned long _find_first_and_bit(const unsigned long *addr1, const unsigned long *addr2, unsigned long size); @@ -41,7 +42,7 @@ unsigned long find_next_bit(const unsigned long *addr, un= signed long size, return val ? __ffs(val) : size; } =20 - return _find_next_bit(addr, NULL, size, offset, 0UL, 0); + return _find_next_bit(addr, NULL, size, offset, 0UL, 0, 0); } #endif =20 @@ -71,7 +72,38 @@ unsigned long find_next_and_bit(const unsigned long *add= r1, return val ? __ffs(val) : size; } =20 - return _find_next_bit(addr1, addr2, size, offset, 0UL, 0); + return _find_next_bit(addr1, addr2, size, offset, 0UL, 0, 0); +} +#endif + +#ifndef find_next_andnot_bit +/** + * find_next_andnot_bit - find the next set bit in one memory region + * but not in the other + * @addr1: The first address to base the search on + * @addr2: The second address to base the search on + * @size: The bitmap size in bits + * @offset: The bitnumber to start searching at + * + * Returns the bit number for the next set bit + * If no bits are set, returns @size. + */ +static inline +unsigned long find_next_andnot_bit(const unsigned long *addr1, + const unsigned long *addr2, unsigned long size, + unsigned long offset) +{ + if (small_const_nbits(size)) { + unsigned long val; + + if (unlikely(offset >=3D size)) + return size; + + val =3D *addr1 & ~*addr2 & GENMASK(size - 1, offset); + return val ? __ffs(val) : size; + } + + return _find_next_bit(addr1, addr2, size, offset, 0UL, 0, 1); } #endif =20 @@ -99,7 +131,7 @@ unsigned long find_next_zero_bit(const unsigned long *ad= dr, unsigned long size, return val =3D=3D ~0UL ? size : ffz(val); } =20 - return _find_next_bit(addr, NULL, size, offset, ~0UL, 0); + return _find_next_bit(addr, NULL, size, offset, ~0UL, 0, 0); } #endif =20 @@ -247,7 +279,7 @@ unsigned long find_next_zero_bit_le(const void *addr, u= nsigned return val =3D=3D ~0UL ? size : ffz(val); } =20 - return _find_next_bit(addr, NULL, size, offset, ~0UL, 1); + return _find_next_bit(addr, NULL, size, offset, ~0UL, 1, 0); } #endif =20 @@ -266,7 +298,7 @@ unsigned long find_next_bit_le(const void *addr, unsign= ed return val ? __ffs(val) : size; } =20 - return _find_next_bit(addr, NULL, size, offset, 0UL, 1); + return _find_next_bit(addr, NULL, size, offset, 0UL, 1, 0); } #endif =20 diff --git a/lib/find_bit.c b/lib/find_bit.c index 1b8e4b2a9cba..6e5f42c621a9 100644 --- a/lib/find_bit.c +++ b/lib/find_bit.c @@ -21,17 +21,19 @@ =20 #if !defined(find_next_bit) || !defined(find_next_zero_bit) || \ !defined(find_next_bit_le) || !defined(find_next_zero_bit_le) || \ - !defined(find_next_and_bit) + !defined(find_next_and_bit) || !defined(find_next_andnot_bit) /* * This is a common helper function for find_next_bit, find_next_zero_bit,= and * find_next_and_bit. The differences are: * - The "invert" argument, which is XORed with each fetched word before * searching it for one bits. - * - The optional "addr2", which is anded with "addr1" if present. + * - The optional "addr2", negated if "negate" and ANDed with "addr1" if + * present. */ unsigned long _find_next_bit(const unsigned long *addr1, const unsigned long *addr2, unsigned long nbits, - unsigned long start, unsigned long invert, unsigned long le) + unsigned long start, unsigned long invert, unsigned long le, + bool negate) { unsigned long tmp, mask; =20 @@ -40,7 +42,9 @@ unsigned long _find_next_bit(const unsigned long *addr1, =20 tmp =3D addr1[start / BITS_PER_LONG]; if (addr2) - tmp &=3D addr2[start / BITS_PER_LONG]; + tmp &=3D negate ? + ~addr2[start / BITS_PER_LONG] : + addr2[start / BITS_PER_LONG]; tmp ^=3D invert; =20 /* Handle 1st word. */ @@ -59,7 +63,9 @@ unsigned long _find_next_bit(const unsigned long *addr1, =20 tmp =3D addr1[start / BITS_PER_LONG]; if (addr2) - tmp &=3D addr2[start / BITS_PER_LONG]; + tmp &=3D negate ? + ~addr2[start / BITS_PER_LONG] : + addr2[start / BITS_PER_LONG]; tmp ^=3D invert; } =20 --=20 2.31.1 From nobody Sat Apr 11 02:17:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E160C2BB41 for ; Tue, 16 Aug 2022 18:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236991AbiHPSIT (ORCPT ); Tue, 16 Aug 2022 14:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236906AbiHPSHw (ORCPT ); Tue, 16 Aug 2022 14:07:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DE885F99 for ; Tue, 16 Aug 2022 11:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660673261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vH2jTlmzQIwOMeKUkJzPFxzEVFleWwYuNxRt4X4XvAY=; b=cmMQF5MV4d1o0o7Kx/cto+FCxnjN5y5SzJR+UXTMchLIrzS9WKgRjIOdMsM9S7kzSGCkBS 0cRRt8cmORFN451TVgb0FX1O/0aC6DhBdewwexfC1TAgSXgXq4aiAuRevTyAW5/HqlW0Jj OE+F+4axd2QB7ACrgikbFDNgOAXYrm8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-48-R3ghcE0UM4Obhp3W9NjidA-1; Tue, 16 Aug 2022 14:07:40 -0400 X-MC-Unique: R3ghcE0UM4Obhp3W9NjidA-1 Received: by mail-wm1-f70.google.com with SMTP id a17-20020a05600c349100b003a545125f6eso10552983wmq.4 for ; Tue, 16 Aug 2022 11:07:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vH2jTlmzQIwOMeKUkJzPFxzEVFleWwYuNxRt4X4XvAY=; b=ebnCaflHtaFr8lmC9EDT837dRnGScu0LpReSgvx85KBr23EDUbIfbYkoXino32crYf vHW1oBUW+x13bYaVswcAj47FT7WQ3hOUx26W3KEkU81AEum8tRNIBazOcu+/1m2j6oSU bTS9pbsYQ5ikeFnMDbPchOn6824+QfcmuAmz81UEMUCTcuTcLbpvAH/BnMvgxsC9SNUB 4U+Oa0FM1PAPS4rN+duLStKv9vPRn+YU0ga4L1oeCdW9x1JkZPFxc/iLjpMNayLx75tS lIso1liZ4IWBpQMmQ55NmuUFRj3b0bw5s43L2gOhYJcESjwHRhRZjeJnFgMEf2SLS+/1 JRgg== X-Gm-Message-State: ACgBeo0u2othLhV/dTf4kSd83Z0M3zPG5pM7kV8SlWUodX9S8G81ys9e 1W2e995R76nqvBzhZjLqqvke/7Ck3lLtnN9jk4HAw1kEl4kOaReq5/o5DAx5JgYc9P+wD8BXmX9 niHWgSwYLESBJTSq/lFUHgik5 X-Received: by 2002:a05:600c:4fcf:b0:3a5:b7f7:3127 with SMTP id o15-20020a05600c4fcf00b003a5b7f73127mr14638611wmq.160.1660673259512; Tue, 16 Aug 2022 11:07:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Ozt5n5rw1n8vb1yr16M5RH2dEqwc/tjFIJhySTHC/leYqLbNjdSwNueyR8yo+3ivUTDnsZQ== X-Received: by 2002:a05:600c:4fcf:b0:3a5:b7f7:3127 with SMTP id o15-20020a05600c4fcf00b003a5b7f73127mr14638594wmq.160.1660673259334; Tue, 16 Aug 2022 11:07:39 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a319bd3278sm14694961wmq.40.2022.08.16.11.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:07:38 -0700 (PDT) From: Valentin Schneider To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Barry Song , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan Subject: [PATCH 2/5] cpumask: Introduce for_each_cpu_andnot() Date: Tue, 16 Aug 2022 19:07:24 +0100 Message-Id: <20220816180727.387807-3-vschneid@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816180727.387807-1-vschneid@redhat.com> References: <20220816180727.387807-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" for_each_cpu_and() is very convenient as it saves having to allocate a temporary cpumask to store the result of cpumask_and(). The same issue applies to cpumask_andnot() which doesn't actually need temporary storage for iteration purposes. Following what has been done for for_each_cpu_and(), introduce for_each_cpu_andnot(). Signed-off-by: Valentin Schneider --- include/linux/cpumask.h | 32 ++++++++++++++++++++++++++++++++ lib/cpumask.c | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index fe29ac7cc469..a8b2ca160e57 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -157,6 +157,13 @@ static inline unsigned int cpumask_next_and(int n, return n+1; } =20 +static inline unsigned int cpumask_next_andnot(int n, + const struct cpumask *srcp, + const struct cpumask *andp) +{ + return n+1; +} + static inline unsigned int cpumask_next_wrap(int n, const struct cpumask *= mask, int start, bool wrap) { @@ -194,6 +201,8 @@ static inline int cpumask_any_distribute(const struct c= pumask *srcp) for ((cpu) =3D 0; (cpu) < 1; (cpu)++, (void)mask, (void)(start)) #define for_each_cpu_and(cpu, mask1, mask2) \ for ((cpu) =3D 0; (cpu) < 1; (cpu)++, (void)mask1, (void)mask2) +#define for_each_cpu_andnot(cpu, mask1, mask2) \ + for ((cpu) =3D 0; (cpu) < 1; (cpu)++, (void)mask1, (void)mask2) #else /** * cpumask_first - get the first cpu in a cpumask @@ -259,6 +268,9 @@ static inline unsigned int cpumask_next_zero(int n, con= st struct cpumask *srcp) } =20 int __pure cpumask_next_and(int n, const struct cpumask *, const struct cp= umask *); +int __pure cpumask_next_andnot(int n, + const struct cpumask *src1p, + const struct cpumask *src2p); int __pure cpumask_any_but(const struct cpumask *mask, unsigned int cpu); unsigned int cpumask_local_spread(unsigned int i, int node); int cpumask_any_and_distribute(const struct cpumask *src1p, @@ -324,6 +336,26 @@ extern int cpumask_next_wrap(int n, const struct cpuma= sk *mask, int start, bool for ((cpu) =3D -1; \ (cpu) =3D cpumask_next_and((cpu), (mask1), (mask2)), \ (cpu) < nr_cpu_ids;) + +/** + * for_each_cpu_andnot - iterate over every cpu in one mask but not in ano= ther + * @cpu: the (optionally unsigned) integer iterator + * @mask1: the first cpumask pointer + * @mask2: the second cpumask pointer + * + * This saves a temporary CPU mask in many places. It is equivalent to: + * struct cpumask tmp; + * cpumask_andnot(&tmp, &mask1, &mask2); + * for_each_cpu(cpu, &tmp) + * ... + * + * After the loop, cpu is >=3D nr_cpu_ids. + */ +#define for_each_cpu_andnot(cpu, mask1, mask2) \ + for ((cpu) =3D -1; \ + (cpu) =3D cpumask_next_andnot((cpu), (mask1), (mask2)), \ + (cpu) < nr_cpu_ids;) + #endif /* SMP */ =20 #define CPU_BITS_NONE \ diff --git a/lib/cpumask.c b/lib/cpumask.c index a971a82d2f43..6896ff4a08fd 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -42,6 +42,25 @@ int cpumask_next_and(int n, const struct cpumask *src1p, } EXPORT_SYMBOL(cpumask_next_and); =20 +/** + * cpumask_next_andnot - get the next cpu in *src1p & ~*src2p + * @n: the cpu prior to the place to search (ie. return will be > @n) + * @src1p: the first cpumask pointer + * @src2p: the second cpumask pointer + * + * Returns >=3D nr_cpu_ids if no further cpus set in *src1p & ~*src2p. + */ +int cpumask_next_andnot(int n, const struct cpumask *src1p, + const struct cpumask *src2p) +{ + /* -1 is a legal arg here. */ + if (n !=3D -1) + cpumask_check(n); + return find_next_andnot_bit(cpumask_bits(src1p), cpumask_bits(src2p), + nr_cpumask_bits, n + 1); +} +EXPORT_SYMBOL(cpumask_next_andnot); + /** * cpumask_any_but - return a "random" in a cpumask, but not this one. * @mask: the cpumask to search --=20 2.31.1 From nobody Sat Apr 11 02:17:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25C63C25B0E for ; Tue, 16 Aug 2022 18:08:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237007AbiHPSI3 (ORCPT ); Tue, 16 Aug 2022 14:08:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236911AbiHPSHy (ORCPT ); Tue, 16 Aug 2022 14:07:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52E285FBB for ; Tue, 16 Aug 2022 11:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660673263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qZr7gdCnQUFeKt5ugQdZLofQqTfC3GDipKWYJIctC0o=; b=jKnJQR33+s/6djtpNYFD/kCjbCq9xCemF1A9eLB/d61NRYajO2bQtUbhkO0Lb0alT3tP1L ADVrTSO/eJ8votp94E0OE1PdflPYVwzTh7B9Rne1sP51ervXLLLmHtYl0yH7d8KrJYqTzq rIJBn3eHgGa7nYfvR0K3t0As3OdfDI0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-546-4IeI_N1gNFqYSvW_2WylEg-1; Tue, 16 Aug 2022 14:07:42 -0400 X-MC-Unique: 4IeI_N1gNFqYSvW_2WylEg-1 Received: by mail-wm1-f71.google.com with SMTP id q10-20020a1ce90a000000b003a60123678aso790759wmc.6 for ; Tue, 16 Aug 2022 11:07:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qZr7gdCnQUFeKt5ugQdZLofQqTfC3GDipKWYJIctC0o=; b=2qQg3H9HbRcKx9IjFcgaGJaDRrmulxuomVU4+qfs0ncCElzdwPMFmx4i2Y/4EdB+ih GWV2+OdLpX0vAa4SLKf5fIy4cWi1Ovw2GIqnq87g2cmFFGA6b3Z/ZuMgoWQrlmxqQf4X JfBCutG4gimq7BZ6dmqU1QKU9c6Q21AXJG22fvyj1L1F6u1wY4Hzm8I7e8+BCtp7rLfX +iddc+nLMIihqt5sNpvFDwVfHPjgLlmkGOz4BPFkqiipAOV8WUcVbdbAsCFLNQBG34QV bxHEsBod3Tt9Uvxw8g62U7IVqRR4yBT07mSJ0g30fPue7rjhMIr2vhFPNUoK/oJQdOgZ ZV6w== X-Gm-Message-State: ACgBeo23WybV3hqOx6vu6tRCwv6rc9YM4QoH/RifpuIS/6bEz85xT8AE Vr6fP1e2CZ9hmu6pR77HKeZ7voe2YlmLgvDxmnR3irn4FO6s0JBqghJhMcsnhhIzOfVRsGLctYs LlRSdAscpJrfSeW2XSvaEjHXU X-Received: by 2002:a7b:c852:0:b0:3a5:407a:76df with SMTP id c18-20020a7bc852000000b003a5407a76dfmr13708343wml.101.1660673260910; Tue, 16 Aug 2022 11:07:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7UPXSQNMLUdzm2OIU4YmRzUCveA1esyoYO7MxQEQacoH/hwrHSpxGq4VehHXhVW3FIbjDgTw== X-Received: by 2002:a7b:c852:0:b0:3a5:407a:76df with SMTP id c18-20020a7bc852000000b003a5407a76dfmr13708328wml.101.1660673260684; Tue, 16 Aug 2022 11:07:40 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a319bd3278sm14694961wmq.40.2022.08.16.11.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:07:40 -0700 (PDT) From: Valentin Schneider To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Barry Song , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan Subject: [PATCH 3/5] sched/topology: Introduce sched_numa_hop_mask() Date: Tue, 16 Aug 2022 19:07:25 +0100 Message-Id: <20220816180727.387807-4-vschneid@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816180727.387807-1-vschneid@redhat.com> References: <20220816180727.387807-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Tariq has pointed out that drivers allocating IRQ vectors would benefit from having smarter NUMA-awareness - cpumask_local_spread() only knows about the local node and everything outside is in the same bucket. sched_domains_numa_masks is pretty much what we want to hand out (a cpumask of CPUs reachable within a given distance budget), introduce sched_numa_hop_mask() to export those cpumasks. Link: http://lore.kernel.org/r/20220728191203.4055-1-tariqt@nvidia.com Signed-off-by: Valentin Schneider --- include/linux/topology.h | 9 +++++++++ kernel/sched/topology.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/linux/topology.h b/include/linux/topology.h index 4564faafd0e1..13b82b83e547 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -245,5 +245,14 @@ static inline const struct cpumask *cpu_cpu_mask(int c= pu) return cpumask_of_node(cpu_to_node(cpu)); } =20 +#ifdef CONFIG_NUMA +extern const struct cpumask *sched_numa_hop_mask(int node, int hops); +#else +static inline const struct cpumask *sched_numa_hop_mask(int node, int hops) +{ + return ERR_PTR(-EOPNOTSUPP); +} +#endif /* CONFIG_NUMA */ + =20 #endif /* _LINUX_TOPOLOGY_H */ diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 8739c2a5a54e..f0236a0ae65c 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2067,6 +2067,34 @@ int sched_numa_find_closest(const struct cpumask *cp= us, int cpu) return found; } =20 +/** + * sched_numa_hop_mask() - Get the cpumask of CPUs at most @hops hops away. + * @node: The node to count hops from. + * @hops: Include CPUs up to that many hops away. 0 means local node. + * + * Requires rcu_lock to be held. Returned cpumask is only valid within that + * read-side section, copy it if required beyond that. + * + * Note that not all hops are equal in size; see sched_init_numa() for how + * distances and masks are handled. + * + * Also note that this is a reflection of sched_domains_numa_masks, which = may change + * during the lifetime of the system (offline nodes are taken out of the m= asks). + */ +const struct cpumask *sched_numa_hop_mask(int node, int hops) +{ + struct cpumask ***masks =3D rcu_dereference(sched_domains_numa_masks); + + if (node >=3D nr_node_ids || hops >=3D sched_domains_numa_levels) + return ERR_PTR(-EINVAL); + + if (!masks) + return NULL; + + return masks[hops][node]; +} +EXPORT_SYMBOL_GPL(sched_numa_hop_mask); + #endif /* CONFIG_NUMA */ =20 static int __sdt_alloc(const struct cpumask *cpu_map) --=20 2.31.1 From nobody Sat Apr 11 02:17:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5D53C25B0E for ; Tue, 16 Aug 2022 18:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237020AbiHPSIj (ORCPT ); Tue, 16 Aug 2022 14:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236965AbiHPSHz (ORCPT ); Tue, 16 Aug 2022 14:07:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9630C85AAD for ; Tue, 16 Aug 2022 11:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660673265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ygl4bsiGppbXjaR+QFxwzenbyEWvTTquS8G3MYyuF5k=; b=feuPUzCzSSIW0VEOdyBD5hBkbKU5K8dZ2PYitRqgcA7CNZZFQCAkSDry4saLUk/Zsa5BAn 4Ivu011wKRP/+5AtsCRIjgyyHDq0GYwy5lweBNxlzKsgxT90y0ACXjivG8eA7Na0/IkJml 5fihCaXOVTE4CZ6ZsvyAHKf/AdpMjwg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-371-yl8Lui23OHSqTa3N935NeQ-1; Tue, 16 Aug 2022 14:07:44 -0400 X-MC-Unique: yl8Lui23OHSqTa3N935NeQ-1 Received: by mail-wm1-f70.google.com with SMTP id h62-20020a1c2141000000b003a4f57eaeaaso5216610wmh.8 for ; Tue, 16 Aug 2022 11:07:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Ygl4bsiGppbXjaR+QFxwzenbyEWvTTquS8G3MYyuF5k=; b=G8gmgSLKjRIiafDEiJg70yyGlP0sqS+aQ7KMrUUjPc2CLhbdAsowNU4NHY4oTNsSQ4 Us8PA/0xaF9pIy6HWWDVG93YOG7JqPCj+AZtps6L92AgkOubOK3LLDlBpeHEEIL9lmdX aTOxi/a/OVT2EJqopnihFEcLn5cZnbGgmi7IhPJY6JtK1grH5Fgofd6PLe7uCunoGeTR dwTFFeAxLWrkjOUaLB+H4j198Hrpzn+6dPGUWGyJ2hmYa+Iw9Pnxj9NDSsZffvTNVT0U ROQv/3vjgpUB+D55zBVL7/o18eiwIdqRKsBRsvGNzJgbZf74Pn9NU2epk/M8NuuL6vY9 g8Ag== X-Gm-Message-State: ACgBeo08Cxirza6M0g61u+rhRLQL/dBTm9iuA+QXp7dVN2qZDRfsq9TD ukl/vr+wm2KPe6Cr8b//Zc+hTLl6QyEQwQ1h7xOM649zAr6pbcc+SO8QlX8bpSGz94xwc21pT3G x+DMFNfuaaIz0ioUwSxTh428w X-Received: by 2002:a05:600c:3ac9:b0:3a5:f114:1f8 with SMTP id d9-20020a05600c3ac900b003a5f11401f8mr7308789wms.204.1660673262253; Tue, 16 Aug 2022 11:07:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR48CFk/soei7QbfayAzQBKnIM/T9VknX41x2JuU6hM+hzmZxgjXWFEqwx3WheqBotPeya0UKg== X-Received: by 2002:a05:600c:3ac9:b0:3a5:f114:1f8 with SMTP id d9-20020a05600c3ac900b003a5f11401f8mr7308780wms.204.1660673262069; Tue, 16 Aug 2022 11:07:42 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a319bd3278sm14694961wmq.40.2022.08.16.11.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:07:41 -0700 (PDT) From: Valentin Schneider To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Barry Song , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan Subject: [PATCH 4/5] sched/topology: Introduce for_each_numa_hop_cpu() Date: Tue, 16 Aug 2022 19:07:26 +0100 Message-Id: <20220816180727.387807-5-vschneid@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816180727.387807-1-vschneid@redhat.com> References: <20220816180727.387807-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The recently introduced sched_numa_hop_mask() exposes cpumasks of CPUs reachable within a given distance budget, but this means each successive cpumask is a superset of the previous one. Code wanting to allocate one item per CPU (e.g. IRQs) at increasing distances would thus need to allocate a temporary cpumask to note which CPUs have already been visited. This can be prevented by leveraging for_each_cpu_andnot() - package all that logic into one ugl^D fancy macro. Signed-off-by: Valentin Schneider --- include/linux/topology.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/topology.h b/include/linux/topology.h index 13b82b83e547..6c671dc3252c 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -254,5 +254,42 @@ static inline const struct cpumask *sched_numa_hop_mas= k(int node, int hops) } #endif /* CONFIG_NUMA */ =20 +/** + * for_each_numa_hop_cpu - iterate over CPUs by increasing NUMA distance, + * starting from a given node. + * @cpu: the iteration variable. + * @node: the NUMA node to start the search from. + * + * Requires rcu_lock to be held. + * Careful: this is a double loop, 'break' won't work as expected. + * + * + * Implementation notes: + * + * Providing it is valid, the mask returned by + * sched_numa_hop_mask(node, hops+1) + * is a superset of the one returned by + * sched_numa_hop_mask(node, hops) + * which may not be that useful for drivers that try to spread things out = and + * want to visit a CPU not more than once. + * + * To accommodate for that, we use for_each_cpu_andnot() to iterate over t= he cpus + * of sched_numa_hop_mask(node, hops+1) with the CPUs of + * sched_numa_hop_mask(node, hops) removed, IOW we only iterate over CPUs + * a given distance away (rather than *up to* a given distance). + * + * hops=3D0 forces us to play silly games: we pass cpu_none_mask to + * for_each_cpu_andnot(), which turns it into for_each_cpu(). + */ +#define for_each_numa_hop_cpu(cpu, node) \ + for (struct { const struct cpumask *curr, *prev; int hops; } __v =3D \ + { sched_numa_hop_mask(node, 0), NULL, 0 }; \ + !IS_ERR_OR_NULL(__v.curr); \ + __v.hops++, \ + __v.prev =3D __v.curr, \ + __v.curr =3D sched_numa_hop_mask(node, __v.hops)) \ + for_each_cpu_andnot(cpu, \ + __v.curr, \ + __v.hops ? __v.prev : cpu_none_mask) =20 #endif /* _LINUX_TOPOLOGY_H */ --=20 2.31.1 From nobody Sat Apr 11 02:17:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89B2CC25B0E for ; Tue, 16 Aug 2022 18:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236919AbiHPSIg (ORCPT ); Tue, 16 Aug 2022 14:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236914AbiHPSH4 (ORCPT ); Tue, 16 Aug 2022 14:07:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FE53844D4 for ; Tue, 16 Aug 2022 11:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660673266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ywTMuS9huvM7zHWOxR6GjSmCdhb3SJi0oS2399XlZwU=; b=H55HsjHjXNDwMXB/Yolv98wJNCbTIIABO8ZxsklxyRRhAXcVP3XSJYqEDh4+CE5MaxZX8h UvPT8id9/Im/v7THeWFZEO522KvEbn4H6AR1UWYtDhC8FcPs4ZG+jffiIKfFdmezXOByxf nErxk7dAyK8lCpBV/pTSHP4p1XUpmxY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-163-E3cHLbglO2WYYnGL11P7ZA-1; Tue, 16 Aug 2022 14:07:45 -0400 X-MC-Unique: E3cHLbglO2WYYnGL11P7ZA-1 Received: by mail-wm1-f69.google.com with SMTP id b4-20020a05600c4e0400b003a5a96f1756so10577618wmq.0 for ; Tue, 16 Aug 2022 11:07:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ywTMuS9huvM7zHWOxR6GjSmCdhb3SJi0oS2399XlZwU=; b=Lg99pfMg31qynihaFJLdx2RgQuvMrZ8SFIgN21l8Bo5YKEKdR23QmWeiK6KO7q9ibi TI7psbKCVcfmDEOpjHel6GlPMr7IkY/sOVlwHUQRtjuPLux99aQf0YZFJM1eBq5mGYuM lydmTajsF3W0OVN1v3eNgDyrScl8YkijpNoIioziYLaIFswiBPrcb4R00uvAoTCBZTzw 9OGhjR4MyPlIiH5U28nwmteU2VYIl4mPYrgmr+FQ+8ORIkm/EAssN8aLs8SmFnXPh3Ku lg3u7YaFFwWQfrNdJe4QKpM18S9feU6EchI/Kb93fKtjsX7ig5ahR2dTTR7PenCaOPAq 4ppg== X-Gm-Message-State: ACgBeo0P1I301S6f/KsFm2RKmVmoFQkPCVole0Ra6WXcZGfJHZ9ePlML WZAhasoteVl9JxpbgnGcdp8rtYcUiLQZMKupZ6jXJRH0Owkzp42GcCs7KQyqkTNMkaEmrUuDiqQ 7WzEPLDl5xRoYjQggq3OEM1ie X-Received: by 2002:a1c:19c2:0:b0:3a5:168e:a918 with SMTP id 185-20020a1c19c2000000b003a5168ea918mr20414209wmz.31.1660673264007; Tue, 16 Aug 2022 11:07:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iJQtE2obeMLeeSvqbOGp+G+UtYBLaHlthMqMKBF8/l32gDnIQKks/dY9pNYiEbkt1Ewqs4Q== X-Received: by 2002:a1c:19c2:0:b0:3a5:168e:a918 with SMTP id 185-20020a1c19c2000000b003a5168ea918mr20414203wmz.31.1660673263847; Tue, 16 Aug 2022 11:07:43 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a319bd3278sm14694961wmq.40.2022.08.16.11.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:07:43 -0700 (PDT) From: Valentin Schneider To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Barry Song , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan Subject: [PATCH 5/5] SHOWCASE: net/mlx5e: Leverage for_each_numa_hop_cpu() Date: Tue, 16 Aug 2022 19:07:27 +0100 Message-Id: <20220816180727.387807-6-vschneid@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816180727.387807-1-vschneid@redhat.com> References: <20220816180727.387807-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Not-signed-off-by: Valentin Schneider --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/eth= ernet/mellanox/mlx5/core/eq.c index 229728c80233..0a5432903edd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -812,6 +812,7 @@ static int comp_irqs_request(struct mlx5_core_dev *dev) int ncomp_eqs =3D table->num_comp_eqs; u16 *cpus; int ret; + int cpu; int i; =20 ncomp_eqs =3D table->num_comp_eqs; @@ -830,8 +831,15 @@ static int comp_irqs_request(struct mlx5_core_dev *dev) ret =3D -ENOMEM; goto free_irqs; } - for (i =3D 0; i < ncomp_eqs; i++) - cpus[i] =3D cpumask_local_spread(i, dev->priv.numa_node); + + rcu_read_lock(); + for_each_numa_hop_cpus(cpu, dev->priv.numa_node) { + cpus[i] =3D cpu; + if (++i =3D=3D ncomp_eqs) + goto spread_done; + } +spread_done: + rcu_read_unlock(); ret =3D mlx5_irqs_request_vectors(dev, cpus, ncomp_eqs, table->comp_irqs); kfree(cpus); if (ret < 0) --=20 2.31.1