From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934719AbcALKz1 (ORCPT ); Tue, 12 Jan 2016 05:55:27 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:33972 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964992AbcALKyv (ORCPT ); Tue, 12 Jan 2016 05:54:51 -0500 Date: Tue, 12 Jan 2016 16:24:47 +0530 From: Viresh Kumar To: Juri Lelli Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, rjw@rjwysocki.net, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com Subject: Re: [RFC PATCH 13/19] cpufreq: fix locking of policy->rwsem in cpufreq_offline_prepare Message-ID: <20160112105447.GE1084@ubuntu> References: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> <1452533760-13787-14-git-send-email-juri.lelli@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452533760-13787-14-git-send-email-juri.lelli@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11-01-16, 17:35, Juri Lelli wrote: > There are paths in cpufreq_offline_prepare where policy is used, but its > rwsem is not held. > > Fix it. > > Cc: "Rafael J. Wysocki" > Cc: Viresh Kumar > Signed-off-by: Juri Lelli > --- > drivers/cpufreq/cpufreq.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) I know the locking in general in cpufreq core is poor. We recently fixed lots of issues in governors .. > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 2c7cc6c73..91158b0 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1332,13 +1332,13 @@ static void cpufreq_offline_prepare(unsigned int cpu) > return; > } > > + down_write(&policy->rwsem); > if (has_target()) { > int ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); > if (ret) > pr_err("%s: Failed to stop governor\n", __func__); > } > > - down_write(&policy->rwsem); > cpumask_clear_cpu(cpu, policy->cpus); > > if (policy_is_inactive(policy)) { > @@ -1356,12 +1356,16 @@ static void cpufreq_offline_prepare(unsigned int cpu) > /* Start governor again for active policy */ > if (!policy_is_inactive(policy)) { Why shouldn't this be under the lock? > if (has_target()) { > - int ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); > + int ret; > + > + down_write(&policy->rwsem); > + ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); > if (!ret) > ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); > > if (ret) > pr_err("%s: Failed to start governor\n", __func__); > + up_write(&policy->rwsem); > } > } else if (cpufreq_driver->stop_cpu) { > cpufreq_driver->stop_cpu(policy); And this ? -- viresh