Skip to contentSkip to conversation

sched: fix the wrong mask_len

PATCH Applied Miao Xie 4 participants 6 messages Oct 17, 2008

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 1/1 sched: fix the wrong mask_len

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

This patch fix it.

---
 kernel/sched_stats.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched_stats.h +1 -1
index 8385d43..81365b3 100644
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = (NR_CPUS/32 + 1) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 
 	if (mask_str == NULL)
Signature · 1 line
1.5.4.rc3
#1 lore raw
Quoted 16 lines

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

This patch fix it.

---
 kernel/sched_stats.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched_stats.h +0 -0
index 8385d43..81365b3 100644

kernel/sched_stats.h line 14

Quoted 7 lines
kernel/sched_stats.h +1 -1
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = (NR_CPUS/32 + 1) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 

DIV_ROUND_UP() is better?

#2 lore raw
Quoted 11 lines · KOSAKI Motohiro
Quoted 11 lines

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

This patch fix it.

---
 kernel/sched_stats.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 14 lines

kernel/sched_stats.h line 14

Quoted 12 lines
kernel/sched_stats.h +1 -1
index 8385d43..81365b3 100644
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = (NR_CPUS/32 + 1) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 

DIV_ROUND_UP() is better?

Agreed

#3 lore raw
Quoted 27 lines · Peter Zijlstra
Quoted 11 lines · KOSAKI Motohiro
Quoted 11 lines

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

This patch fix it.

---
 kernel/sched_stats.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 14 lines

kernel/sched_stats.h line 14

Quoted 12 lines
kernel/sched_stats.h +1 -1
index 8385d43..81365b3 100644
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = (NR_CPUS/32 + 1) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 

DIV_ROUND_UP() is better?

Quoted 1 line

Agreed

---
Subject: sched: fix the wrong mask_len
From: Peter Zijlstra <[email protected]>
Date: Fri Oct 17 12:55:57 CEST 2008

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

---
 kernel/sched_stats.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched_stats.h +1 -1
Index: linux-2.6/kernel/sched_stats.h
===================================================================
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = DIV_ROUND_UP(NR_CPUS, 32) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 
 	if (mask_str == NULL)
#4 lore raw
Quoted 19 lines

---
Subject: sched: fix the wrong mask_len
From: Peter Zijlstra <[email protected]>
Date: Fri Oct 17 12:55:57 CEST 2008

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

---
 kernel/sched_stats.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/kernel/sched_stats.h
===================================================================

kernel/sched_stats.h line 15

Quoted 8 lines
kernel/sched_stats.h +1 -1
@@ -9,7 +9,7 @@
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
-	int mask_len = NR_CPUS/32 * 9;
+	int mask_len = DIV_ROUND_UP(NR_CPUS, 32) * 9;
 	char *mask_str = kmalloc(mask_len, GFP_KERNEL);
 
 	if (mask_str == NULL)
Applied
#5 lore raw
In reply to Miao Xie
Quoted 6 lines · Miao Xie

If the NR_CPUS isn't a multiple of 32, we get a truncated string of sched domains by catting /proc/schedstat. This is caused by the wrong mask_len.

This patch fix it.

applied to tip/sched/urgent, thanks!

Ingo