From: Yury Norov <yury.norov@gmail.com>
To: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Menglong Dong <imagedong@tencent.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Petr Machata <petrm@nvidia.com>,
linux-kernel@vger.kernel.org
Cc: Yury Norov <yury.norov@gmail.com>
Subject: [PATCH 4/4] net: fix opencoded for_each_and_bit() in __netif_set_xps_queue()
Date: Sun, 2 Oct 2022 08:17:02 -0700 [thread overview]
Message-ID: <20221002151702.3932770-5-yury.norov@gmail.com> (raw)
In-Reply-To: <20221002151702.3932770-1-yury.norov@gmail.com>
Replace opencoded bitmap traversing and drop unused
netif_attrmask_next*() functions
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
include/linux/netdevice.h | 46 ---------------------------------------
net/core/dev.c | 3 +--
2 files changed, 1 insertion(+), 48 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6f8cdd5c7908..41c94e5854e8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3628,52 +3628,6 @@ static inline bool netif_attr_test_online(unsigned long j,
return (j < nr_bits);
}
-
-/**
- * netif_attrmask_next - get the next CPU/Rx queue in a cpu/Rx queues mask
- * @n: CPU/Rx queue index
- * @srcp: the cpumask/Rx queue mask pointer
- * @nr_bits: number of bits in the bitmask
- *
- * Returns >= nr_bits if no further CPUs/Rx queues set.
- */
-static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp,
- unsigned int nr_bits)
-{
- /* n is a prior cpu */
- cpu_max_bits_warn(n + 1, nr_bits);
-
- if (srcp)
- return find_next_bit(srcp, nr_bits, n + 1);
-
- return n + 1;
-}
-
-/**
- * netif_attrmask_next_and - get the next CPU/Rx queue in \*src1p & \*src2p
- * @n: CPU/Rx queue index
- * @src1p: the first CPUs/Rx queues mask pointer
- * @src2p: the second CPUs/Rx queues mask pointer
- * @nr_bits: number of bits in the bitmask
- *
- * Returns >= nr_bits if no further CPUs/Rx queues set in both.
- */
-static inline int netif_attrmask_next_and(int n, const unsigned long *src1p,
- const unsigned long *src2p,
- unsigned int nr_bits)
-{
- /* n is a prior cpu */
- cpu_max_bits_warn(n + 1, nr_bits);
-
- if (src1p && src2p)
- return find_next_and_bit(src1p, src2p, nr_bits, n + 1);
- else if (src1p)
- return find_next_bit(src1p, nr_bits, n + 1);
- else if (src2p)
- return find_next_bit(src2p, nr_bits, n + 1);
-
- return n + 1;
-}
#else
static inline int netif_set_xps_queue(struct net_device *dev,
const struct cpumask *mask,
diff --git a/net/core/dev.c b/net/core/dev.c
index 266378ad1cf1..e3da6cb1e7ee 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2591,8 +2591,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
copy = true;
/* allocate memory for queue storage */
- for (j = -1; j = netif_attrmask_next_and(j, online_mask, mask, nr_ids),
- j < nr_ids;) {
+ for_each_and_bit(j, online_mask, mask ? : online_mask, nr_ids) {
if (!new_dev_maps) {
new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
if (!new_dev_maps)
--
2.34.1
next prev parent reply other threads:[~2022-10-02 15:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 15:16 [PATCH 0/4] net: drop netif_attrmask_next*() Yury Norov
2022-10-02 15:16 ` [PATCH 1/4] net: move setup code out of mutex in __netif_set_xps_queue() Yury Norov
2022-10-02 15:17 ` [PATCH 2/4] net: merge XPS_CPU_DEV_MAPS_SIZE and XPS_RXQ_DEV_MAPS_SIZE macros Yury Norov
2022-10-02 15:17 ` [PATCH 3/4] net: initialize online_mask unconditionally in __netif_set_xps_queue() Yury Norov
2022-10-02 16:58 ` Yury Norov
2022-10-02 15:17 ` Yury Norov [this message]
2022-10-03 16:50 ` [PATCH 0/4] net: drop netif_attrmask_next*() Jakub Kicinski
2022-10-03 18:11 ` Yury Norov
2022-10-03 23:25 ` Jakub Kicinski
2022-10-04 0:07 ` Yury Norov
2022-10-04 0:29 ` Jakub Kicinski
2022-10-04 0:43 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221002151702.3932770-5-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imagedong@tencent.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).