From patchwork Thu Oct 29 12:27:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 55761 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp529830lbr; Thu, 29 Oct 2015 05:28:04 -0700 (PDT) X-Received: by 10.50.29.101 with SMTP id j5mr9182956igh.70.1446121681131; Thu, 29 Oct 2015 05:28:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si2842227ioe.71.2015.10.29.05.28.00; Thu, 29 Oct 2015 05:28:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756909AbbJ2M1z (ORCPT + 11 others); Thu, 29 Oct 2015 08:27:55 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35706 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756895AbbJ2M1x (ORCPT ); Thu, 29 Oct 2015 08:27:53 -0400 Received: by pasz6 with SMTP id z6so39966537pas.2 for ; Thu, 29 Oct 2015 05:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=M5DGCVfeEwcO4CG1bPmcW6Rp0ReBFv3BWyOSBbSZysc=; b=cdgNtAnyU9OoqWy9trDUmbr+cAt70PA4NDrNHDeHmXPvAOXV4LbilSp73gRsCTJnHm x0SkUB9HExs7+4eJWidq85nqATYVxpwKJ2Uz3xH2hbrhUslsH4yuIuUe7JuKB6hfEpV/ MXzL5DT66jgZEd/wSdbo6BQLg5iAHiHHi1TKZIuGMHLi5RTKVfNv1SyXp7DatfBg6CSS RU75Q4yFh9GaHSAHva4y2EMR2D7D+BQE07lLCgc9hvGMknz/yZdMepCwdbIbf6/8VaR/ u6nVBzcLuE+qcIYuzIDMiFm++lfABMwIrSPDZFxrXW9W8m6Uawd04iracxAOZwe/Ho2/ DILg== 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=M5DGCVfeEwcO4CG1bPmcW6Rp0ReBFv3BWyOSBbSZysc=; b=ggLB1AatE3jZ04vIvqbRxdY1AF0KjEwzWcgfHpv2CFotKHyozYgDrSn8G+1HVzHP0V DKGnfcAhijJlEeJKV7DIrbFWpjw/hNulIjRQA6fJY2FOzrsS2FzbgLFc8ndNP2g3QoO2 U5YCDRCj/SUx5N4TVyDo+evbvpG7qcAm3usZzyIq2B2jEpkl7vea0f2g4/IZ56w7vKF8 CvI9aVpSYh6t7LpdUGidGi1Kr7AWxKHHxgSdWbaRgqAowiAMLvZXIut69hXYR2EPcRk6 Av9bAVqwxP0DW72fHtWSU4TeLyZzPQUMV5yG/uNXaGYwjlemcXGeDhQP2AOevk/Z8Oed m4Ig== X-Gm-Message-State: ALoCoQkbm6dlBDhruSHLkbQAEk6YPxDrCt7huLoODdT7YFr4cPLgumx5dqMcnug1DNaPBp191AEI X-Received: by 10.68.134.73 with SMTP id pi9mr1661763pbb.169.1446121672885; Thu, 29 Oct 2015 05:27:52 -0700 (PDT) Received: from localhost ([122.172.111.169]) by smtp.gmail.com with ESMTPSA id rz9sm2180614pbb.61.2015.10.29.05.27.51 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 29 Oct 2015 05:27:52 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 6/6] cpufreq: ondemand: update update_sampling_rate() to make it more efficient Date: Thu, 29 Oct 2015 17:57:25 +0530 Message-Id: X-Mailer: git-send-email 2.6.2.198.g614a2ac In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently update_sampling_rate() runs over each online CPU and cancels/queues timers on all policy->cpus every time. This should be done just once for any cpu belonging to a policy. Create a cpumask and keep on clearing it as and when we process policies, so that we don't have to traverse through all CPUs of the same policy. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_ondemand.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.6.2.198.g614a2ac -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 9e0293c23285..6eac39124894 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -251,6 +251,7 @@ static void update_sampling_rate(struct dbs_data *dbs_data, struct cpufreq_policy *policy; struct cpu_common_dbs_info *shared; unsigned long next_sampling, appointed_at; + struct cpumask cpumask; int cpu; od_tuners->sampling_rate = new_rate = max(new_rate, @@ -261,7 +262,9 @@ static void update_sampling_rate(struct dbs_data *dbs_data, */ mutex_lock(&od_dbs_cdata.mutex); - for_each_online_cpu(cpu) { + cpumask_copy(&cpumask, cpu_online_mask); + + for_each_cpu(cpu, &cpumask) { dbs_info = &per_cpu(od_cpu_dbs_info, cpu); cdbs = &dbs_info->cdbs; shared = cdbs->shared; @@ -275,6 +278,9 @@ static void update_sampling_rate(struct dbs_data *dbs_data, policy = shared->policy; + /* clear all CPUs of this policy */ + cpumask_andnot(&cpumask, &cpumask, policy->cpus); + /* * Update sampling rate for CPUs whose policy is governed by * dbs_data. In case of governor_per_policy, only a single @@ -284,6 +290,10 @@ static void update_sampling_rate(struct dbs_data *dbs_data, if (dbs_data != policy->governor_data) continue; + /* + * Checking this for any CPU should be fine, timers for all of + * them are scheduled together. + */ next_sampling = jiffies + usecs_to_jiffies(new_rate); appointed_at = dbs_info->cdbs.timer.expires;