Skip to contentSkip to conversation

powerpc : Fix sleeping-in-atomic section warning triggered by /proc/cpuinfo

PATCH New Shriya 1 participant 1 message Jan 10, 2018 PowerPC

lore
Share & tools
lore

Shriya

author
#0 lore raw

PATCH 1/1 powerpc : Fix sleeping-in-atomic section warning triggered by /proc/cpuinfo

Commit cd77b5ce208c ("Fix the frequency read by /proc/cpuinfo") to fix /proc/cpuinfo on POWERNV triggered a sleeping-in-atomic section warning. This was because the place where we cpufreq_get (which takes an rwsem) from show_cpuinfo is in a preempt_disabled. However, the preempt_disable() in show_cpuinfo is for protection against CPU-Hotplug, since we don't want to report the information of offline CPUs in /proc/cpuinfo.

Fix this by replacing preempt_disable()/preempt_enable() in show_cpuinfo() by get_online_cpus()/put_online_cpus() giving a proper protection against CPU-Hotplug.

---
 arch/powerpc/kernel/setup-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kernel/setup-common.c +3 -3
index 2075322..f772442 100644
@@ -244,9 +244,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 	/* We only show online cpus: disable preempt (overzealous, I
 	 * knew) to prevent cpu going down. */
-	preempt_disable();
+	get_online_cpus();
 	if (!cpu_online(cpu_id)) {
-		preempt_enable();
+		put_online_cpus();
 		return 0;
 	}
 
@@ -359,7 +359,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	seq_printf(m, "\n");
 #endif
 
-	preempt_enable();
+	put_online_cpus();
 
 	/* If this is the last cpu, print the summary */
 	if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)

--
1.9.1