From patchwork Fri May 20 01:34:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9128509 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 70D5C60213 for ; Fri, 20 May 2016 01:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63581200E7 for ; Fri, 20 May 2016 01:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57937209D7; Fri, 20 May 2016 01:31:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00,FSL_HELO_HOME, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61044200E7 for ; Fri, 20 May 2016 01:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754049AbcETBbV (ORCPT ); Thu, 19 May 2016 21:31:21 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:42186 "HELO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754038AbcETBbU (ORCPT ); Thu, 19 May 2016 21:31:20 -0400 Received: from 217.96.254.2.ipv4.supernova.orange.pl (217.96.254.2) (HELO vostro.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer v0.80.2) id e117b0918f153bbb; Fri, 20 May 2016 03:31:17 +0200 From: "Rafael J. Wysocki" To: Linux PM list Cc: Linux Kernel Mailing List , Viresh Kumar , Srinivas Pandruvada Subject: [PATCH] cpufreq: stats: Walk online CPUs with CPU offline/online locked Date: Fri, 20 May 2016 03:34:51 +0200 Message-ID: <19792191.esL3UuyORb@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.5.0-rc1+; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki 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 --- drivers/cpufreq/cpufreq_stats.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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(¬ifier_policy_block, CPUFREQ_POLICY_NOTIFIER); cpufreq_unregister_notifier(¬ifier_trans_block, CPUFREQ_TRANSITION_NOTIFIER); + for_each_online_cpu(cpu) cpufreq_stats_free_table(cpu); + + put_online_cpus(); } MODULE_AUTHOR("Zou Nan hai ");