Netdev List
 help / color / mirror / Atom feed
From: Li RongQing <lirongqing@baidu.com>
To: netdev@vger.kernel.org
Subject: [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids
Date: Fri,  6 Jul 2018 17:33:36 +0800	[thread overview]
Message-ID: <1530869616-3572-1-git-send-email-lirongqing@baidu.com> (raw)

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

             reply	other threads:[~2018-07-06  9:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06  9:33 Li RongQing [this message]
2018-07-08  4:04 ` [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids David Miller

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=1530869616-3572-1-git-send-email-lirongqing@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=netdev@vger.kernel.org \
    /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