From patchwork Thu Dec 3 04:07:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 57595 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3272522lbb; Wed, 2 Dec 2015 20:09:33 -0800 (PST) X-Received: by 10.98.69.7 with SMTP id s7mr9931161pfa.28.1449115773317; Wed, 02 Dec 2015 20:09:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si9098459pfq.226.2015.12.02.20.09.33; Wed, 02 Dec 2015 20:09:33 -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=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 S1758544AbbLCEJM (ORCPT + 28 others); Wed, 2 Dec 2015 23:09:12 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33736 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758349AbbLCEIW (ORCPT ); Wed, 2 Dec 2015 23:08:22 -0500 Received: by pabfh17 with SMTP id fh17so61129951pab.0 for ; Wed, 02 Dec 2015 20:08:22 -0800 (PST) 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=cZfqREOlTUOaB6ay8ZTLKMMuccnbG/OFWuLH+9rqkBw=; b=kG6RtkI7VcV4jqq0HBtvOWO48Bj1gyZQIjtcoYFMgAOUFVXcalCt1JP8pO8K+W5V/e YzNVVrK1kLIilwuM9NFAarCn1bsRbl3/ltSLNpwgYVEmktPfkmpLik1eVcgvO698xSMP YfXGWErGElv//ZU20if9EqV+f8VF0DJr3cGvmVwQLqaum9gPzgoLQIj3Ianop5CUv0NK Cp5kech3pKe8H917iVaeZ76XEnOOWWwJB36AtaiiwJRcTYwUHQVMiNokkVDuSh/gURAR ubRkWtHlpE9UlvWJxtXo8JMu2Ayg9wN4c2cwPGIsGEXCtbe73Pvjit4hhXJBn2qxmZ9B KT4g== 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=cZfqREOlTUOaB6ay8ZTLKMMuccnbG/OFWuLH+9rqkBw=; b=c4fCsK/NiKqjIauURJgGRmEP6n0EIVkfuoh29jwOQ8dr/Q7VcCXyMf972vv2KziQqO Bb+taK9FKLGZvi4ujVOIoGsEhYmuCM6YH12JgICvHiZ7Lt6QHrwYicUnAENHBWwOY41Q DbcI3w9obykL9RIc9dHWormOXNENU7rfVTxMlNk1F2sPvi7rwdyl1+HboY9+9yj+tnUb fOk5FeGolcWBxcRAOp8Ufr4srRT6hUyaYVIX1jLUjetCH1keg5B/N+8WI+iyMq02F9o7 gaLobsVRWM9LmUpyH8NbuG0xGh8odYm/57Yo8YLCrlUmKdrRFrqZxViykliAP7SLUilH K3yg== X-Gm-Message-State: ALoCoQnBFs0RnNQHEEshoomVW4DWpD5pcSK0VGv0wTPhA64a3VWOKJC63/EoCzuFCJrbIC8WhqjF X-Received: by 10.98.17.152 with SMTP id 24mr10101484pfr.41.1449115702235; Wed, 02 Dec 2015 20:08:22 -0800 (PST) Received: from localhost ([122.172.170.156]) by smtp.gmail.com with ESMTPSA id h10sm7264404pat.7.2015.12.02.20.08.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Dec 2015 20:08:21 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, ashwin.chaugule@linaro.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 6/6] cpufreq: ondemand: update update_sampling_rate() to make it more efficient Date: Thu, 3 Dec 2015 09:37:54 +0530 Message-Id: <5b9fffd163d07be79943615d069147e801975e0c.1449115453.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.6.2.198.g614a2ac 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 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-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index f879012cf849..eae51070c034 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -246,6 +246,7 @@ static void update_sampling_rate(struct dbs_data *dbs_data, unsigned int new_rate) { struct od_dbs_tuners *od_tuners = dbs_data->tuners; + struct cpumask cpumask; int cpu; od_tuners->sampling_rate = new_rate = max(new_rate, @@ -256,7 +257,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) { struct cpufreq_policy *policy; struct od_cpu_dbs_info_s *dbs_info; struct cpu_dbs_info *cdbs; @@ -276,6 +279,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 @@ -285,6 +291,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;