From patchwork Mon Feb 24 06:29:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuukka Tikkanen X-Patchwork-Id: 25171 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E094E2066C for ; Mon, 24 Feb 2014 07:45:41 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id p10sf4839132pdj.3 for ; Sun, 23 Feb 2014 23:45:40 -0800 (PST) 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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ZjeUdbTVSlSGWulmCgPTrTHnmTjthPayART7G+3HIiw=; b=DOuuuLB4FH/GWoShMhG3LcxKOC8rgdcEyiF/4UPiCZOSECDVzXY6lku3CxLL9GIl3m 0Ctk1hJ7kJpIuNvkzdoJHvIbmXPp3jdYhMe0cbYXaSBndKo5aAllJytZhQ3zAO8hWtB+ NKt5oElk63MITbxvTA5t/Dmoq/2UIWX0ulspfZGG/c6Us74TKELGHaUk/QKbxUA6nMYo 0bnrX/heX4gsj7E4+NLYW4MhvlszWsXuahDMxxJmi4LTcTWRFOJmcbXBVjigoM7+PxLZ JBbm0q5+rVvD7tjgZd/OT1msxeX23P5cyu54cEOM09YgsGCxmwxoVKlJ+HfyezucS0oM wfYw== X-Gm-Message-State: ALoCoQnHIA3uyfb/Xl2FofaFH+GpmIpIDac9c2QZ30fKLrBLo9Vt7ABm3VWoWzHiFG/Itd92c5lR X-Received: by 10.66.189.163 with SMTP id gj3mr9953921pac.32.1393227940824; Sun, 23 Feb 2014 23:45:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.212 with SMTP id 78ls251292qgt.30.gmail; Sun, 23 Feb 2014 23:45:40 -0800 (PST) X-Received: by 10.52.166.9 with SMTP id zc9mr9770331vdb.16.1393227940683; Sun, 23 Feb 2014 23:45:40 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id uw4si5620377vdc.66.2014.02.23.23.45.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 23 Feb 2014 23:45:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so5339545vcb.6 for ; Sun, 23 Feb 2014 23:45:40 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr9804376vdf.24.1393227940594; Sun, 23 Feb 2014 23:45:40 -0800 (PST) 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.220.174.196 with SMTP id u4csp43359vcz; Sun, 23 Feb 2014 23:45:40 -0800 (PST) X-Received: by 10.66.8.131 with SMTP id r3mr23117658paa.7.1393227939668; Sun, 23 Feb 2014 23:45:39 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si15994975pav.304.2014.02.23.23.45.39; Sun, 23 Feb 2014 23:45:39 -0800 (PST) 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 S1751948AbaBXHnz (ORCPT + 11 others); Mon, 24 Feb 2014 02:43:55 -0500 Received: from mx.mmd.net ([80.83.0.3]:55322 "EHLO mx.mmd.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbaBXHny (ORCPT ); Mon, 24 Feb 2014 02:43:54 -0500 X-Greylist: delayed 1050 seconds by postgrey-1.27 at vger.kernel.org; Mon, 24 Feb 2014 02:43:53 EST Received: from istutuskone.tic0.net (verkonrikkoja.tic0.net [80.83.5.104]) by mx.mmd.net (Postfix) with ESMTP id 0314FF70; Mon, 24 Feb 2014 09:26:31 +0200 (EET) From: Tuukka Tikkanen To: linux-pm@vger.kernel.org, rjw@rjwysocki.net Cc: daniel.lezcano@linaro.org, tuukka.tikkanen@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] Cpuidle: Do not substract exit latency from assumed sleep length Date: Mon, 24 Feb 2014 08:29:34 +0200 Message-Id: <1393223377-5744-5-git-send-email-tuukka.tikkanen@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393223377-5744-1-git-send-email-tuukka.tikkanen@linaro.org> References: <1393223377-5744-1-git-send-email-tuukka.tikkanen@linaro.org> 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: tuukka.tikkanen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , The menu governor statistics update function tries to determine the amount of time between entry to low power state and the occurrence of the wakeup event. However, the time measured by the framework includes exit latency on top of the desired value. This exit latency is substracted from the measured value to obtain the desired value. When measured value is not available, the menu governor assumes the wakeup was caused by the timer and the time is equal to remaining timer length. No exit latency should be substracted from this value. This patch prevents the erroneous substraction and clarifies the associated comment. It also removes one intermediate variable that serves no purpose. Signed-off-by: Tuukka Tikkanen --- drivers/cpuidle/governors/menu.c | 44 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index f0995dd..b347c10 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -387,32 +387,40 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) { struct menu_device *data = &__get_cpu_var(menu_devices); int last_idx = data->last_state_idx; - unsigned int last_idle_us = cpuidle_get_last_residency(dev); struct cpuidle_state *target = &drv->states[last_idx]; unsigned int measured_us; unsigned int new_factor; /* - * Ugh, this idle state doesn't support residency measurements, so we - * are basically lost in the dark. As a compromise, assume we slept - * for the whole expected time. + * Try to figure out how much time passed between entry to low + * power state and occurrence of the wakeup event. + * + * If the entered idle state didn't support residency measurements, + * we are basically lost in the dark how much time passed. + * As a compromise, assume we slept for the whole expected time. + * + * Any measured amount of time will include the exit latency. + * Since we are interested in when the wakeup begun, not when it + * was completed, we must substract the exit latency. However, if + * the measured amount of time is less than the exit latency, + * assume the state was never reached and the exit latency is 0. */ - if (unlikely(!(target->flags & CPUIDLE_FLAG_TIME_VALID))) - last_idle_us = data->next_timer_us; - + if (unlikely(!(target->flags & CPUIDLE_FLAG_TIME_VALID))) { + /* Use timer value as is */ + measured_us = data->next_timer_us; - measured_us = last_idle_us; + } else { + /* Use measured value */ + measured_us = cpuidle_get_last_residency(dev); - /* - * We correct for the exit latency; we are assuming here that the - * exit latency happens after the event that we're interested in. - */ - if (measured_us > target->exit_latency) - measured_us -= target->exit_latency; + /* Deduct exit latency */ + if (measured_us > target->exit_latency) + measured_us -= target->exit_latency; - /* Make sure our coefficients do not exceed unity */ - if (measured_us > data->next_timer_us) - measured_us = data->next_timer_us; + /* Make sure our coefficients do not exceed unity */ + if (measured_us > data->next_timer_us) + measured_us = data->next_timer_us; + } /* Update our correction ratio */ new_factor = data->correction_factor[data->bucket]; @@ -439,7 +447,7 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) data->correction_factor[data->bucket] = new_factor; /* update the repeating-pattern data */ - data->intervals[data->interval_ptr++] = last_idle_us; + data->intervals[data->interval_ptr++] = measured_us; if (data->interval_ptr >= INTERVALS) data->interval_ptr = 0; }