From patchwork Thu Oct 23 09:01:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 39348 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BDED720341 for ; Thu, 23 Oct 2014 09:01:30 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf335386lbg.5 for ; Thu, 23 Oct 2014 02:01:29 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=32CIBmXok9v+QtSblO3lj95bsq8TnHbzyHJSFr6HtwI=; b=bB1STZSHqV5oFZhKSuR7cL5WSg8tOLtdm8y4fpahdagFG5LjKUy/EU4cLQtTs3FAot qmaBUhGX3nLrb9rhaktJth5Z00ZEHxHMt0Gs6UCcFhxl3lTQ/AvONO9HsnKS/qYI2FFK m2uJlp+yG4xJciX1mmUUYECVrv4UFQlmFyFyz3KFhPdWYKPv2lk/mAXkH/bHeRsmzFzj SbU0RUTs+2aalisIbQ1TWWV5EBzKCXsgtCKK2RWI0csQrNsdLGrDJcwnOshk2pBy50Fe Z3T7Rj7OJxvfcLhDogBzD4iGnpvcQQ/AaM2IE9dtlj4e1O+1iWRjFr4J2ErzV3u45Jrk 6Gxg== X-Gm-Message-State: ALoCoQkLpMNd4vsxodDRoAOi3qDPLsKktwVoy7NmL6hfW5gR8AjaP6M1NcEbkcKM/IF5Lz3Dn4Gi X-Received: by 10.112.89.195 with SMTP id bq3mr777876lbb.9.1414054889573; Thu, 23 Oct 2014 02:01:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.174 with SMTP id p14ls240878lal.68.gmail; Thu, 23 Oct 2014 02:01:29 -0700 (PDT) X-Received: by 10.112.161.9 with SMTP id xo9mr3617074lbb.62.1414054889308; Thu, 23 Oct 2014 02:01:29 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ms6si1672070lbb.19.2014.10.23.02.01.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 02:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id s18so478659lam.9 for ; Thu, 23 Oct 2014 02:01:29 -0700 (PDT) X-Received: by 10.152.120.199 with SMTP id le7mr3421782lab.67.1414054889175; Thu, 23 Oct 2014 02:01:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp220616lbz; Thu, 23 Oct 2014 02:01:28 -0700 (PDT) X-Received: by 10.194.57.210 with SMTP id k18mr2442982wjq.110.1414054888438; Thu, 23 Oct 2014 02:01:28 -0700 (PDT) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com. [74.125.82.41]) by mx.google.com with ESMTPS id hj7si1274497wjb.114.2014.10.23.02.01.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 02:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.lezcano@linaro.org designates 74.125.82.41 as permitted sender) client-ip=74.125.82.41; Received: by mail-wg0-f41.google.com with SMTP id b13so616551wgh.24 for ; Thu, 23 Oct 2014 02:01:28 -0700 (PDT) X-Received: by 10.180.207.6 with SMTP id ls6mr44237708wic.28.1414054888238; Thu, 23 Oct 2014 02:01:28 -0700 (PDT) Received: from localhost.localdomain (AToulouse-656-1-959-39.w90-50.abo.wanadoo.fr. [90.50.216.39]) by mx.google.com with ESMTPSA id ga7sm1845645wic.5.2014.10.23.02.01.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Oct 2014 02:01:27 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: nicolas.pitre@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH V2 4/5] cpuidle: menu: Fix the get_typical_interval Date: Thu, 23 Oct 2014 11:01:20 +0200 Message-Id: <1414054881-17713-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414054881-17713-1-git-send-email-daniel.lezcano@linaro.org> References: <1414054881-17713-1-git-send-email-daniel.lezcano@linaro.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.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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 Acked-by: Nicolas Pitre --- 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++) {