From patchwork Thu Dec 27 14:55:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 1913191 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 6508E400EC for ; Thu, 27 Dec 2012 14:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752993Ab2L0O4g (ORCPT ); Thu, 27 Dec 2012 09:56:36 -0500 Received: from mail-wi0-f175.google.com ([209.85.212.175]:61461 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041Ab2L0O4b (ORCPT ); Thu, 27 Dec 2012 09:56:31 -0500 Received: by mail-wi0-f175.google.com with SMTP id hm11so7743138wib.8 for ; Thu, 27 Dec 2012 06:56:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=yy6SaBhz5ZCObAe1Rl/7Kg22U1g1VUOnbW4XGEMqdfc=; b=DQlqZ8eouyAKrxMMRCdNAHG5Io1j1QySAK7J1nDnmHQJiAicHU8fTAxjD527+b0Xca aySmKDUjUofxnSmYH+oVcHK6ZKgrcDcS6J2ehIVAU8VgjgpK7k9GwGlZLgIBEqiJS+hy 31KVdZTmvQ8tTgozRCVL45/BWljwb/JzDU5drfRLw3jqj4TTF+dz0qViEGE0rNscEIYz 3fwetLTqAkSD4ZVIct2YmVYtmHSGyN0V+grgVfiljJZJpENcM5R6xEzozPSOeBQAkzRn QFVyPDgJS4mxrLrv48MQ6npiFQvrNtKeTwR0dPZUi13BgDQrTORGk0DyUqIrwUpNv/mO IHYg== X-Received: by 10.180.77.35 with SMTP id p3mr34673350wiw.18.1356620190638; Thu, 27 Dec 2012 06:56:30 -0800 (PST) Received: from localhost ([2a01:2029:1:11e3:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id u6sm49593061wif.2.2012.12.27.06.56.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Dec 2012 06:56:29 -0800 (PST) From: Fabio Baltieri To: "Rafael J. Wysocki" , cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH 4/5] cpufreq: conservative: call dbs_check_cpu only when necessary Date: Thu, 27 Dec 2012 15:55:41 +0100 Message-Id: <1356620142-8680-5-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1356620142-8680-1-git-send-email-fabio.baltieri@linaro.org> References: <1356620142-8680-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQkUUANnH5evLqhKOPY0iuGXLCvFM3Gl1mAu8WsnPy9+dsLz3tAYQSNO9gqTvcz/5ysHICEs 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) {