From patchwork Mon Jul 27 12:28:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51517 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 72BCA22918 for ; Mon, 27 Jul 2015 12:29:23 +0000 (UTC) Received: by wixh2 with SMTP id h2sf27705394wix.0 for ; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) 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=jmMtNaBwv36DQN9bDpIYVHmM9NRUz/9NEozBSrWE2Oc=; b=C/j2JYRCvnXzqt0yAQJQ1cuxGutTbRgn32DyETLa2WhLeraeF43NKA0VV4KCUt+RSA j3R61Zs41sdxzwMXCKqqrVyOz9s7HUzELyqM/wQDIByCx1bx6FnW75O/CQQLRCZtjssL g0TnOGfWC+VR1g5KeWLuGM0K6yCg2A52dETGY6idVVwTJg1Mhs10sJGOZ5RpddrohVCn uyC/2KkJSjmclS4XE1C62TvZtngQbkQnJ0tmM4QchvZc9/Uu+WAKQtLh/pw7LWPlP/O8 djMxGuOsHAgi7Q4UpHnFYJ8tT6nkRsM9EiJwTcQCyFyAGkWYoGdt+lU5f20PULHV73hL NxlQ== X-Gm-Message-State: ALoCoQkWABV0DEw5tB2JCKQkPm8U3LriazSVflWIakQ78dGvW2f9CzloKrnHSHRg3AQogvOZVOJO X-Received: by 10.180.11.226 with SMTP id t2mr5238264wib.0.1438000162738; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.36 with SMTP id p4ls650881lah.63.gmail; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) X-Received: by 10.112.46.130 with SMTP id v2mr26404715lbm.119.1438000162469; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id rv3si15104829lbb.151.2015.07.27.05.29.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2015 05:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lagw2 with SMTP id w2so47900777lag.3 for ; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr26562764lak.117.1438000162374; Mon, 27 Jul 2015 05:29:22 -0700 (PDT) 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.7.198 with SMTP id l6csp1502158lba; Mon, 27 Jul 2015 05:29:21 -0700 (PDT) X-Received: by 10.50.39.17 with SMTP id l17mr16062798igk.75.1438000160003; Mon, 27 Jul 2015 05:29:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rf7si28141008pdb.85.2015.07.27.05.29.19; Mon, 27 Jul 2015 05:29:19 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753531AbbG0M3B (ORCPT + 28 others); Mon, 27 Jul 2015 08:29:01 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35108 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbbG0M25 (ORCPT ); Mon, 27 Jul 2015 08:28:57 -0400 Received: by pabkd10 with SMTP id kd10so51130173pab.2 for ; Mon, 27 Jul 2015 05:28:56 -0700 (PDT) X-Received: by 10.66.158.3 with SMTP id wq3mr67639839pab.38.1438000136601; Mon, 27 Jul 2015 05:28:56 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id o8sm29296271pdp.70.2015.07.27.05.28.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 27 Jul 2015 05:28:55 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, preeti.lkml@gmail.com, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 6/9] cpufreq: ondemand: queue work for policy->cpus together Date: Mon, 27 Jul 2015 17:58:11 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.215.53 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: , Currently update_sampling_rate() runs over each online CPU and cancels/queues work on it. Its very inefficient for the case where a single policy manages multiple CPUs, as they can be processed together. Also drop the unnecessary cancel_delayed_work_sync() as we are doing a mod_delayed_work_on() in gov_queue_work(), which will take care of pending works for us. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_ondemand.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index f1551fc7b4fd..a6f579e40ce2 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -247,40 +247,45 @@ static void update_sampling_rate(struct dbs_data *dbs_data, unsigned int new_rate) { struct od_dbs_tuners *od_tuners = dbs_data->tuners; + struct cpufreq_policy *policy; + struct od_cpu_dbs_info_s *dbs_info; + unsigned long next_sampling, appointed_at; + struct cpumask cpumask; int cpu; + cpumask_copy(&cpumask, cpu_online_mask); + od_tuners->sampling_rate = new_rate = max(new_rate, dbs_data->min_sampling_rate); - for_each_online_cpu(cpu) { - struct cpufreq_policy *policy; - struct od_cpu_dbs_info_s *dbs_info; - unsigned long next_sampling, appointed_at; - + for_each_cpu(cpu, &cpumask) { policy = cpufreq_cpu_get(cpu); if (!policy) continue; + + /* clear all CPUs of this policy */ + cpumask_andnot(&cpumask, &cpumask, policy->cpus); + if (policy->governor != &cpufreq_gov_ondemand) { cpufreq_cpu_put(policy); continue; } + dbs_info = &per_cpu(od_cpu_dbs_info, cpu); cpufreq_cpu_put(policy); - if (!delayed_work_pending(&dbs_info->cdbs.dwork)) + /* Make sure the work is not canceled on policy->cpus */ + if (!dbs_info->cdbs.shared->policy) continue; next_sampling = jiffies + usecs_to_jiffies(new_rate); appointed_at = dbs_info->cdbs.dwork.timer.expires; - if (time_before(next_sampling, appointed_at)) { - cancel_delayed_work_sync(&dbs_info->cdbs.dwork); - - gov_queue_work(dbs_data, policy, - usecs_to_jiffies(new_rate), - cpumask_of(cpu)); + if (!time_before(next_sampling, appointed_at)) + continue; - } + gov_queue_work(dbs_data, policy, usecs_to_jiffies(new_rate), + policy->cpus); } }