From patchwork Mon Mar 4 07:47:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2211031 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 CBFE440077 for ; Mon, 4 Mar 2013 07:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752773Ab3CDHro (ORCPT ); Mon, 4 Mar 2013 02:47:44 -0500 Received: from mail-da0-f43.google.com ([209.85.210.43]:52890 "EHLO mail-da0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754886Ab3CDHrm (ORCPT ); Mon, 4 Mar 2013 02:47:42 -0500 Received: by mail-da0-f43.google.com with SMTP id u36so2418416dak.2 for ; Sun, 03 Mar 2013 23:47:42 -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:in-reply-to:references:x-gm-message-state; bh=dFYvjbWK0hdtsB8JM4FaNebXAxgVrDPJOVJ1yJgltDI=; b=GXry4MvS0jWPVIVsY6KZ/xxec7gBhcyHr9zKCKZOg4p/PX3odGlv36bPLcfp4gX6Eu kPr76Tzl1k1SaR51+ivu89S/1c4k7HZc5GN08L6/vwjaSxM/QbgieQf2PS2ABzWhiV8i rnceT0Tpbyu5tfLgiHh+zCqRs5MmSElUKI5j/deHyxcK5knPs7PV/7W3lFGyIOdvbGSN wcn754vooq7Y1UCLiZeheahWz4exdbB/sUXKwebulTx2yJvlKQAXH73IGXo4N5vjzhqa LGo7pTqiE/wfnJIA+lnTuilQo0a46YI/elkoXNOtHZYQmpbg78I+Yp+Mbme/vCyXP8j+ Z/Nw== X-Received: by 10.68.227.129 with SMTP id sa1mr26755319pbc.107.1362383262010; Sun, 03 Mar 2013 23:47:42 -0800 (PST) Received: from localhost ([118.143.64.134]) by mx.google.com with ESMTPS id kl4sm21433864pbc.31.2013.03.03.23.47.37 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 03 Mar 2013 23:47:41 -0800 (PST) From: Viresh Kumar To: rjw@sisk.pl Cc: cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, rickard.andersson@stericsson.com, fabio.baltieri@linaro.org, tj@kernel.org, Viresh Kumar Subject: [PATCH V2 1/2] cpufreq: ondemand: Don't update sample_type if we don't evaluate load again Date: Mon, 4 Mar 2013 15:47:23 +0800 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlK5ENpGWID7KNJmS54lByXDkoEvlz/0BlYEGQkI38+VEShoggW9VcURJPbkDMKZWwN5zg1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Because we have per cpu timer now, we check if we need to evaluate load again or not (In case it is recently evaluated). Here the 2nd cpu which got timer interrupt updates core_dbs_info->sample_type irrespective of load evaluation is required or not. Which is wrong as the first cpu is dependent on this variable set to an older value. Moreover it would be best in this case to schedule 2nd cpu's timer to sampling_rate instead of freq_lo or hi as that must be managed by the other cpu. In case the other cpu idles in between then also we wouldn't loose much power. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_ondemand.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index c5fd794..e76f4f8 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -224,34 +224,32 @@ static void od_dbs_timer(struct work_struct *work) cpu); struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data; struct od_dbs_tuners *od_tuners = dbs_data->tuners; - int delay, sample_type = core_dbs_info->sample_type; - bool eval_load; + int delay = 0, sample_type = core_dbs_info->sample_type; mutex_lock(&core_dbs_info->cdbs.timer_mutex); - eval_load = need_load_eval(&core_dbs_info->cdbs, - od_tuners->sampling_rate); + if (!need_load_eval(&core_dbs_info->cdbs, od_tuners->sampling_rate)) + goto max_delay; /* Common NORMAL_SAMPLE setup */ core_dbs_info->sample_type = OD_NORMAL_SAMPLE; if (sample_type == OD_SUB_SAMPLE) { delay = core_dbs_info->freq_lo_jiffies; - if (eval_load) - __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy, - core_dbs_info->freq_lo, - CPUFREQ_RELATION_H); + __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy, + core_dbs_info->freq_lo, CPUFREQ_RELATION_H); } else { - if (eval_load) - dbs_check_cpu(dbs_data, cpu); + dbs_check_cpu(dbs_data, cpu); if (core_dbs_info->freq_lo) { /* Setup timer for SUB_SAMPLE */ core_dbs_info->sample_type = OD_SUB_SAMPLE; delay = core_dbs_info->freq_hi_jiffies; - } else { - delay = delay_for_sampling_rate(od_tuners->sampling_rate - * core_dbs_info->rate_mult); } } +max_delay: + if (!delay) + delay = delay_for_sampling_rate(od_tuners->sampling_rate + * core_dbs_info->rate_mult); + schedule_delayed_work_on(smp_processor_id(), dw, delay); mutex_unlock(&core_dbs_info->cdbs.timer_mutex); }