From patchwork Mon Feb 24 06:29:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuukka Tikkanen X-Patchwork-Id: 25176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D50D52066C for ; Mon, 24 Feb 2014 08:13:37 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id to1sf21046933ieb.11 for ; Mon, 24 Feb 2014 00:13:37 -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=CAXq3ue1ORAEnjrwcAigsKcYD4CpsMupt78ygdzwV/0=; b=KcXNnzk8liSageDD+F84GjOsgFRWnxwcYcs500cWMTSQ13rBakHfr8qosPYVdwyFuo EvsHRLyuiHfjmL2Q7Er6McfrrmdsVza8LOrcwF18GD4kPW69DQaJJs0PviQDDRy2Z8et 2WGRR/oiyDzNnt2MyS1jOeV9bb5SXtcvgMi/PLl7jaHZz2OR2+Mj4yVN9cUDmTH6DOXp qrWDhHaqkaTUsgqD5aF3W3fU4kXuCkV47A/QdE2vej0QM5i8ScWjPxnq0gzEfgXHx9KJ Zur/Y/s9c61ZyqIpj5kL0hhthDla4pn0szY2z1xhgwPB4X8+sDdecL/tLkf1LsUCYglE r99Q== X-Gm-Message-State: ALoCoQkicx9xuTF8DH18PJw4GJSMT6mohtD9cUJOg7ZRKhKyN8k3dQIdFa9+KMGQpnNA/fS4Zymx X-Received: by 10.182.216.200 with SMTP id os8mr8530490obc.0.1393229617053; Mon, 24 Feb 2014 00:13:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.116 with SMTP id g107ls1779484qgg.49.gmail; Mon, 24 Feb 2014 00:13:36 -0800 (PST) X-Received: by 10.220.98.204 with SMTP id r12mr11768219vcn.48.1393229616902; Mon, 24 Feb 2014 00:13:36 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id uw4si5632656vdc.79.2014.02.24.00.13.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 00:13:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 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.170; Received: by mail-vc0-f170.google.com with SMTP id hu8so5545692vcb.1 for ; Mon, 24 Feb 2014 00:13:36 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr11687198vco.18.1393229616838; Mon, 24 Feb 2014 00:13:36 -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 u4csp44726vcz; Mon, 24 Feb 2014 00:13:36 -0800 (PST) X-Received: by 10.68.197.8 with SMTP id iq8mr23574340pbc.124.1393229616076; Mon, 24 Feb 2014 00:13:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si15926230pbk.1.2014.02.24.00.13.35; Mon, 24 Feb 2014 00:13:35 -0800 (PST) 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 S1753411AbaBXINK (ORCPT + 26 others); Mon, 24 Feb 2014 03:13:10 -0500 Received: from mx.mmd.net ([80.83.0.3]:55413 "EHLO mx.mmd.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbaBXIND (ORCPT ); Mon, 24 Feb 2014 03:13:03 -0500 Received: from istutuskone.tic0.net (verkonrikkoja.tic0.net [80.83.5.104]) by mx.mmd.net (Postfix) with ESMTP id D417FEE6; Mon, 24 Feb 2014 09:26:29 +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 3/7] Cpuidle: Ensure menu coefficients stay within domain Date: Mon, 24 Feb 2014 08:29:33 +0200 Message-Id: <1393223377-5744-4-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-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: tuukka.tikkanen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 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 uses coefficients as one method of actual idle period length estimation. The coefficients are, as detailed below, multipliers giving expected idle period length from time until next timer expiry. The multipliers are supposed to have domain of (0..1]. The coefficients are fractions where only the numerators are stored and denominators are a shared constant RESOLUTION*DECAY. Since the value of the coefficient should always be greater than 0 and less than or equal to 1, the numerator must have a value greater than 0 and less than or equal to RESOLUTION*DECAY. If the coefficients are updated with measured idle durations exceeding timer length, the multiplier may reach values exceeding unity (i.e. the stored numerator exceeds RESOLUTION*DECAY). This patch ensures that the multipliers are updated with durations capped to timer length. Signed-off-by: Tuukka Tikkanen Acked-by: Nicolas Pitre --- drivers/cpuidle/governors/menu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 115386a..f0995dd 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -410,6 +410,9 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) 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; /* Update our correction ratio */ new_factor = data->correction_factor[data->bucket];