[PATCH] block: Replace NR_CPUS with num_online_cpus()

From: Sisir Koppaka
Date: Mon Mar 28 2011 - 13:41:12 EST


NR_CPUS is a boot state and hence, not indicative of the actual number
of online CPUs. This is a known checkpatch warning.

Signed-off-by: Sisir Koppaka <sisir.koppaka@xxxxxxxxx>
CC: Jens Axboe <jaxboe@xxxxxxxxxxxx>
CC: Tejun Heo <tj@xxxxxxxxxx>
---
block/blk.h | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/blk.h b/block/blk.h
index c8db371..9a55515 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -1,3 +1,4 @@
+#include <linux/cpumask.h>
#ifndef BLK_INTERNAL_H
#define BLK_INTERNAL_H

@@ -136,7 +137,7 @@ static inline int
queue_congestion_off_threshold(struct request_queue *q)

static inline int blk_cpu_to_group(int cpu)
{
- int group = NR_CPUS;
+ int group = num_online_cpus();
#ifdef CONFIG_SCHED_MC
const struct cpumask *mask = cpu_coregroup_mask(cpu);
group = cpumask_first(mask);
@@ -145,7 +146,7 @@ static inline int blk_cpu_to_group(int cpu)
#else
return cpu;
#endif
- if (likely(group < NR_CPUS))
+ if (likely(group < num_online_cpus()))
return group;
return cpu;
}
--
1.7.0.4

                sk
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/