Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2710868ybc; Mon, 18 Nov 2019 03:30:12 -0800 (PST) X-Google-Smtp-Source: APXvYqw/ssdepwO+E+/LY5FBe+l8197LjgAZV23pkng9RScqsyDbwHztmCv1Hs+wkdzasmlfTRlH X-Received: by 2002:a17:906:e88:: with SMTP id p8mr25706434ejf.15.1574076612360; Mon, 18 Nov 2019 03:30:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574076612; cv=none; d=google.com; s=arc-20160816; b=TuHZxIC3WWY0dZOKWmf4TmJqgNTOrcFCYdXHJJtRf4feZ+q39i1bAghMdkx8vmxwlo HLBHmLGe+Q5zhZ4cWXRccLGvVerwihTyjNGjfm6kuJDIS0HStlsaR39jF65B1MVUVtLj eLOy5Z1KuRH9PMrT4PW43YPuhw9wxL8j5gVUDZv/RS3r1Z+rTzIyHVXPHQDtB3o1tYso 3tr8nKcVRW8Aupioeoe2L0J2xIUZIp5Q/LBTaQqsF+s9X+dNhFLypVJHNgIy2UtkRgKg ZzKfld9IHLk90Va5eV8GNm+H8kIIAbzI3WDyNS6SNgh9265Jd41e1MyYVcjFOY+bec8N ynAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=0VGp3OpF5GA2F7BU2LE4TwYF6X0125T01Rr+E1EqppI=; b=ovA7Zmc7fgqL2p1WSF7kRgq2Z478VtIUVPNWACrhGKGFUqwPxe9stykd0T4CKz/S49 2Raq199NzNhH6E/X1Y6S0FUt5o+aC8UOSZG7ZJZBlpTaYx8rASjAWJ9m3cc8BradBr9I ZuFLtZbSHfvRB65zRcDfa6Iy5GsF/T6TEfFHmTiqtlFr8EfwVwz0v1uu4rgErCBn2hd1 r6oNq/pr6Y0l0CYt6Xw4po6fdGsCwSrIEYAaBosg4ZTVF4Ed2WjhK+/5/P4Z8Cq2WrOe AZYqph60zX0ookPc/F6XV0EReZVX//59/p+rN2INrjMhpNdXzxeAGiea1E1w521WiJet 2Z0A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x28si15542599edl.21.2019.11.18.03.29.48; Mon, 18 Nov 2019 03:30:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbfKRL1K (ORCPT + 99 others); Mon, 18 Nov 2019 06:27:10 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40500 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfKRL1K (ORCPT ); Mon, 18 Nov 2019 06:27:10 -0500 Received: by mail-ot1-f68.google.com with SMTP id m15so14170314otq.7; Mon, 18 Nov 2019 03:27:09 -0800 (PST) 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=0VGp3OpF5GA2F7BU2LE4TwYF6X0125T01Rr+E1EqppI=; b=jCMLZMfmYQkoKN3iFC/0AuUf28FH7MDLubE6jSmZTvABJSU6ZYjmQ32KzTMLwEL/BE v0pJd7qp2EpS84gG91LfN2xUw7n83VVDK8v8gKacvB4uCupsDGv3xLa0iXh2atKSCn2D ynj/bzN3qT3Y/+1cvsNSvogzpIowAY/Bmqv5PCNk1ZfHYs1h6KyL8eKM8lDsl7SAAAR9 S98uJrIdufRAh8CxeBEAlPkavt8T8v9nMghFZBCTRQ+RkQsbANyP8bo0C3keGkVv0agB C2e5g8OXIuVFCk6wfa9rAGNBcGvUk0UUuLf5id0AVE/0OfMenq6WE1UhSSiir9MWfK7e H4ng== X-Gm-Message-State: APjAAAXTEGxk0JBBEnl/mVbB/Kdu4nLAvMZCpjnSpaFkO7Td4ulNnpww UbVtUHtSZ0Jf9RefQ6idRM450nBISiIbtgD/t/A= X-Received: by 2002:a05:6830:232a:: with SMTP id q10mr22460237otg.262.1574076428641; Mon, 18 Nov 2019 03:27:08 -0800 (PST) MIME-Version: 1.0 References: <2717750.dCEzHT3DVQ@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 18 Nov 2019 12:26:57 +0100 Message-ID: Subject: Re: [PATCH] cpuidle: Consolidate disabled state checks To: "Rafael J. Wysocki" Cc: Len Brown , "Rafael J. Wysocki" , Linux PM , Peter Zijlstra , Daniel Lezcano , Doug Smythies , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cheers, Rafael