linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: stats: Walk online CPUs with CPU offline/online locked
@ 2016-05-20  1:34 Rafael J. Wysocki
  2016-05-20  1:41 ` [PATCH v2] " Rafael J. Wysocki
  0 siblings, 1 reply; 15+ messages in thread
From: Rafael J. Wysocki @ 2016-05-20  1:34 UTC (permalink / raw)
  To: Linux PM list
  Cc: Linux Kernel Mailing List, Viresh Kumar, Srinivas Pandruvada

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Loops over online CPUs in cpufreq_stats_init() and cpufreq_stats_exit()
should be carried out with CPU offline/online locked or races are
possible otherwise, so make that happen.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_stats.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq_stats.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_stats.c
+++ linux-pm/drivers/cpufreq/cpufreq_stats.c
@@ -322,6 +322,8 @@ static int __init cpufreq_stats_init(voi
 	if (ret)
 		return ret;
 
+	get_online_cpus();
+
 	for_each_online_cpu(cpu)
 		cpufreq_stats_create_table(cpu);
 
@@ -332,21 +334,27 @@ static int __init cpufreq_stats_init(voi
 				CPUFREQ_POLICY_NOTIFIER);
 		for_each_online_cpu(cpu)
 			cpufreq_stats_free_table(cpu);
-		return ret;
 	}
 
-	return 0;
+	put_online_cpus();
+
+	return ret;
 }
 static void __exit cpufreq_stats_exit(void)
 {
 	unsigned int cpu;
 
+	get_online_cpus();
+
 	cpufreq_unregister_notifier(&notifier_policy_block,
 			CPUFREQ_POLICY_NOTIFIER);
 	cpufreq_unregister_notifier(&notifier_trans_block,
 			CPUFREQ_TRANSITION_NOTIFIER);
+
 	for_each_online_cpu(cpu)
 		cpufreq_stats_free_table(cpu);
+
+	put_online_cpus();
 }
 
 MODULE_AUTHOR("Zou Nan hai <nanhai.zou@intel.com>");

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-05-25  2:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20  1:34 [PATCH] cpufreq: stats: Walk online CPUs with CPU offline/online locked Rafael J. Wysocki
2016-05-20  1:41 ` [PATCH v2] " Rafael J. Wysocki
2016-05-20  2:22   ` Viresh Kumar
2016-05-20 12:13     ` Rafael J. Wysocki
2016-05-20 21:33       ` Rafael J. Wysocki
2016-05-23  3:57         ` Viresh Kumar
2016-05-23 13:40           ` Rafael J. Wysocki
2016-05-23 15:19             ` Viresh Kumar
2016-05-23 20:47               ` Rafael J. Wysocki
2016-05-24  4:56                 ` Viresh Kumar
2016-05-24 12:13                   ` Rafael J. Wysocki
2016-05-24 12:17                     ` Viresh Kumar
2016-05-25  0:00                       ` Rafael J. Wysocki
2016-05-25  0:48                         ` Rafael J. Wysocki
2016-05-25  2:07                           ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).