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 <lirongq...@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