From patchwork Fri Jan 2 05:46:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 42670 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEB0D26CB5 for ; Fri, 2 Jan 2015 05:47:52 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf10472277lbj.3 for ; Thu, 01 Jan 2015 21:47:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=k1tisHjlh+YkBGiKUi4soQlW4WJDvHPXLx6ecxSLs3c=; b=CHv/BgaXNhmKH6fSuZncySTBWJfLHFbKbqh9EM0yre9SEvkv6NlqQ865iCRd1RFJ1M b0YhGGxV4JOhZt3fVpudCqQtCaxDKdzujw7w9YN6CKT06JymFa3dyxg/UL58KjU4/PHL cKuhSx7UNsFetSGwfc6oWZLRPGJJzA22TD6QlkFzWNRFxN9vJgesbf1UH+bT0jxgLFn4 jNXgJU0+hJLa72R2khH1VUURvehLlm74YWao+qSmqJZzB4DV6f8z+5RIFYvz94+ixqIv a6J2GycZ/AP8gkRhdrND2+NVd1MPHlkUTlo9R8kGSwih4+Kxw9ncFEEqTQYyjcCE6/NE Mqfg== X-Gm-Message-State: ALoCoQkkc5pvnIgL5wzs//OvTk+q9EkGxVmjqmGSQmvRuiNMKDdMvZiMfpvYaip5sLJmrQkRwNIV X-Received: by 10.181.13.18 with SMTP id eu18mr367422wid.7.1420177671861; Thu, 01 Jan 2015 21:47:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.66 with SMTP id le2ls2203724lac.90.gmail; Thu, 01 Jan 2015 21:47:51 -0800 (PST) X-Received: by 10.112.13.103 with SMTP id g7mr8342611lbc.29.1420177671561; Thu, 01 Jan 2015 21:47:51 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id h5si50306378lbs.69.2015.01.01.21.47.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Jan 2015 21:47:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id z12so14706071lbi.32 for ; Thu, 01 Jan 2015 21:47:51 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr75262476laj.74.1420177671450; Thu, 01 Jan 2015 21:47:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp114525lbb; Thu, 1 Jan 2015 21:47:50 -0800 (PST) X-Received: by 10.70.37.35 with SMTP id v3mr119080780pdj.4.1420177670230; Thu, 01 Jan 2015 21:47:50 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si68097479pdc.177.2015.01.01.21.47.49; Thu, 01 Jan 2015 21:47:50 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750747AbbABFrs (ORCPT + 12 others); Fri, 2 Jan 2015 00:47:48 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:51941 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbbABFrs (ORCPT ); Fri, 2 Jan 2015 00:47:48 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so22864778pdb.8 for ; Thu, 01 Jan 2015 21:47:47 -0800 (PST) X-Received: by 10.66.182.200 with SMTP id eg8mr120449877pac.53.1420177667693; Thu, 01 Jan 2015 21:47:47 -0800 (PST) Received: from localhost ([122.167.116.151]) by mx.google.com with ESMTPSA id h2sm28915180pat.20.2015.01.01.21.47.46 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Jan 2015 21:47:47 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH V2 12/14] cpufreq: stats: replace spinlock with mutex Date: Fri, 2 Jan 2015 11:16:49 +0530 Message-Id: <7b128a0d00c54b6354ab217e905fbee0e3436e84.1420177186.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.2.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Later commit will allocate memory from within the spinlock as that would be part of critical region. kzalloc() might sleep and we can't sleep from inside spinlocks critical region, so convert the spinlock into a mutex. Reviewed-by: Prarit Bhargava Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 7701532b32c8..de55ca86b6f1 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -12,10 +12,11 @@ #include #include #include +#include #include #include -static spinlock_t cpufreq_stats_lock; +static DEFINE_MUTEX(cpufreq_stats_lock); struct cpufreq_stats { unsigned int total_trans; @@ -39,12 +40,12 @@ static int cpufreq_stats_update(struct cpufreq_stats *stat) { unsigned long long cur_time = get_jiffies_64(); - spin_lock(&cpufreq_stats_lock); + mutex_lock(&cpufreq_stats_lock); if (stat->time_in_state) stat->time_in_state[stat->last_index] += cur_time - stat->last_time; stat->last_time = cur_time; - spin_unlock(&cpufreq_stats_lock); + mutex_unlock(&cpufreq_stats_lock); return 0; } @@ -218,10 +219,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) stat->freq_table[i++] = pos->frequency; stat->state_num = i; - spin_lock(&cpufreq_stats_lock); + mutex_lock(&cpufreq_stats_lock); stat->last_time = get_jiffies_64(); stat->last_index = freq_table_get_index(stat, policy->cur); - spin_unlock(&cpufreq_stats_lock); + mutex_unlock(&cpufreq_stats_lock); policy->stats_data = stat; ret = sysfs_create_group(&policy->kobj, &stats_attr_group); @@ -298,13 +299,13 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, cpufreq_stats_update(stat); - spin_lock(&cpufreq_stats_lock); + mutex_lock(&cpufreq_stats_lock); stat->last_index = new_index; #ifdef CONFIG_CPU_FREQ_STAT_DETAILS stat->trans_table[old_index * stat->max_state + new_index]++; #endif stat->total_trans++; - spin_unlock(&cpufreq_stats_lock); + mutex_unlock(&cpufreq_stats_lock); cpufreq_cpu_put(policy); return 0; } @@ -322,7 +323,6 @@ static int __init cpufreq_stats_init(void) int ret; unsigned int cpu; - spin_lock_init(&cpufreq_stats_lock); ret = cpufreq_register_notifier(¬ifier_policy_block, CPUFREQ_POLICY_NOTIFIER); if (ret)