From patchwork Mon Jun 22 08:02: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: 50139 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 62D1F218E6 for ; Mon, 22 Jun 2015 08:03:40 +0000 (UTC) Received: by wguu7 with SMTP id u7sf26849534wgu.0 for ; Mon, 22 Jun 2015 01:03:39 -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=SxZmnII7h6PCcgepW3RGW+u2pRgw14vlmXPiLnZvTW0=; b=iBBra7AJwRVLlMLfc3ciL0Jft9NH3dg5vHKKA9fFU5YIiRsvPxl3/nS1bBFIPjiCpv PA4dOO4bt1e5KZFzutS4liGgvq5RsPiACkBHFErYi63ugL7HkAFvXOG0mTnQDKvFvg3l TOUNjfGEfqtPxTYmcgUsjLoaUW8iM8rlUownl0iqUCSh6xZFPM21EFHOGrHCcUhVTIRw LaKjI5xogyV+bQmyemPC10d2TaZ/XcQXj+/q4qYeIfB07Yr9AXKZjDyfDhp1EFivRHhA MdENRuVUnHZXJzAZaltN9WiV77Csv04SxDEWH6dZUxQomgu5QYaxil5URD2MuVdGrTDu Z5Mw== X-Gm-Message-State: ALoCoQkvpe18ABgjlkk1EbFvGqSxR3tKzqsSajk3fHmEizVrlwiZE5ac+/HPtMRBkJH8gOXzY2j0 X-Received: by 10.112.26.5 with SMTP id h5mr27108683lbg.4.1434960219716; Mon, 22 Jun 2015 01:03:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.121.98 with SMTP id lj2ls825055lab.94.gmail; Mon, 22 Jun 2015 01:03:39 -0700 (PDT) X-Received: by 10.112.119.198 with SMTP id kw6mr28294618lbb.97.1434960219569; Mon, 22 Jun 2015 01:03:39 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id u9si15903748lau.48.2015.06.22.01.03.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2015 01:03:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laka10 with SMTP id a10so104778161lak.0 for ; Mon, 22 Jun 2015 01:03:39 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr28284466lac.41.1434960219467; Mon, 22 Jun 2015 01:03:39 -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.108.230 with SMTP id hn6csp2208862lbb; Mon, 22 Jun 2015 01:03:38 -0700 (PDT) X-Received: by 10.66.136.78 with SMTP id py14mr56499054pab.1.1434960217604; Mon, 22 Jun 2015 01:03:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si28457864pdl.134.2015.06.22.01.03.36; Mon, 22 Jun 2015 01:03:37 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756137AbbFVIDg (ORCPT + 11 others); Mon, 22 Jun 2015 04:03:36 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:36596 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756129AbbFVIDc (ORCPT ); Mon, 22 Jun 2015 04:03:32 -0400 Received: by pdcu2 with SMTP id u2so7354763pdc.3 for ; Mon, 22 Jun 2015 01:03:32 -0700 (PDT) X-Received: by 10.70.102.132 with SMTP id fo4mr56731910pdb.31.1434960212424; Mon, 22 Jun 2015 01:03:32 -0700 (PDT) Received: from localhost ([122.167.71.211]) by mx.google.com with ESMTPSA id do16sm18969967pac.15.2015.06.22.01.03.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 22 Jun 2015 01:03:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Preeti U Murthy Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar Subject: [PATCH 07/10] cpufreq: ondemand: queue work for policy->cpus together Date: Mon, 22 Jun 2015 13:32:54 +0530 Message-Id: <66980e2b51a83bf34f6fd18ee55155b6c667aa6a.1434959517.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.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.215.48 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 | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 841e1fa96ee7..cfecd3b67cb3 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -247,40 +247,48 @@ 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); + /* + * Checking this for any CPU of the policy is fine. As either + * all would have queued work or none. + */ if (!delayed_work_pending(&dbs_info->cdbs.dwork)) 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); } }