Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3422020ybc; Mon, 18 Nov 2019 15:14:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwiblJip6J+/Fi56GIpGDbUWBNCfFpttJ6FLPNAgp3zkDlnCb7sU7G8S0V1A8T2fQBIKh1c X-Received: by 2002:a17:906:24d4:: with SMTP id f20mr31058020ejb.182.1574118842155; Mon, 18 Nov 2019 15:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574118842; cv=none; d=google.com; s=arc-20160816; b=UpdiK6BKWTFjDbNCEHp3FkrmhD3VmWSZUenDTIxdbrywT04AZgNb+++fHlvxSfSSJw kGp+2d7nqY8mAcXk+WyNue+8LVwR9dMmfXnm0oVl8hW6D1lhlwn6aX7VPgYyQ8xFYsPn iskUFlZw8lfFi0OAONsI6X6Kr6a9+tFG38Z+X5ruvpOdfKGCi8NUGbZbkhg/O9P8+syG 4lIXHqXKk+FEjXbP9Ozc2nIAmOfqcJmyqoKtuDv+D3egO6gKwjVdKb9mvOUnNmFJDA0c hLVUtJlWA9Rwe0/TQoQXpux51aJjrTXD2zImQFF5Pn7UxYzq/s1CoFoIvY7bGrdH6xsQ RvwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PoUOmjf5gE4C7XM5PbBJTweyqYzujvk1YqZxO8SoprU=; b=K0h5Oup7CD6vAHFUfXZStzjZD1vdcCKohmVi54+OqxjUM0MN2XTnOJ16ul2ulmmYpX tRm4Z2W4WrIQMxOeVqu9cJxNwRx76HCToChDBtsFbtFW88YneZHnV1YZX1rODNV0L/Y3 u+CAumaPprAKhR1GFEMWWLEvEqUITu3CrQgbopWLW27RvjilGjs7svIEg9m8kCNXVCoF G248HVugpV9Li6cvMiqGsNaJq5fARNie4fztSy0+FpvBGGIIwAS7Q6M7WX/vnMkqLbw7 nsM/DTTLcWsopd5yStUmVbV7VB5YxzIxz5kUMMioFa1vn1MfgDRybxywowsmGwAq7eSe emKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks14si12005083ejb.87.2019.11.18.15.13.37; Mon, 18 Nov 2019 15:14:02 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbfKRXKK (ORCPT + 99 others); Mon, 18 Nov 2019 18:10:10 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:47618 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbfKRXKF (ORCPT ); Mon, 18 Nov 2019 18:10:05 -0500 Received: from 79.184.253.244.ipv4.supernova.orange.pl (79.184.253.244) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id bde311d14881fd19; Tue, 19 Nov 2019 00:10:02 +0100 From: "Rafael J. Wysocki" To: Len Brown Cc: "Rafael J. Wysocki" , Linux PM , Peter Zijlstra , Daniel Lezcano , Doug Smythies , LKML Subject: [RFC][PATCH 0/2] cpuidle: Allow states to be disabled by default (was: Re: [PATCH] cpuidle: Consolidate disabled state checks) Date: Tue, 19 Nov 2019 00:04:59 +0100 Message-ID: <1688511.GgkECGP1XA@kreacher> In-Reply-To: References: <2717750.dCEzHT3DVQ@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, November 18, 2019 12:26:57 PM CET Rafael J. Wysocki wrote: > On Mon, Nov 18, 2019 at 10:22 AM Rafael J. Wysocki wrote: > > > > On Mon, Nov 18, 2019 at 5:46 AM Len Brown wrote: > > > > > > On Mon, Nov 4, 2019 at 6:16 AM Rafael J. Wysocki wrote: > > > > > > > > From: Rafael J. Wysocki > > > > > > > > There are two reasons why CPU idle states may be disabled: either > > > > because the driver has disabled them or because they have been > > > > disabled by user space via sysfs. > > > > > > > > In the former case, the state's "disabled" flag is set once during > > > > the initialization of the driver and it is never cleared later (it > > > > is read-only effectively). > > > > > > for x86 (intel_idle and acpi_idle), no states with disabled=1 are registered > > > with cpuidle. Instead, intel_idle (currently) skips them in the loop > > > that registers states. > > > (and acpi_idle never touches the disabled field) > > > > > > And so for x86, governors checking for drv->states[i].disabled is a NOP, > > > and the condition described by CPUIDLE_STATE_DISABLED_BY_DRIVER > > > does not (yet) exist. > > > > OK > > > > > Looking at the ARM code, it seems that cpuidle-imx6q.c and cpuidle-tegra20.c > > > reach into the cpuidle states at run time and toggle the > > > drv->states[i].disabled. > > > > I might have overlooked that, let me check. > > > > > It seems that this patch takes the initial value of > > > drv->states->disabled, and sets the (per cpu) > > > usage.disable=..BY_DRIVER, > > > but that subsequent run-time toggles in drv->states[i]disabled by > > > these drivers would be missed, > > > because you're removed the run-time checking of drv->states->disabled? > > > > If it is updated at run time, then yes, the updates will be missed, so > > thanks for pointing that out. > > > > > Finally, I'd like to change intel_idle so that it *can* register a > > > state that is disabled, by default. > > > If I change the driver to NOT skip registering disabled states, and > > > the cpuidle copy has cpuidle_state.disabled=1, > > > then the state is indeed, unused at run-time. But as you said, > > > it is effectively read-only, and is not indicated in sysfs, and can > > > not be changed via sysfs. > > > > > > One way to do this is to do what you do here and initialize > > > usage.disabled to drv->state.disabled. (not distinguishing between > > > DRIVER and USER) > > > That way the user could later over-ride what a driver set, by clearing > > > the disabled attribute. > > I'd rather get rid of the "disabled" field from struct cpuidle_state > entirely and introduce a new state flag to indicate the "disabled by > default" status. > > I also would expose that new flag in a new sysfs attribute of idle > states, say "disable_default". > > Then, the DISABLED_BY_DRIVER bit would be reserved for driver quirks > (as per https://patchwork.kernel.org/patch/11249519/) and the > DISABLED_BY_USER one could be used for all of the other purposes. To that end, I have the following two experimental patches (on top of https://patchwork.kernel.org/patch/11249519/) that IMO are simple enough. Please let me know what you think.