Skip to contentSkip to conversation

include KERN_* constant in printk calls

PATCH In review Chris Sanford 5 participants 9 messages May 18, 2009 – May 21, 2009 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include KERN_* constant in printk calls

Add the KERN_CONT constant to two printk calls.

---

kernel/sched.c +2 -2
index 26efa47..6a2ed16 100644
@@ -7319,7 +7319,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
 
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		printk(KERN_CONT "does not load-balance\n");
 		if (sd->parent)
 			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");
@@ -7340,7 +7340,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s groups:", level + 1, "");
 	do {
 		if (!group) {
-			printk("\n");
+			printk(KERN_CONT "\n");
 			printk(KERN_ERR "ERROR: group is NULL\n");
 			break;
 		}
#1 lore raw
Quoted 21 lines · Chris Sanford

Add the KERN_CONT constant to two printk calls.

---

kernel/sched.c +1 -1
index 26efa47..6a2ed16 100644
@@ -7319,7 +7319,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
 
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		printk(KERN_CONT "does not load-balance\n");
 		if (sd->parent)
 			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7345

Quoted 7 lines
kernel/sched.c +1 -1
@@ -7340,7 +7340,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s groups:", level + 1, "");
 	do {
 		if (!group) {
-			printk("\n");
+			printk(KERN_CONT "\n");
 			printk(KERN_ERR "ERROR: group is NULL\n");
 			break;

Please use pr_cont() - and while at it, perhaps convert all other printk()s in sched.c from KERN_* to the pr_*() notation as well?

Thanks,

Ingo

#2 lore raw
Quoted 35 lines · Ingo Molnar
Quoted 21 lines · Chris Sanford

Add the KERN_CONT constant to two printk calls.

---

kernel/sched.c +1 -1
index 26efa47..6a2ed16 100644
@@ -7319,7 +7319,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
 
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		printk(KERN_CONT "does not load-balance\n");
 		if (sd->parent)
 			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7345

Quoted 7 lines
kernel/sched.c +1 -1
@@ -7340,7 +7340,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s groups:", level + 1, "");
 	do {
 		if (!group) {
-			printk("\n");
+			printk(KERN_CONT "\n");
 			printk(KERN_ERR "ERROR: group is NULL\n");
 			break;

Please use pr_cont() - and while at it, perhaps convert all other printk()s in sched.c from KERN_* to the pr_*() notation as well?

Quoted 4 lines

Thanks,

Ingo
--

The KERN_DEBUG constant is used 5 times when DEBUG is undefined. Doing a straight conversion from printk(KERN_DEBUG to pr_debug( will result in no messages being printed. Should these calls have a different message type, should DEBUG be defined, or should something else be done? Thanks,
Chris

#3 lore raw
Quoted 38 lines · Chris Sanford
Quoted 37 lines · Ingo Molnar
Quoted 21 lines · Chris Sanford

Add the KERN_CONT constant to two printk calls.

---

kernel/sched.c +1 -1
index 26efa47..6a2ed16 100644
@@ -7319,7 +7319,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
 
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		printk(KERN_CONT "does not load-balance\n");
 		if (sd->parent)
 			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7345

Quoted 7 lines
kernel/sched.c +1 -1
@@ -7340,7 +7340,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 	printk(KERN_DEBUG "%*s groups:", level + 1, "");
 	do {
 		if (!group) {
-			printk("\n");
+			printk(KERN_CONT "\n");
 			printk(KERN_ERR "ERROR: group is NULL\n");
 			break;

Please use pr_cont() - and while at it, perhaps convert all other printk()s in sched.c from KERN_* to the pr_*() notation as well?

Thanks,

Quoted 8 lines
Quoted 2 lines

Ingo
--

The KERN_DEBUG constant is used 5 times when DEBUG is undefined. Doing a straight conversion from printk(KERN_DEBUG to pr_debug( will result in no messages being printed. Should these calls have a different message type, should DEBUG be defined, or should something else be done?

good point - i think it's fine to change it to pr_info().

Ingo

#4 lore raw

Here is the updated patch for sched.c. It replaces all the printk calls with their corresponding pr_* call. The five KERN_DEBUG calls have been changed to pr_info.

---

kernel/sched.c +41 -41
index 26efa47..cfe42e7 100644
@@ -4912,7 +4912,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
 {
 	struct pt_regs *regs = get_irq_regs();
 
-	printk(KERN_ERR "BUG: scheduling while atomic: %s/%d/0x%08x\n",
+	pr_err("BUG: scheduling while atomic: %s/%d/0x%08x\n",
 		prev->comm, prev->pid, preempt_count());
 
 	debug_show_held_locks(prev);
@@ -6474,23 +6474,23 @@ void sched_show_task(struct task_struct *p)
 	unsigned state;
 
 	state = p->state ? __ffs(p->state) + 1 : 0;
-	printk(KERN_INFO "%-13.13s %c", p->comm,
+	pr_info("%-13.13s %c", p->comm,
 		state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
 #if BITS_PER_LONG = 32
 	if (state = TASK_RUNNING)
-		printk(KERN_CONT " running  ");
+		pr_cont(" running  ");
 	else
-		printk(KERN_CONT " %08lx ", thread_saved_pc(p));
+		pr_cont(" %08lx ", thread_saved_pc(p));
 #else
 	if (state = TASK_RUNNING)
-		printk(KERN_CONT "  running task    ");
+		pr_cont("  running task    ");
 	else
-		printk(KERN_CONT " %016lx ", thread_saved_pc(p));
+		pr_cont(" %016lx ", thread_saved_pc(p));
 #endif
 #ifdef CONFIG_DEBUG_STACK_USAGE
 	free = stack_not_used(p);
 #endif
-	printk(KERN_CONT "%5lu %5d %6d\n", free,
+	pr_cont("%5lu %5d %6d\n", free,
 		task_pid_nr(p), task_pid_nr(p->real_parent));
 
 	show_stack(p, NULL);
@@ -6501,10 +6501,10 @@ void show_state_filter(unsigned long state_filter)
 	struct task_struct *g, *p;
 
 #if BITS_PER_LONG = 32
-	printk(KERN_INFO
+	pr_info(
 		"  task                PC stack   pid father\n");
 #else
-	printk(KERN_INFO
+	pr_info(
 		"  task                        PC stack   pid father\n");
 #endif
 	read_lock(&tasklist_lock);
@@ -6833,7 +6833,7 @@ again:
 		 * leave kernel.
 		 */
 		if (p->mm && printk_ratelimit()) {
-			printk(KERN_INFO "process %d (%s) no "
+			pr_info("process %d (%s) no "
 			       "longer affine to cpu%d\n",
 			       task_pid_nr(p), p->comm, dead_cpu);
 		}
@@ -7315,52 +7315,52 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 
 	cpulist_scnprintf(str, sizeof(str), sched_domain_span(sd));
 	cpumask_clear(groupmask);
-
-	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
-
+	
+	pr_info("%*s domain %d: ", level, "", level);
+	
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		pr_cont("does not load-balance\n");
 		if (sd->parent)
-			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
+			pr_err("ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");
 		return -1;
 	}
 
-	printk(KERN_CONT "span %s level %s\n", str, sd->name);
+	pr_cont("span %s level %s\n", str, sd->name);
 
 	if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
-		printk(KERN_ERR "ERROR: domain->span does not contain "
+		pr_err("ERROR: domain->span does not contain "
 				"CPU%d\n", cpu);
 	}
 	if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) {
-		printk(KERN_ERR "ERROR: domain->groups does not contain"
+		pr_err("ERROR: domain->groups does not contain"
 				" CPU%d\n", cpu);
 	}
 
-	printk(KERN_DEBUG "%*s groups:", level + 1, "");
+	pr_info("%*s groups:", level + 1, "");
 	do {
 		if (!group) {
-			printk("\n");
-			printk(KERN_ERR "ERROR: group is NULL\n");
+			pr_cont("\n");
+			pr_err("ERROR: group is NULL\n");
 			break;
 		}
 
 		if (!group->__cpu_power) {
-			printk(KERN_CONT "\n");
-			printk(KERN_ERR "ERROR: domain->cpu_power not "
+			pr_cont("\n");
+			pr_err("ERROR: domain->cpu_power not "
 					"set\n");
 			break;
 		}
 
 		if (!cpumask_weight(sched_group_cpus(group))) {
-			printk(KERN_CONT "\n");
-			printk(KERN_ERR "ERROR: empty group\n");
+			pr_cont("\n");
+			pr_err("ERROR: empty group\n");
 			break;
 		}
 
 		if (cpumask_intersects(groupmask, sched_group_cpus(group))) {
-			printk(KERN_CONT "\n");
-			printk(KERN_ERR "ERROR: repeated CPUs\n");
+			pr_cont("\n");
+			pr_err("ERROR: repeated CPUs\n");
 			break;
 		}
 
@@ -7368,22 +7368,22 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 
 		cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));
 
-		printk(KERN_CONT " %s", str);
+		pr_cont(" %s", str);
 		if (group->__cpu_power != SCHED_LOAD_SCALE) {
-			printk(KERN_CONT " (__cpu_power = %d)",
+			pr_cont(" (__cpu_power = %d)",
 				group->__cpu_power);
 		}
 
 		group = group->next;
 	} while (group != sd->groups);
-	printk(KERN_CONT "\n");
+	pr_cont("\n");
 
 	if (!cpumask_equal(sched_domain_span(sd), groupmask))
-		printk(KERN_ERR "ERROR: groups don't span domain->span\n");
+		pr_err("ERROR: groups don't span domain->span\n");
 
 	if (sd->parent &&
 	    !cpumask_subset(groupmask, sched_domain_span(sd->parent)))
-		printk(KERN_ERR "ERROR: parent span is not a superset "
+		pr_err("ERROR: parent span is not a superset "
 			"of domain->span\n");
 	return 0;
 }
@@ -7394,14 +7394,14 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu)
 	int level = 0;
 
 	if (!sd) {
-		printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu);
+		pr_info("CPU%d attaching NULL sched-domain.\n", cpu);
 		return;
 	}
 
-	printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu);
+	pr_info("CPU%d attaching sched-domain:\n", cpu);
 
 	if (!alloc_cpumask_var(&groupmask, GFP_KERNEL)) {
-		printk(KERN_DEBUG "Cannot load-balance (out of memory)\n");
+		pr_info("Cannot load-balance (out of memory)\n");
 		return;
 	}
 
@@ -8095,14 +8095,14 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 	sched_group_nodes = kcalloc(nr_node_ids, sizeof(struct sched_group *),
 				    GFP_KERNEL);
 	if (!sched_group_nodes) {
-		printk(KERN_WARNING "Can not alloc sched group node list\n");
+		pr_warning("Can not alloc sched group node list\n");
 		goto free_tmpmask;
 	}
 #endif
 
 	rd = alloc_rootdomain();
 	if (!rd) {
-		printk(KERN_WARNING "Cannot alloc root domain\n");
+		pr_warning("Cannot alloc root domain\n");
 		goto free_sched_groups;
 	}
 
@@ -8241,7 +8241,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 		sg = kmalloc_node(sizeof(struct sched_group) + cpumask_size(),
 				  GFP_KERNEL, i);
 		if (!sg) {
-			printk(KERN_WARNING "Can not alloc domain group for "
+			pr_warning("Can not alloc domain group for "
 				"node %d\n", i);
 			goto error;
 		}
@@ -8275,7 +8275,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 					  cpumask_size(),
 					  GFP_KERNEL, i);
 			if (!sg) {
-				printk(KERN_WARNING
+				pr_warning(
 				"Can not alloc domain group for node %d\n", j);
 				goto error;
 			}
@@ -9075,10 +9075,10 @@ void __might_sleep(char *file, int line)
 		return;
 	prev_jiffy = jiffies;
 
-	printk(KERN_ERR
+	pr_err(
 		"BUG: sleeping function called from invalid context at %s:%d\n",
 			file, line);
-	printk(KERN_ERR
+	pr_err(
 		"in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
 			in_atomic(), irqs_disabled(),
 			current->pid, current->comm);
#5 lore raw

Hi Chris.

Minor comments.

kernel/sched.c

Quoted 4 lines · Chris Sanford
kernel/sched.c +0 -0
index 26efa47..cfe42e7 100644

[]

kernel/sched.c void show_state_filter(unsigned long state_filter) · line 6510

Quoted 13 lines
kernel/sched.c +2 -2
@@ -6501,10 +6501,10 @@ void show_state_filter(unsigned long state_filter)
 	struct task_struct *g, *p;
 
 #if BITS_PER_LONG = 32
-	printk(KERN_INFO
+	pr_info(
 		"  task                PC stack   pid father\n");
 #else
-	printk(KERN_INFO
+	pr_info(
 		"  task                        PC stack   pid father\n");
 #endif
 	read_lock(&tasklist_lock);

One line please. pr_info(" task etc...

kernel/sched.c again: · line 6839

Quoted 9 lines
kernel/sched.c +1 -1
@@ -6833,7 +6833,7 @@ again:
 		 * leave kernel.
 		 */
 		if (p->mm && printk_ratelimit()) {
-			printk(KERN_INFO "process %d (%s) no "
+			pr_info("process %d (%s) no "
 			       "longer affine to cpu%d\n",
 			       task_pid_nr(p), p->comm, dead_cpu);
 		}

pr_info("process $d (%s) no longer affine to cpu%d\n"

Quoted 7 lines
kernel/sched.c +0 -3
@@ -7315,52 +7315,52 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 
 	cpulist_scnprintf(str, sizeof(str), sched_domain_span(sd));
 	cpumask_clear(groupmask);
-
-	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
-

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7325

Quoted 10 lines
kernel/sched.c +5 -2
+	
+	pr_info("%*s domain %d: ", level, "", level);
+	
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
+		pr_cont("does not load-balance\n");
 		if (sd->parent)
-			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
+			pr_err("ERROR: !SD_LOAD_BALANCE domain"
 					" has parent");

Make single line and add "\n"?

pr_err("ERROR: !SD_LOAD_BALANCE domain has parent\n"

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7333

Quoted 10 lines
kernel/sched.c +2 -2
 		return -1;
 	}
 
-	printk(KERN_CONT "span %s level %s\n", str, sd->name);
+	pr_cont("span %s level %s\n", str, sd->name);
 
 	if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
-		printk(KERN_ERR "ERROR: domain->span does not contain "
+		pr_err("ERROR: domain->span does not contain "
 				"CPU%d\n", cpu);

Single line?

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7337

Quoted 5 lines
kernel/sched.c +1 -1
 	}
 	if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) {
-		printk(KERN_ERR "ERROR: domain->groups does not contain"
+		pr_err("ERROR: domain->groups does not contain"
 				" CPU%d\n", cpu);

Single line?

Quoted 16 lines
kernel/sched.c +3 -3
@@ -7368,22 +7368,22 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
 
 		cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));
 
-		printk(KERN_CONT " %s", str);
+		pr_cont(" %s", str);
 		if (group->__cpu_power != SCHED_LOAD_SCALE) {
-			printk(KERN_CONT " (__cpu_power = %d)",
+			pr_cont(" (__cpu_power = %d)",
 				group->__cpu_power);
 		}
 
 		group = group->next;
 	} while (group != sd->groups);
-	printk(KERN_CONT "\n");
+	pr_cont("\n");

kernel/sched.c static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, · line 7387

Quoted 10 lines
kernel/sched.c +2 -2
 
 	if (!cpumask_equal(sched_domain_span(sd), groupmask))
-		printk(KERN_ERR "ERROR: groups don't span domain->span\n");
+		pr_err("ERROR: groups don't span domain->span\n");
 
 	if (sd->parent &&
 	    !cpumask_subset(groupmask, sched_domain_span(sd->parent)))
-		printk(KERN_ERR "ERROR: parent span is not a superset "
+		pr_err("ERROR: parent span is not a superset "
 			"of domain->span\n");

Single line?

Quoted 7 lines
kernel/sched.c +1 -1
@@ -8095,14 +8095,14 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 	sched_group_nodes = kcalloc(nr_node_ids, sizeof(struct sched_group *),
 				    GFP_KERNEL);
 	if (!sched_group_nodes) {
-		printk(KERN_WARNING "Can not alloc sched group node list\n");
+		pr_warning("Can not alloc sched group node list\n");
 		goto free_tmpmask;

kernel/sched.c static int __build_sched_domains(const struct cpumask *cpu_map, · line 8108

Quoted 10 lines
kernel/sched.c +1 -1
 	}
 #endif
 
 	rd = alloc_rootdomain();
 	if (!rd) {
-		printk(KERN_WARNING "Cannot alloc root domain\n");
+		pr_warning("Cannot alloc root domain\n");
 		goto free_sched_groups;
 	}
 

"Can not" vs "Cannot", maybe choose a single style?

kernel/sched.c static int __build_sched_domains(const struct cpumask *cpu_map, · line 8245

Quoted 7 lines
kernel/sched.c +1 -1
@@ -8241,7 +8241,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 		sg = kmalloc_node(sizeof(struct sched_group) + cpumask_size(),
 				  GFP_KERNEL, i);
 		if (!sg) {
-			printk(KERN_WARNING "Can not alloc domain group for "
+			pr_warning("Can not alloc domain group for "
 				"node %d\n", i);

Single line string? Maybe:

			pr_warning("Can not alloc domain group for node %d\n",
				   i);

kernel/sched.c void __might_sleep(char *file, int line) · line 9080

Quoted 8 lines
kernel/sched.c +1 -1
@@ -9075,10 +9075,10 @@ void __might_sleep(char *file, int line)
 		return;
 	prev_jiffy = jiffies;
 
-	printk(KERN_ERR
+	pr_err(
 		"BUG: sleeping function called from invalid context at %s:%d\n",
 			file, line);

pr_err("BUG: etc

kernel/sched.c void __might_sleep(char *file, int line) · line 9084

Quoted 5 lines
kernel/sched.c +1 -1
-	printk(KERN_ERR
+	pr_err(
 		"in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
 			in_atomic(), irqs_disabled(),
 			current->pid, current->comm);

here too.

cheers, Joe

#6 lore raw

Here it is with your suggestions...

kernel/sched.c +0 -0
index 26efa47..c4fb502 100644

@@ -4912,7 +4912,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
{
struct pt_regs *regs = get_irq_regs();

- printk(KERN_ERR "BUG: scheduling while atomic: %s/%d/0x%08x\n",
+ pr_err("BUG: scheduling while atomic: %s/%d/0x%08x\n",
prev->comm, prev->pid, preempt_count());

debug_show_held_locks(prev);
@@ -6474,23 +6474,23 @@ void sched_show_task(struct task_struct *p)
unsigned state;

state = p->state ? __ffs(p->state) + 1 : 0;
- printk(KERN_INFO "%-13.13s %c", p->comm,
+ pr_info("%-13.13s %c", p->comm,
state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
#if BITS_PER_LONG = 32
if (state = TASK_RUNNING)
- printk(KERN_CONT " running ");
+ pr_cont(" running ");
else
- printk(KERN_CONT " %08lx ", thread_saved_pc(p));
+ pr_cont(" %08lx ", thread_saved_pc(p));
#else
if (state = TASK_RUNNING)
- printk(KERN_CONT " running task ");
+ pr_cont(" running task ");
else
- printk(KERN_CONT " %016lx ", thread_saved_pc(p));
+ pr_cont(" %016lx ", thread_saved_pc(p));
#endif
#ifdef CONFIG_DEBUG_STACK_USAGE
free = stack_not_used(p);
#endif
- printk(KERN_CONT "%5lu %5d %6d\n", free,
+ pr_cont("%5lu %5d %6d\n", free,
task_pid_nr(p), task_pid_nr(p->real_parent));

show_stack(p, NULL);
@@ -6501,11 +6501,9 @@ void show_state_filter(unsigned long state_filter)
struct task_struct *g, *p;

#if BITS_PER_LONG = 32
- printk(KERN_INFO
- " task PC stack pid father\n");
+ pr_info(" task PC stack pid father\n");
#else
- printk(KERN_INFO
- " task PC stack pid father\n");
+ pr_info(" task PC stack pid father\n");
#endif
read_lock(&tasklist_lock); do_each_thread(g, p) {
@@ -6833,9 +6831,8 @@ again:
* leave kernel.
*/
if (p->mm && printk_ratelimit()) {
- printk(KERN_INFO "process %d (%s) no "
- "longer affine to cpu%d\n",
- task_pid_nr(p), p->comm, dead_cpu);
+ pr_info("process %d (%s) no longer affine to cpu%d\n",
+ task_pid_nr(p), p->comm, dead_cpu);
}
}

@@ -7315,52 +7312,48 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,

cpulist_scnprintf(str, sizeof(str), sched_domain_span(sd)); cpumask_clear(groupmask);
-
- printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
-
+
+ pr_info("%*s domain %d: ", level, "", level);
+
if (!(sd->flags & SD_LOAD_BALANCE)) {
- printk("does not load-balance\n");
+ pr_cont("does not load-balance\n");
if (sd->parent)
- printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
- " has parent");
+ pr_err("ERROR: !SD_LOAD_BALANCE domain has parent\n");
return -1;
}

- printk(KERN_CONT "span %s level %s\n", str, sd->name);
+ pr_cont("span %s level %s\n", str, sd->name);

if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
- printk(KERN_ERR "ERROR: domain->span does not contain "
- "CPU%d\n", cpu);
+ pr_err("ERROR: domain->span does not contain CPU%d\n", cpu);
}
if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) {
- printk(KERN_ERR "ERROR: domain->groups does not contain"
- " CPU%d\n", cpu);
+ pr_err("ERROR: domain->groups does not contain CPU%d\n", cpu);
}

- printk(KERN_DEBUG "%*s groups:", level + 1, "");
+ pr_info("%*s groups:", level + 1, "");
do {
if (!group) {
- printk("\n");
- printk(KERN_ERR "ERROR: group is NULL\n");
+ pr_cont("\n");
+ pr_err("ERROR: group is NULL\n");
break;
}

if (!group->__cpu_power) {
- printk(KERN_CONT "\n");
- printk(KERN_ERR "ERROR: domain->cpu_power not "
- "set\n");
+ pr_cont("\n");
+ pr_err("ERROR: domain->cpu_power not set\n");
break;
}

if (!cpumask_weight(sched_group_cpus(group))) {
- printk(KERN_CONT "\n");
- printk(KERN_ERR "ERROR: empty group\n");
+ pr_cont("\n");
+ pr_err("ERROR: empty group\n");
break;
}

if (cpumask_intersects(groupmask, sched_group_cpus(group))) {
- printk(KERN_CONT "\n");
- printk(KERN_ERR "ERROR: repeated CPUs\n");
+ pr_cont("\n");
+ pr_err("ERROR: repeated CPUs\n");
break;
}

@@ -7368,23 +7361,22 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,

cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));

- printk(KERN_CONT " %s", str);
+ pr_cont(" %s", str);
if (group->__cpu_power != SCHED_LOAD_SCALE) {
- printk(KERN_CONT " (__cpu_power = %d)",
+ pr_cont(" (__cpu_power = %d)",
group->__cpu_power);
}

group = group->next;
} while (group != sd->groups);
- printk(KERN_CONT "\n");
+ pr_cont("\n");

if (!cpumask_equal(sched_domain_span(sd), groupmask))
- printk(KERN_ERR "ERROR: groups don't span domain->span\n");
+ pr_err("ERROR: groups don't span domain->span\n");

if (sd->parent &&
!cpumask_subset(groupmask, sched_domain_span(sd->parent)))
- printk(KERN_ERR "ERROR: parent span is not a superset "
- "of domain->span\n");
+ pr_err("ERROR: parent span is not a superset of domain->span\n");
return 0;
}

@@ -7394,14 +7386,14 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu)
int level = 0;

if (!sd) {
- printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu);
+ pr_info("CPU%d attaching NULL sched-domain.\n", cpu);
return;
}

- printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu);
+ pr_info("CPU%d attaching sched-domain:\n", cpu);

if (!alloc_cpumask_var(&groupmask, GFP_KERNEL)) {
- printk(KERN_DEBUG "Cannot load-balance (out of memory)\n");
+ pr_info("Cannot load-balance (out of memory)\n");
return;
}

@@ -8095,14 +8087,14 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
sched_group_nodes = kcalloc(nr_node_ids, sizeof(struct sched_group *),
GFP_KERNEL);
if (!sched_group_nodes) {
- printk(KERN_WARNING "Can not alloc sched group node list\n");
+ pr_warning("Cannot alloc sched group node list\n");
goto free_tmpmask;
}
#endif

rd = alloc_rootdomain();
if (!rd) {
- printk(KERN_WARNING "Cannot alloc root domain\n");
+ pr_warning("Cannot alloc root domain\n");
goto free_sched_groups;
}

@@ -8241,8 +8233,8 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
sg = kmalloc_node(sizeof(struct sched_group) + cpumask_size(),
GFP_KERNEL, i);
if (!sg) {
- printk(KERN_WARNING "Can not alloc domain group for "
- "node %d\n", i);
+ pr_warning("Cannot alloc domain group for node %d\n",
+ i);
goto error;
}
sched_group_nodes[i] = sg;
@@ -8275,8 +8267,8 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
cpumask_size(),
GFP_KERNEL, i);
if (!sg) {
- printk(KERN_WARNING
- "Can not alloc domain group for node %d\n", j);
+ pr_warning(
+ "Cannot alloc domain group for node %d\n", j);
goto error;
}
sg->__cpu_power = 0;
@@ -9075,13 +9067,11 @@ void __might_sleep(char *file, int line)
return;
prev_jiffy = jiffies;

- printk(KERN_ERR
- "BUG: sleeping function called from invalid context at %s:%d\n",
- file, line);
- printk(KERN_ERR
- "in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
- in_atomic(), irqs_disabled(),
- current->pid, current->comm);
+ pr_err("BUG: sleeping function called from invalid context at %s:%d\n",
+ file, line);
+ pr_err("in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
+ in_atomic(), irqs_disabled(),
+ current->pid, current->comm);

debug_show_held_locks(current);
if (irqs_disabled())

#7 lore raw
In reply to Chris Sanford
Quoted 3 lines · Chris Sanford

Here is the updated patch for sched.c. It replaces all the printk calls with their corresponding pr_* call. The five KERN_DEBUG calls have been changed to pr_info.

Switching from KERN_DEBUG to KERN_INFO means the messages will now appear for most people, whereas previously they didn't. I'm not sure that's a great idea.

If you really want to convert them, then I think we need a macro for KERN_DEBUG but not conditionally compiled like pr_debug.

I sent a patch for that once, but I don't think anyone liked it, and I've lost it now :D

cheers

#8 lore raw
Quoted 9 lines · Michael Ellerman
Quoted 3 lines · Chris Sanford

Here is the updated patch for sched.c. It replaces all the printk calls with their corresponding pr_* call. The five KERN_DEBUG calls have been changed to pr_info.

Switching from KERN_DEBUG to KERN_INFO means the messages will now appear for most people, whereas previously they didn't. I'm not sure that's a great idea.

Quoted 6 lines

If you really want to convert them, then I think we need a macro for KERN_DEBUG but not conditionally compiled like pr_debug.

I sent a patch for that once, but I don't think anyone liked it, and I've lost it now :D

beeing mainly a user theses days i would like to comment ...

It is fine if debug statements are disabled within NO_DEBUG mode. As user i find them annoying because i do not care. KERN_INFO is ok and if people complain they need more info someone can always change from DEBUG to INFO.
putting to much info into syslog simply drowns important informations. so keep it as pr_debug().

just my 2 cents,
wh