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>,
Guo Ren <guoren@linux.alibaba.com>,
"Michael S . Tsirkin" <mst@redhat.com>
Cc: Yury Norov <yury.norov@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/4] net: merge XPS_CPU_DEV_MAPS_SIZE and XPS_RXQ_DEV_MAPS_SIZE macros
Date: Thu, 13 Oct 2022 16:43:46 -0700 [thread overview]
Message-ID: <20221013234349.1165689-3-yury.norov@gmail.com> (raw)
In-Reply-To: <20221013234349.1165689-1-yury.norov@gmail.com>
The macros are used in a single place, and merging them
would simplify the code.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
include/linux/netdevice.h | 7 ++-----
net/core/dev.c | 3 +--
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a36edb0ec199..53d738f66159 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -825,11 +825,8 @@ struct xps_dev_maps {
struct xps_map __rcu *attr_map[]; /* Either CPUs map or RXQs map */
};
-#define XPS_CPU_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \
- (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *)))
-
-#define XPS_RXQ_DEV_MAPS_SIZE(_tcs, _rxqs) (sizeof(struct xps_dev_maps) +\
- (_rxqs * (_tcs) * sizeof(struct xps_map *)))
+#define XPS_DEV_MAPS_SIZE(_tcs, nr) (sizeof(struct xps_dev_maps) +\
+ ((nr) * (_tcs) * sizeof(struct xps_map *)))
#endif /* CONFIG_XPS */
diff --git a/net/core/dev.c b/net/core/dev.c
index 70fa12c6551c..9dc6fcb0d48a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2564,15 +2564,14 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
}
if (type == XPS_RXQS) {
- maps_sz = XPS_RXQ_DEV_MAPS_SIZE(num_tc, dev->num_rx_queues);
nr_ids = dev->num_rx_queues;
} else {
- maps_sz = XPS_CPU_DEV_MAPS_SIZE(num_tc);
if (num_possible_cpus() > 1)
online_mask = cpumask_bits(cpu_online_mask);
nr_ids = nr_cpu_ids;
}
+ maps_sz = XPS_DEV_MAPS_SIZE(num_tc, nr_ids);
if (maps_sz < L1_CACHE_BYTES)
maps_sz = L1_CACHE_BYTES;
--
2.34.1
next prev parent reply other threads:[~2022-10-13 23:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 23:43 [PATCH v2 0/4] net: drop netif_attrmask_next*() Yury Norov
2022-10-13 23:43 ` [PATCH v2 1/4] net: move setup code out of mutex in __netif_set_xps_queue() Yury Norov
2022-10-13 23:43 ` Yury Norov [this message]
2022-10-13 23:43 ` [PATCH v2 3/4] net: initialize online_mask unconditionally " Yury Norov
2022-10-13 23:43 ` [PATCH v2 4/4] net: fix opencoded for_each_and_bit() " Yury Norov
2022-10-14 9:38 ` Michael S. Tsirkin
2022-10-14 14:20 ` [PATCH v2 0/4] net: drop netif_attrmask_next*() Michael S. Tsirkin
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=20221013234349.1165689-3-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=guoren@linux.alibaba.com \
--cc=imagedong@tencent.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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
all inboxes | Powered by JetHome®