Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6619089pxv; Thu, 29 Jul 2021 20:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLU/sfxyeSPfQ9W8QVnSZzFuOw+jyW4Eu+LLmYPiYIrE4CzCgnK4EBuDWxLqm3nF73TfCn X-Received: by 2002:a17:906:ae91:: with SMTP id md17mr574764ejb.105.1627616326931; Thu, 29 Jul 2021 20:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627616326; cv=none; d=google.com; s=arc-20160816; b=cfx6hx3lQKFDpQ9lV7eOzqO3KSX5uFt8NdwVGyee4ED6OXHN4MVcKXV0eyOZPw96gi mCPkcRW4BWICFXCld24HHM52JelfJb0d0Z4NjHR/bqRSGIKQ5tEz3ABD9MqYBdKcVek+ 6fuNUclx3mroowOUL/t6laMhK5ZXdzvW/CKH5BrWwHc6kaUiuj30fhzZfXFjDijjyyef UHC6MxsJopVV/vo9UVyq6bTZnd/lB4HhOe35KabILQ6tqCiEoWex1qkzYmvZlTO9AUM0 ckmyK1EVA9DsUPRlFnB1sRODVay8TR/bNsywnICv3LJyNrJ0KPimwN4WTzqEjYWS6bkw sNYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=V1EKk6db6Y8vCs85qWDsaQdefuQvwKiDm0jlq66LwLk=; b=VonbIwcY7s1zVvgonZb+txtJNDP+grAyEb3Huh3rOqGT3TJTcnQWoB0c8vocjkDCvD IMrbHBLMAFTJuvsdrdax2+fiMKfyCEA2PAjufE7WhEMBjOFyGmoAs5nhoVzx3bgQEhIv AsPO/xWg6I5Ot8kNkeLHvPTfEYk84ltZVXL8UWUDt/cVSLqTboWNYgk8I8NK/IuGcRvW RvcMUYRVpDLWEgnNmUSdGA2dyWO4pKPPNHhVPLsitINOwvfCGIGQWTyS2VGHV5Gk3YzU XUM9WnETsMac/lJSDqQKf3DwAbxk9h2pDsuMyqN4/FqvSn3dAphXKWW1Km+kvDh214fl hDaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@telus.net header.s=google header.b="V/0drxt9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=telus.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q2si444702edc.346.2021.07.29.20.38.22; Thu, 29 Jul 2021 20:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@telus.net header.s=google header.b="V/0drxt9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=telus.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236250AbhG3DhD (ORCPT + 99 others); Thu, 29 Jul 2021 23:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234733AbhG3DhD (ORCPT ); Thu, 29 Jul 2021 23:37:03 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E93EDC0613C1 for ; Thu, 29 Jul 2021 20:36:57 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id y200so9764774iof.1 for ; Thu, 29 Jul 2021 20:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V1EKk6db6Y8vCs85qWDsaQdefuQvwKiDm0jlq66LwLk=; b=V/0drxt9megCv8w0kDJNaPEyTmBwWbF0FmUQQ6jUct64IS+vXU1mvsvzBy32FtXZB4 p0CHybwKutlK9CO8+xTY5LnDGLonMZSBXkISqhvVy/BSqPThLtCMLeDL1bUsPliuVafW +EUbrG/bqLUPEmke5nDUtOZt5nd0yvfXI3VtP4LkEC0m2+1auhlIdqAekEQhrTBQ9lyp QK0m9GnrBXlvxWpIX6JIuEt7SNg9OyWGj8KLYFG/CwY/boN4dLbycNp2CAUl706X7gLk ToOkYStabPzB/48DZrw66c0aCHEU0tI8rU8fg+Fo0/5fnDIHc/5YcuheT4dpVEDyIlYc pc6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V1EKk6db6Y8vCs85qWDsaQdefuQvwKiDm0jlq66LwLk=; b=RFL3drmIAEOLQMnOgfAccFKjmsm8Cjc0dU4Nx8U6N3zT9vzkyq93rUU8+zd7Tz4jqz NbhDNvcqA8BnF8e5/5ohjBNSYqLHrZ+kXpbo5DtsSChZ/KFDT7uYqeHbnsUu7ORTzJLX 2iKINjQ/MN8ttcFw1Bnunvi4MmsNFQBCaj8Y9hXYXtEKDHHEm1z1iBWJrzqeEbddfeeW 5sjVAgoxO4HcKWXC1ysiEVPdgxPkoZm0YQn3z1KV/+/pOs1CLO3pqBUI9DqqV6cMnUVx iY8Z0Uv8e4/FII6upAkSrF9Vv9Y0ztLPB8MsJvvDJ892mzcvW9hGhz4LhVkv+pWa2chO 6UWA== X-Gm-Message-State: AOAM530PBk6/iUXi0+7cTgKODgysA6ChWa1VlbgsyTukAYvGnfwJzJhb DlYeWidbSzHlnum+uSKlmnq4DZok3OtUJiAL3C/6Ig== X-Received: by 2002:a5e:db02:: with SMTP id q2mr626895iop.172.1627616217421; Thu, 29 Jul 2021 20:36:57 -0700 (PDT) MIME-Version: 1.0 References: <1867445.PYKUYFuaPT@kreacher> <2178828.iZASKD2KPV@kreacher> <4334837.LvFx2qVVIh@kreacher> In-Reply-To: <4334837.LvFx2qVVIh@kreacher> From: Doug Smythies Date: Thu, 29 Jul 2021 20:36:49 -0700 Message-ID: Subject: Re: [PATCH v1 0/5] cpuidle: teo: Rework the idle state selection logic To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , LKML , Linux PM , dsmythies Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 29, 2021 at 9:14 AM Rafael J. Wysocki wrote: > ... [snip]... > > This means that idle state 0 data are disregarded after disabling it > and that most likely is because the second loop in teo_select() should > be over all states down to idle state 0 (not only down to the first > enabled one). > > So below is an updated patch (not tested yet). Hi Rafael, This updated patch works great / solves the problem. Tested-by: Doug Smythies Thank you very much. ... Doug > > --- > drivers/cpuidle/governors/teo.c | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > > Index: linux-pm/drivers/cpuidle/governors/teo.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/governors/teo.c > +++ linux-pm/drivers/cpuidle/governors/teo.c > @@ -397,32 +397,34 @@ static int teo_select(struct cpuidle_dri > intercept_sum = 0; > recent_sum = 0; > > - for (i = idx - 1; i >= idx0; i--) { > + for (i = idx - 1; i >= 0; i--) { > struct teo_bin *bin = &cpu_data->state_bins[i]; > s64 span_ns; > > intercept_sum += bin->intercepts; > recent_sum += bin->recent; > > - if (dev->states_usage[i].disable) > + if (dev->states_usage[i].disable && i > 0) > continue; > > span_ns = teo_middle_of_bin(i, drv); > - if (!teo_time_ok(span_ns)) { > - /* > - * The current state is too shallow, so select > - * the first enabled deeper state. > - */ > - duration_ns = last_enabled_span_ns; > - idx = last_enabled_idx; > - break; > - } > > if ((!alt_recent || 2 * recent_sum > idx_recent_sum) && > (!alt_intercepts || > 2 * intercept_sum > idx_intercept_sum)) { > - idx = i; > - duration_ns = span_ns; > + if (!teo_time_ok(span_ns) || > + dev->states_usage[i].disable) { > + /* > + * The current state is too shallow or > + * disabled, so select the first enabled > + * deeper state. > + */ > + duration_ns = last_enabled_span_ns; > + idx = last_enabled_idx; > + } else { > + idx = i; > + duration_ns = span_ns; > + } > break; > }