From patchwork Mon Oct 20 16:25:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 39057 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A41D3203C5 for ; Mon, 20 Oct 2014 16:27:03 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d49sf1542489eek.11 for ; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) 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=Ky06/1iSHDvUHOfb9rTeTAYTbTJCf0l9WqYmhysZ9H4=; b=Cx31oGJh5OcKtcc1xIyU5XYgRFWYq1bmtN76IlC/0iHqBRE8gCKgW6pAGtSoEYcUJk DWd5lKt8JZVWlqourvQydDlKkJNxHuPlyPe0ERnx4OqF8N2taMdCP5GsePlOm1S6n8VQ bzoXpzUSCIGsZdrKF4CLOzoI0wbgxPdIff6g2jfh0MBPF23GDqlLgAzOoRggbprrtaL4 q7Hsp94TH6NhMwpVQjXNLJBubotrgPzf6pdIeD0SOUrBUZmTVJ8snK8Y9qybmUVxyLdl QiH71OJvzqwbrswA/sFgjuBCY1WWdsN341H7kCSTzXV7a7qsOr7VSfOPfQ/7QDuTrDQe CiQw== X-Gm-Message-State: ALoCoQmhcennMf74ajh2U0SckN5KqbqxJLcd75tGWLirNdXJ6n4ubePgBMnZOe/Xrcv/SvlPQYE5 X-Received: by 10.112.141.230 with SMTP id rr6mr4255926lbb.4.1413822422853; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.131 with SMTP id w3ls504812lad.79.gmail; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) X-Received: by 10.152.170.194 with SMTP id ao2mr2846637lac.60.1413822422618; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id c5si15022936lah.117.2014.10.20.09.27.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 09:27:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so4296929lam.36 for ; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr28647574lad.29.1413822422344; Mon, 20 Oct 2014 09:27:02 -0700 (PDT) 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.112.84.229 with SMTP id c5csp339448lbz; Mon, 20 Oct 2014 09:27:01 -0700 (PDT) X-Received: by 10.68.202.170 with SMTP id kj10mr3056267pbc.161.1413822420874; Mon, 20 Oct 2014 09:27:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vx5si8259629pab.239.2014.10.20.09.26.59 for ; Mon, 20 Oct 2014 09:27:00 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752454AbaJTQ06 (ORCPT + 15 others); Mon, 20 Oct 2014 12:26:58 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:63573 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751102AbaJTQZx (ORCPT ); Mon, 20 Oct 2014 12:25:53 -0400 Received: by mail-wi0-f177.google.com with SMTP id fb4so6843020wid.4 for ; Mon, 20 Oct 2014 09:25:52 -0700 (PDT) X-Received: by 10.194.250.105 with SMTP id zb9mr5207557wjc.123.1413822352826; Mon, 20 Oct 2014 09:25:52 -0700 (PDT) Received: from localhost.localdomain (AToulouse-656-1-960-30.w90-50.abo.wanadoo.fr. [90.50.217.30]) by mx.google.com with ESMTPSA id cs2sm10155776wib.2.2014.10.20.09.25.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Oct 2014 09:25:52 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: peterz@infradead.org, nicolas.pitre@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org Subject: [PATCH 4/5] cpuidle: menu: Fix the get_typical_interval Date: Mon, 20 Oct 2014 18:25:42 +0200 Message-Id: <1413822343-1972-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413822343-1972-1-git-send-email-daniel.lezcano@linaro.org> References: <1413822343-1972-1-git-send-email-daniel.lezcano@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: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) 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 first time the 'get_typical_function' is called, it computes an average of zero as no data is filled yet. That leads the 'data->predicted_us' variable to be set to zero too. The caller, 'menu_select' will then do: interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters, cpu_load); That sets the interactivity_req to zero (0/performance...). and then if (latency_req > interactivity_req) latency_req = interactivity_req; ... setting 'latency_req' to zero too. No idle state will fulfill this constraint and we will go the C1 state as default and leading to an update. So the next calls will compute an average different from zero. Even if that works with the current code but with a broken semantic, it will just break with the next patches where we are stricter with the latencies check: the first check will fail (latency_req is zero), then no update will occur leading to always falling to choose an idle state. As there are no previous values and it is pointless to compute a standard deviation for these unexisting values. Just return without setting the 'data->predicted_us' to zero. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/governors/menu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 3907301..6ae8390 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -226,6 +226,15 @@ again: else do_div(avg, divisor); + /* + * We are at the very beginning and no data have been filled + * yet. Let's skip the standard deviation computation + * otherwise the data->predicted_us will be zero and that will + * lead to a zero latency req in the select function + */ + if (!avg) + return; + /* Then try to determine standard deviation */ stddev = 0; for (i = 0; i < INTERVALS; i++) {