From patchwork Tue Oct 13 08:09:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 54826 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 6137523001 for ; Tue, 13 Oct 2015 08:09:51 +0000 (UTC) Received: by lbbpc3 with SMTP id pc3sf5028332lbb.2 for ; Tue, 13 Oct 2015 01:09:50 -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=4Y/2vrE0wgP6CGj5Pq8Ngs/hG0Roaw3VH5KJ8c9mV2s=; b=RN1OneGEzh9hTJ4lYMtaCrLxleNxjfyW2sfxIbd39zenbmHatJAi6qT5STvFpbojAX rdW5/qd22h213pFw4nXHbSWZtGLW5WupiniUHgmuT+pYVtupDk1N/3MIL1ep/KkFVv2o eAP3A2BhtbR+ZzJU+HBbm9WvTPNP8M5gzHuAnQyaKhqD+ZtJ2wRpBdHjQ1KZHoYjrc6M qHbIx1k+t8SM8W3kAJX3y40uSCI0k85cHoU2CXGBN7teDKTBZqUaXc8qiNOX0li+K/fq O5wMtqmtHlbhIFYAPLWZPqQ11bx1KThhaEkkorQbSQHZKxTvb8YQCoBqRae7IFmMR10i AtTg== X-Gm-Message-State: ALoCoQm9iL19WMHBYsZNMcDzYAyaKyPTw5Kp+NyiJ3NEAzhE2K1NCitHcEqXRE932NG5D7+HTKk9 X-Received: by 10.194.94.66 with SMTP id da2mr2357989wjb.7.1444723790285; Tue, 13 Oct 2015 01:09:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.87.8 with SMTP id l8ls674210lfb.92.gmail; Tue, 13 Oct 2015 01:09:50 -0700 (PDT) X-Received: by 10.25.41.72 with SMTP id p69mr9321191lfp.111.1444723790105; Tue, 13 Oct 2015 01:09:50 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id c15si1385330lfe.37.2015.10.13.01.09.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Oct 2015 01:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbk10 with SMTP id k10so10397109lbb.0 for ; Tue, 13 Oct 2015 01:09:50 -0700 (PDT) X-Received: by 10.25.28.81 with SMTP id c78mr5435019lfc.29.1444723789938; Tue, 13 Oct 2015 01:09:49 -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.59.35 with SMTP id w3csp1974459lbq; Tue, 13 Oct 2015 01:09:48 -0700 (PDT) X-Received: by 10.50.79.230 with SMTP id m6mr18047578igx.9.1444723788758; Tue, 13 Oct 2015 01:09:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si1860265igp.64.2015.10.13.01.09.48; Tue, 13 Oct 2015 01:09:48 -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 S1752862AbbJMIJj (ORCPT + 30 others); Tue, 13 Oct 2015 04:09:39 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:35014 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752804AbbJMIJg (ORCPT ); Tue, 13 Oct 2015 04:09:36 -0400 Received: by pabve7 with SMTP id ve7so14407210pab.2 for ; Tue, 13 Oct 2015 01:09:35 -0700 (PDT) X-Received: by 10.68.223.34 with SMTP id qr2mr39349294pbc.97.1444723775568; Tue, 13 Oct 2015 01:09:35 -0700 (PDT) Received: from localhost ([223.227.239.124]) by smtp.gmail.com with ESMTPSA id qv5sm2225182pbc.71.2015.10.13.01.09.33 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 13 Oct 2015 01:09:34 -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 V3 3/5] cpufreq: ondemand: queue work for policy->cpus together Date: Tue, 13 Oct 2015 13:39:03 +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.217.179 as permitted sender) smtp.mailfrom=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 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index bf0511a9735c..4677c7e9d534 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -238,29 +238,36 @@ 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; + 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; - + 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; - cancel_delayed_work_sync(&dbs_info->cdbs.dwork); gov_queue_work(dbs_data, policy, usecs_to_jiffies(new_rate), true); }