Skip to contentSkip to conversation

ext4: Convert the usage of NR_CPUS to nr_cpu_ids.

PATCH In review Aneesh Kumar K.V 3 participants 4 messages Jul 22, 2008 – Jul 23, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Convert the usage of NR_CPUS to nr_cpu_ids.

NR_CPUS can be really large. We should be using nr_cpu_ids instead.

---
 fs/ext4/mballoc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +2 -2
index 9db0f4d..5b854b7 100644
@@ -2541,7 +2541,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
 	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
 	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
 
-	i = sizeof(struct ext4_locality_group) * NR_CPUS;
+	i = sizeof(struct ext4_locality_group) * nr_cpu_ids;
 	sbi->s_locality_groups = kmalloc(i, GFP_KERNEL);
 	if (sbi->s_locality_groups == NULL) {
 		clear_opt(sbi->s_mount_opt, MBALLOC);
@@ -2549,7 +2549,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
 		kfree(sbi->s_mb_maxs);
 		return -ENOMEM;
 	}
-	for (i = 0; i < NR_CPUS; i++) {
+	for (i = 0; i < nr_cpu_ids; i++) {
 		struct ext4_locality_group *lg;
 		lg = &sbi->s_locality_groups[i];
 		mutex_init(&lg->lg_mutex);
Signature · 1 line
1.5.6.3.439.g1e10.dirty
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Aneesh Kumar K.V

NR_CPUS can be really large. We should be using nr_cpu_ids instead.

Yep, thanks, I thought we got rid of these at some point but guess not (or not all)!

Quoted 1 line
Quoted 26 lines
---
 fs/ext4/mballoc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +2 -2
index 9db0f4d..5b854b7 100644
@@ -2541,7 +2541,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
 	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
 	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
 
-	i = sizeof(struct ext4_locality_group) * NR_CPUS;
+	i = sizeof(struct ext4_locality_group) * nr_cpu_ids;
 	sbi->s_locality_groups = kmalloc(i, GFP_KERNEL);
 	if (sbi->s_locality_groups == NULL) {
 		clear_opt(sbi->s_mount_opt, MBALLOC);
@@ -2549,7 +2549,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
 		kfree(sbi->s_mb_maxs);
 		return -ENOMEM;
 	}
-	for (i = 0; i < NR_CPUS; i++) {
+	for (i = 0; i < nr_cpu_ids; i++) {
 		struct ext4_locality_group *lg;
 		lg = &sbi->s_locality_groups[i];
 		mutex_init(&lg->lg_mutex);
#2 lore raw
In reply to Aneesh Kumar K.V
Quoted 2 lines · Aneesh Kumar

NR_CPUS can be really large. We should be using nr_cpu_ids instead.

Should this actually be num_possible_cpus() or num_online_cpus()? I've never seen nr_cpu_ids used before.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#3 lore raw
Quoted 7 lines · Andreas Dilger
Quoted 2 lines · Aneesh Kumar

NR_CPUS can be really large. We should be using nr_cpu_ids instead.

Should this actually be num_possible_cpus() or num_online_cpus()? I've never seen nr_cpu_ids used before.

introduced in
git show 53b8a315b76a3f3c70a5644976c0095460eb13d8
[PATCH] Convert highest_possible_processor_id to nr_cpu_ids

lots of eg: that does NR_CPU to nr_cpu_ids conversion

git show 0c0b0aca66b3a58e12a216d992a0b534eff210e0
net: remove NR_CPUS arrays in net/core/dev.c

-aneesh