Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2593686ybc; Mon, 18 Nov 2019 01:24:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyqtS9RtzxMfvKccZoOszW7LBJnq7hRoDkgNijJYjIZPY6JrJPiowyTcnKWb0PeZvh1QjYh X-Received: by 2002:a05:600c:2549:: with SMTP id e9mr26820799wma.177.1574069042932; Mon, 18 Nov 2019 01:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574069042; cv=none; d=google.com; s=arc-20160816; b=vNt2HvpfQAa8IUzex3rrVRE/2rzV3HBJnbKt0htj4V5G4cHCA45HWt3iebwZGU8qt8 +pl3pZTVWmttsI5Zisr1LfuGASR7x+oHq6b4T0tibE4ePQ4RzMnumifRVbI94Lk1fYIp V0AVmqPK3Wto8AKXHnokQU6A89uu4WlD7N6zIR4NoWIgOlBhSXJe6/SlcH5mqtyXW+uG 7Z890KsvZtyRdy3IydrNUGNEqLFlHwiKvq5OlkRP6DSmWFnRNjDke6bWK3vsAaiwTakC Z+J/fcqLRQrwTo9FOWzrXy2eW5imM0TygvVULNqduGmbcuBrY5CCUdiJXb6XFCSt+psi cN+A== 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=vN0gbv6vMevkHM5ujao5cMfwNZPe4ICulhsutFl+h+s=; b=RuBLQXBTvccHP6OQ9ZhyBC1ADa0e9IHljVD5WPebFegFSY/duoFnI9yttnxUEs4OC5 nm5FGQW9IhXrrnXaTIJ5/YZovmqqECub9HryPLlgqq6M+TbF8jowVxckcLp7VWO7uQ42 X6kj105rz8KXIMS9sjPrC+CUsUKatfAAIUgq9DvJdPCQmFNFyQfjGsfG5S8s2tauQ77U UXa1TbJD45AJ9+//Y5DRtuD5nJhdoNUm7nSlAzIkvdf+hGLrZQfdD+L9c6Kf2NRfy2kV teE8JWaFIvturgYDKMGQUynVENwdhMwWkVPBlVEB/g7CB2c2n7m/z/FDfE9qjyLKLm+g GJeg== 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 f36si12274667ede.159.2019.11.18.01.23.39; Mon, 18 Nov 2019 01:24: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726750AbfKRJWR (ORCPT + 99 others); Mon, 18 Nov 2019 04:22:17 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:39829 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbfKRJWR (ORCPT ); Mon, 18 Nov 2019 04:22:17 -0500 Received: by mail-oi1-f194.google.com with SMTP id v138so14666050oif.6; Mon, 18 Nov 2019 01:22:16 -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=vN0gbv6vMevkHM5ujao5cMfwNZPe4ICulhsutFl+h+s=; b=uK67ZnoQIB5oF4aBmoDBRoo4U93stEHOE929uZVKdDQ0avOC9cW7bFhGbtwAk4rwuE pFIXLI2Ty57D3mZeYhxbzBi/4l2IZCudPPMvjvZzj/E4kBNjsIU7z6/REBuSMTHWbUdZ VpqElpuhUjc8+ru+U8uLlEBWbnLUPCZB+thVOBV8s93eRZyXUFYFY6UBKlsnvhQU0gqv uPkrXCdOcqDHRXYqtcW0rWlgsn78qKL5TeRXAecYZAPE+9EzgM0w+i9M6SO7ad8MR/Dr 2bveCLyBe0cPxKfvs5WYHrSX/DwpqTxtm2bOQSr6OkFeLcaO7QpD+HmpKvMm3B3DqCYU DjSA== X-Gm-Message-State: APjAAAVBsLsU/0qrYW3Ps7JWxRntVWRVxMryJ+xqN/JP0jvQFpHwNWtr 0I28FP5a6lxT6Y9/HeFfEpQC/FIZnfDOSz8wT7g= X-Received: by 2002:aca:1101:: with SMTP id 1mr20107108oir.103.1574068936447; Mon, 18 Nov 2019 01:22:16 -0800 (PST) MIME-Version: 1.0 References: <2717750.dCEzHT3DVQ@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 18 Nov 2019 10:22:05 +0100 Message-ID: Subject: Re: [PATCH] cpuidle: Consolidate disabled state checks To: Len Brown Cc: "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 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. > > However, the ARM drivers, at least, seem to want to reserve the right > to set and clear the drv->state.disabled, > and to have them continue to have that right, we have to continue > checking that field at run-time. Alternatively, the drivers in question can be changed to update the disable field in state_usage instead (maybe under a lock to prevent them from racing with user space). > And giving drivers the opportunity to do that disabling driver-wide, > instead of per-cpu (usage) wide, > seems to be something we may want to keep. So it looks like you want me to revert this patch which is something that I really don't want to do, because of the extra checks all over the place which are simply pointless in the majority of cases. Cheers, Rafael