From patchwork Thu Feb 4 06:43:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61158 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp284392lbl; Wed, 3 Feb 2016 22:43:20 -0800 (PST) X-Received: by 10.66.140.14 with SMTP id rc14mr8597262pab.65.1454568200760; Wed, 03 Feb 2016 22:43:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n81si14646473pfi.46.2016.02.03.22.43.20; Wed, 03 Feb 2016 22:43:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756017AbcBDGnN (ORCPT + 30 others); Thu, 4 Feb 2016 01:43:13 -0500 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35702 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755274AbcBDGnH (ORCPT ); Thu, 4 Feb 2016 01:43:07 -0500 Received: by mail-pf0-f174.google.com with SMTP id 65so34466918pfd.2 for ; Wed, 03 Feb 2016 22:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=GCrPJo47Sprm9WIv5QNHjp6Rrlna2T+//u5IZt1cZ5o=; b=WOonv7Tw88l6TKAuJL454w00BA8Pr1a2fo4iMYvN+bBK+Pq4jDfXUOp0qPKhu3Z8wJ vfG/lGAiFgq3WrlDyEFeFkOQJ8yCx7G7wvbgRN1UP3INqBz7f8XNsnRW3xTZu5UYFFl2 rOE8o1drWj7FpNQ2KpAG/hhtk8rAPQf3d94Qc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=GCrPJo47Sprm9WIv5QNHjp6Rrlna2T+//u5IZt1cZ5o=; b=CqhHTDJCwV6qQfHeAnLGiFsYeo2y7DAakiZAxEJC6XOl8VOIElx69rgNqGRyHVI1ej 3VRYQ2SMkVbOeEr9Io4AqnXhAvMGLzOYarnibSpo5Tbi2GOp3mPlp7yuNvSCMp7nKvGM hdC6R08fYxviF0ZbZN/DJ+eYJJhNyth2o0t6ccz3DlFNkpmEuYzCpni4GispyfWlJdTB GMGAMzMmex4GaS+C0yohGPBI0rDh5eL7SgAGq33ysTVfjDPgiuYEYyp/lkc2LHkDs0O9 0Ds7bcN/5xbUU8CxIK8RkNj02Me5JXRoGB8fEjhqzqMEZfhxmLe4qfTE3kwvFwWgJJO0 F/og== X-Gm-Message-State: AG10YOSwSGz5pujOmzAjbT/T3yxjsqOcWw8tXY11J8c8JysYBWZHNx8WmPM3FpmebFNxt6eS X-Received: by 10.98.34.212 with SMTP id p81mr8573283pfj.23.1454568187188; Wed, 03 Feb 2016 22:43:07 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id uk10sm14209093pab.31.2016.02.03.22.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 22:43:06 -0800 (PST) Date: Thu, 4 Feb 2016 12:13:04 +0530 From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, peterz@infradead.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 7/7] cpufreq: Remove cpufreq_governor_lock Message-ID: <20160204064304.GA3469@vireshk> References: <75f5a53c38b1efcfe7dc496525b0e96b6343a93e.1454507872.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <75f5a53c38b1efcfe7dc496525b0e96b6343a93e.1454507872.git.viresh.kumar@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-02-16, 19:32, Viresh Kumar wrote: > We used to drop policy->rwsem just before calling __cpufreq_governor() > in some cases earlier and so it was possible that __cpufreq_governor() > runs concurrently via separate threads. > > In order to guarantee valid state transitions for governors, > 'governor_enabled' was required to be protected using some locking and > we created cpufreq_governor_lock for that. > > But now, __cpufreq_governor() is always called from within policy->rwsem > held and so 'governor_enabled' is protected against races even without > cpufreq_governor_lock. > > Get rid of the extra lock now. > > Signed-off-by: Viresh Kumar > --- > drivers/cpufreq/cpufreq.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 4fc3889ca7c9..7bc8a5ed97e5 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -102,7 +102,6 @@ static LIST_HEAD(cpufreq_governor_list); > static struct cpufreq_driver *cpufreq_driver; > static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); > static DEFINE_RWLOCK(cpufreq_driver_lock); > -DEFINE_MUTEX(cpufreq_governor_lock); > > /* Flag to suspend/resume CPUFreq governors */ > static bool cpufreq_suspended; > @@ -1963,11 +1962,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, > > pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event); > > - mutex_lock(&cpufreq_governor_lock); > if ((policy->governor_enabled && event == CPUFREQ_GOV_START) > || (!policy->governor_enabled > && (event == CPUFREQ_GOV_LIMITS || event == CPUFREQ_GOV_STOP))) { > - mutex_unlock(&cpufreq_governor_lock); > return -EBUSY; > } > > @@ -1976,8 +1973,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, > else if (event == CPUFREQ_GOV_START) > policy->governor_enabled = true; > > - mutex_unlock(&cpufreq_governor_lock); > - > ret = policy->governor->governor(policy, event); > > if (!ret) { > @@ -1987,12 +1982,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, > policy->governor->initialized--; > } else { > /* Restore original values */ > - mutex_lock(&cpufreq_governor_lock); > if (event == CPUFREQ_GOV_STOP) > policy->governor_enabled = true; > else if (event == CPUFREQ_GOV_START) > policy->governor_enabled = false; > - mutex_unlock(&cpufreq_governor_lock); > } > > if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) || + minor cleanup: -- viresh diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index ed328a39c4ac..7bed63e14e7d 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -214,7 +214,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) return delay; } -extern struct mutex cpufreq_governor_lock; extern const struct sysfs_ops governor_sysfs_ops; void gov_add_timers(struct cpufreq_policy *policy, unsigned int delay);