All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids
@ 2018-07-06  9:33 Li RongQing
  2018-07-08  4:04 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2018-07-06  9:33 UTC (permalink / raw)
  To: netdev

The return of num_possible_cpus() is same as nr_cpu_ids, but
nr_cpu_ids can reduce cpu computation

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 net/core/dev.c             | 4 ++--
 net/ipv4/inet_hashtables.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 89825c1eccdc..05c7bc6e4ce6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2189,7 +2189,7 @@ static void netif_reset_xps_queues(struct net_device *dev, u16 offset,
 	if (!dev_maps)
 		goto out_no_maps;
 
-	if (num_possible_cpus() > 1)
+	if (nr_cpu_ids > 1)
 		possible_mask = cpumask_bits(cpu_possible_mask);
 	nr_ids = nr_cpu_ids;
 	clean_xps_maps(dev, possible_mask, dev_maps, nr_ids, offset, count,
@@ -2273,7 +2273,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
 		nr_ids = dev->num_rx_queues;
 	} else {
 		maps_sz = XPS_CPU_DEV_MAPS_SIZE(num_tc);
-		if (num_possible_cpus() > 1) {
+		if (nr_cpu_ids > 1) {
 			online_mask = cpumask_bits(cpu_online_mask);
 			possible_mask = cpumask_bits(cpu_possible_mask);
 		}
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 3647167c8fa3..80cadf06fd3f 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -825,7 +825,7 @@ int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo)
 	if (locksz != 0) {
 		/* allocate 2 cache lines or at least one spinlock per cpu */
 		nblocks = max(2U * L1_CACHE_BYTES / locksz, 1U);
-		nblocks = roundup_pow_of_two(nblocks * num_possible_cpus());
+		nblocks = roundup_pow_of_two(nblocks * nr_cpu_ids);
 
 		/* no more locks than number of hash buckets */
 		nblocks = min(nblocks, hashinfo->ehash_mask + 1);
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids
  2018-07-06  9:33 [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids Li RongQing
@ 2018-07-08  4:04 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-08  4:04 UTC (permalink / raw)
  To: lirongqing; +Cc: netdev

From: Li RongQing <lirongqing@baidu.com>
Date: Fri,  6 Jul 2018 17:33:36 +0800

> The return of num_possible_cpus() is same as nr_cpu_ids, but
> nr_cpu_ids can reduce cpu computation
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>

These two numbers are not the same, in fact num_possible_cpus() can be
and often is smaller than nr_cpu_ids.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-08  4:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06  9:33 [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids Li RongQing
2018-07-08  4:04 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.