From patchwork Mon Nov 26 16:39:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 1803061 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 365AF3FC54 for ; Mon, 26 Nov 2012 16:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755540Ab2KZQlK (ORCPT ); Mon, 26 Nov 2012 11:41:10 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:54311 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755526Ab2KZQlG (ORCPT ); Mon, 26 Nov 2012 11:41:06 -0500 Received: by mail-ee0-f46.google.com with SMTP id e53so4587622eek.19 for ; Mon, 26 Nov 2012 08:41:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=yy6SaBhz5ZCObAe1Rl/7Kg22U1g1VUOnbW4XGEMqdfc=; b=fsywh85Z/Kb8Kw/cTNvTSS3UGDppapsGf+qM/GOPs6PfC3oOLO4h7ILGB/oyrQumu5 2kaTQwge6ht6d3ObX+/fRk1k1BLgcUIQ7lk1VG34nIpHxOCkBmheq/QkXkNzcSsfI886 mEveSTn0bnh/INikWX/dg0t188mquAG1qdPWkkq1XXYMK3c+va2ZHn+esk9hNbA5NFpG kXKxfoAUapGYZiApAVPH/jVspTdHigKMz2IhiwkViJq1Lj7XXkj131l4wswsSRdbnz62 geEHrHYYBmp7gnYRvFChH2bPjqsB4UxwEl+XsGtgjgCo4oK8Ts3lp59qIsVAPdLaZYC0 To2A== Received: by 10.14.173.65 with SMTP id u41mr1599993eel.13.1353948066179; Mon, 26 Nov 2012 08:41:06 -0800 (PST) Received: from localhost ([2a01:2029:1:1304:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id o49sm35065017eep.5.2012.11.26.08.41.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 08:41:05 -0800 (PST) From: Fabio Baltieri To: "Rafael J. Wysocki" , cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Cc: Rickard Andersson , Vincent Guittot , Linus Walleij , Lee Jones , linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH 4/5] cpufreq: conservative: call dbs_check_cpu only when necessary Date: Mon, 26 Nov 2012 17:39:55 +0100 Message-Id: <1353947996-26723-5-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1353947996-26723-1-git-send-email-fabio.baltieri@linaro.org> References: <1353947996-26723-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQmngnO98SUdjQbmUnu+B/JdV7NOurUSGzkmLEwWhwQIxOaa3AkXV/JH7FWxGNrPEKeyaLtm Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Modify conservative timer to not resample CPU utilization if recently sampled from another SW coordinated core. Signed-off-by: Fabio Baltieri --- drivers/cpufreq/cpufreq_conservative.c | 47 +++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index b9d7f14..5d8e894 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -111,22 +111,57 @@ static void cs_check_cpu(int cpu, unsigned int load) } } -static void cs_dbs_timer(struct work_struct *work) +static void cs_timer_update(struct cs_cpu_dbs_info_s *dbs_info, bool sample, + struct delayed_work *dw) { - struct cs_cpu_dbs_info_s *dbs_info = container_of(work, - struct cs_cpu_dbs_info_s, cdbs.work.work); unsigned int cpu = dbs_info->cdbs.cpu; int delay = delay_for_sampling_rate(cs_tuners.sampling_rate); + if (sample) + dbs_check_cpu(&cs_dbs_data, cpu); + + schedule_delayed_work_on(smp_processor_id(), dw, delay); +} + +static void cs_timer_coordinated(struct cs_cpu_dbs_info_s *dbs_info_local, + struct delayed_work *dw) +{ + struct cs_cpu_dbs_info_s *dbs_info; + ktime_t time_now; + s64 delta_us; + bool sample = true; + + /* use leader CPU's dbs_info */ + dbs_info = &per_cpu(cs_cpu_dbs_info, dbs_info_local->cdbs.cpu); mutex_lock(&dbs_info->cdbs.timer_mutex); - dbs_check_cpu(&cs_dbs_data, cpu); + time_now = ktime_get(); + delta_us = ktime_us_delta(time_now, dbs_info->cdbs.time_stamp); - schedule_delayed_work_on(smp_processor_id(), &dbs_info->cdbs.work, - delay); + /* Do nothing if we recently have sampled */ + if (delta_us < (s64)(cs_tuners.sampling_rate / 2)) + sample = false; + else + dbs_info->cdbs.time_stamp = time_now; + + cs_timer_update(dbs_info, sample, dw); mutex_unlock(&dbs_info->cdbs.timer_mutex); } +static void cs_dbs_timer(struct work_struct *work) +{ + struct delayed_work *dw = to_delayed_work(work); + struct cs_cpu_dbs_info_s *dbs_info = container_of(work, + struct cs_cpu_dbs_info_s, cdbs.work.work); + + if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) { + cs_timer_coordinated(dbs_info, dw); + } else { + mutex_lock(&dbs_info->cdbs.timer_mutex); + cs_timer_update(dbs_info, true, dw); + mutex_unlock(&dbs_info->cdbs.timer_mutex); + } +} static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, void *data) {