From patchwork Thu Feb 11 12:01:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61735 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp146962lbl; Thu, 11 Feb 2016 04:03:27 -0800 (PST) X-Received: by 10.66.120.200 with SMTP id le8mr66266332pab.61.1455192207457; Thu, 11 Feb 2016 04:03:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sk8si12298872pac.44.2016.02.11.04.03.27; Thu, 11 Feb 2016 04:03:27 -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 S1752709AbcBKMDX (ORCPT + 30 others); Thu, 11 Feb 2016 07:03:23 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34076 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752430AbcBKMBk (ORCPT ); Thu, 11 Feb 2016 07:01:40 -0500 Received: by mail-pf0-f182.google.com with SMTP id x65so28593817pfb.1 for ; Thu, 11 Feb 2016 04:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=4tcqRlRIjOVcJ3VR8jhYf4VluKrGEKBLnWUGscWpf/Q=; b=dAOe8HZKHoVYgGIueFQgUrs0IpettM5Ikd6Gtd0KBNrXB87wdXO/moM12uRSlZEfja opzJ6scxzY1x/1uuC7xU68QD4jBu0ilLGiXajs6finDzu9ANCQ5rAp39X+4WlS00ScUg mNZK6SVK0ayBMS2+j+vDPtSkMOLClgYV//wXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=4tcqRlRIjOVcJ3VR8jhYf4VluKrGEKBLnWUGscWpf/Q=; b=ESF1vnXAc1HZgyKVOxwhBCzapYMcJE8osSiI2cGidW63mBYomEGcc4gqpMoO/Yu6n3 k8/kkiETQoTf8p9iNPfv5sb2SOuKDJpI6LZOsSVqON3OkS+whnylN75kxWvJJ5zDpDqk 8/pPiO/1eJlOJlNu+LfiB4mMlbQs9IKNyiU7+bAZ04axOmzE9u8YahLQD5rzqfDNzns1 DjyPoZOFtz9FyaMkbtxolTO4Iy2qEBXDOE7pFVQROugQdswk5KadxHkUPgYSBTSlpJcI vXaxfFqtF/BTCxIEps0diOFrQBoCixTxsQYIdyvjXntrGmN4VBXUBDdmaIgpNF+9ZBYa zLyA== X-Gm-Message-State: AG10YORQ5RRmDWi4XzkmBixeJ2rBG2t1ooc3+xpnK0bA6eGPUPbcnzkhsN2spE9cOGZYLTka X-Received: by 10.98.75.200 with SMTP id d69mr66665494pfj.108.1455192100264; Thu, 11 Feb 2016 04:01:40 -0800 (PST) Received: from localhost ([122.172.89.184]) by smtp.gmail.com with ESMTPSA id 82sm11921200pfn.89.2016.02.11.04.01.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 04:01:39 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V5 3/6] cpufreq: Remove cpufreq_governor_lock Date: Thu, 11 Feb 2016 17:31:13 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Juri Lelli Tested-by: Shilpasri G Bhat --- drivers/cpufreq/cpufreq.c | 8 -------- drivers/cpufreq/cpufreq_governor.h | 1 - 2 files changed, 9 deletions(-) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 51fb47cd38a0..745da90d7b38 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -146,8 +146,6 @@ void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) rcu_read_unlock(); } -DEFINE_MUTEX(cpufreq_governor_lock); - /* Flag to suspend/resume CPUFreq governors */ static bool cpufreq_suspended; @@ -2014,11 +2012,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; } @@ -2027,8 +2023,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) { @@ -2038,12 +2032,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) || diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 4e77efb7db67..02885e353dfc 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -232,7 +232,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) } extern struct mutex dbs_data_mutex; -extern struct mutex cpufreq_governor_lock; void dbs_check_cpu(struct cpufreq_policy *policy); int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); void od_register_powersave_bias_handler(unsigned int (*f)