From patchwork Tue Jan 6 15:39:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 42786 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1B68F2055F for ; Tue, 6 Jan 2015 15:40:39 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf2548111wid.3 for ; Tue, 06 Jan 2015 07:40:38 -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=kzNjPOZF8UY06Kv0mOX02t8lsimog+0swuM3fNhOENs=; b=EfeoY5wuqJXVD+mfPO8F1XmsXcEGeVBRkPiJfgoSTOaw+n1r2IJAQAK/PbPeQbp8aO nnwHtyWzBGn69AMNbZUeR93WKifZP5FB7xhDp8Te1SllDTTjDUgOshAEpY0iDBMTeCcJ mGBsOEWvIJGk7ACYmmYEPX+OX2fCYKqrfkdWuNbZQ3ikpBSSB9em0vhbiKqRhuehlLAu lhs/01yrUSfF+TxT+1qBP6lLCVv/Ae/HTLXEjr+LyYg3HHOh9Z7UZWB43wqPX+3qpkhH 7IUjcwUMBaqrk8fj2M3OkEnSrjpgVVDjXTmpqfrjW5y14z4DMVRRijcXAQlSDQrZdO3r cHWg== X-Gm-Message-State: ALoCoQk0jSV3n159WIyPbHWxibsy38+SHmP7KMxybqzlRiuudt7lZWi+UHyukZ1lYvSQtOVLGfBh X-Received: by 10.112.9.199 with SMTP id c7mr1518575lbb.7.1420558838376; Tue, 06 Jan 2015 07:40:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.40 with SMTP id h8ls52628lah.12.gmail; Tue, 06 Jan 2015 07:40:38 -0800 (PST) X-Received: by 10.112.119.201 with SMTP id kw9mr99527761lbb.99.1420558838149; Tue, 06 Jan 2015 07:40:38 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id tv7si66351418lbb.83.2015.01.06.07.40.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Jan 2015 07:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id p9so19726280lbv.0 for ; Tue, 06 Jan 2015 07:40:38 -0800 (PST) X-Received: by 10.112.159.136 with SMTP id xc8mr29895988lbb.98.1420558838020; Tue, 06 Jan 2015 07:40:38 -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 c8csp1209736lbb; Tue, 6 Jan 2015 07:40:37 -0800 (PST) X-Received: by 10.66.221.197 with SMTP id qg5mr35963035pac.150.1420558832387; Tue, 06 Jan 2015 07:40:32 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si89605937pdl.210.2015.01.06.07.40.31; Tue, 06 Jan 2015 07:40:32 -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 S1755513AbbAFPka (ORCPT + 12 others); Tue, 6 Jan 2015 10:40:30 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:55360 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755479AbbAFPk3 (ORCPT ); Tue, 6 Jan 2015 10:40:29 -0500 Received: by mail-pa0-f43.google.com with SMTP id kx10so31244814pab.2 for ; Tue, 06 Jan 2015 07:40:29 -0800 (PST) X-Received: by 10.70.37.202 with SMTP id a10mr156039266pdk.107.1420558829196; Tue, 06 Jan 2015 07:40:29 -0800 (PST) Received: from localhost ([122.167.212.196]) by mx.google.com with ESMTPSA id ju5sm20753365pab.42.2015.01.06.07.40.28 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 06 Jan 2015 07:40:28 -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 V3 16/16] cpufreq: stats: drop unnecessary locking Date: Tue, 6 Jan 2015 21:09:15 +0530 Message-Id: <2de6e2482211a493d61f4a77e38f60686fc5fc84.1420558386.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.169 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: , There is no possibility of any race on updating last_index, trans_table or total_trans as these are updated only by cpufreq_stat_notifier_trans() which will be called sequentially. The only place where locking is still relevant is: cpufreq_stats_update(), which updates time_in_state and last_time. This can be called by two thread in parallel, that may result in races. The two threads being: - sysfs read of time_in_state - and frequency transition that calls cpufreq_stat_notifier_trans(). Remove locking from the first case mentioned above. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 71fcc7c198a1..bce255568123 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -207,12 +207,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) cpufreq_for_each_valid_entry(pos, table) if (freq_table_get_index(stats, pos->frequency) == -1) stats->freq_table[i++] = pos->frequency; - stats->state_num = i; - spin_lock(&cpufreq_stats_lock); + stats->state_num = i; stats->last_time = get_jiffies_64(); stats->last_index = freq_table_get_index(stats, policy->cur); - spin_unlock(&cpufreq_stats_lock); policy->stats = stats; ret = sysfs_create_group(&policy->kobj, &stats_attr_group); @@ -294,13 +292,11 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, cpufreq_stats_update(stats); - spin_lock(&cpufreq_stats_lock); stats->last_index = new_index; #ifdef CONFIG_CPU_FREQ_STAT_DETAILS stats->trans_table[old_index * stats->max_state + new_index]++; #endif stats->total_trans++; - spin_unlock(&cpufreq_stats_lock); put_policy: cpufreq_cpu_put(policy);