Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2394714ybc; Sun, 17 Nov 2019 20:49:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyT8yuaI7MFdZMl6KvQpWWWFv/80MqbXKUTBirbSk/GHCgjvq4s0pgOWS4Iinge+cItnAkY X-Received: by 2002:a17:906:8548:: with SMTP id h8mr23571285ejy.290.1574052576963; Sun, 17 Nov 2019 20:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574052576; cv=none; d=google.com; s=arc-20160816; b=P1gJn6oj+pHINxggfilexkCjgRd3StQA9x6J3siTKu/EPh/P+YDHMpbCZ5bEeq+dd+ gc6Xhd9kmxSPO/BEVMtSyc+OyKtTkB91Ae/EtdxDrt1OBul3JVK71J1gBIh3Ww+Mxe3W wKeU5cJGwlRByg4S1QeyBK98gSUXlAJXgOjkTuXgXYeRstwrZmeTziOI9zY/ZRdTFyqt aSSiqzVvjuXqu/IxQI6Aiw4yHM3DmGXfmhU2pHLU1UDw+b/iq0H4sdDIVlya3hA3fflI pg5qtzAe5rT+aztCANl8KEvp9BZVy5yjHypwUlVsvX0aeUajKzYmbeV+dJ+ISxvddhSN Q9nA== 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=VUOQUGby+FTDEOd45d8wOcDXQ1N8J/aKk3wSgOD09hw=; b=0B5axTjgRYOh8eMqs2lxNox2TgAIx+DPz0Phbv9JByhpmJy6RaUdF2i9VpoOjwl/ah ptNREbN+HiNYZ+t1RoJM8wSKinxqDINze87WUE4kp3+h5N/SQ3zGe2MNRAaq6foE2EMX KptlysLEaIePn44pMhWQL2cwzaI85Ro/SMoB0glWB3vhLe8TpBdzBZxMrb/OCih/8ctj vuvVFH/AhQ+kMD4v6JX0E7lMOPcnSTyiDw2/+Jm7If5xahv3s5xwo3mnxJZuHHpjj0ll cel9lDSlpOYEOvx09CR39HInz4Ko9+TpCFaxurPymm9aSSBOrose4XbleaqpOs22Yvye wFyA== 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 a11si10949200eju.356.2019.11.17.20.48.41; Sun, 17 Nov 2019 20:49:36 -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 S1726460AbfKREqG (ORCPT + 99 others); Sun, 17 Nov 2019 23:46:06 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:40833 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfKREqG (ORCPT ); Sun, 17 Nov 2019 23:46:06 -0500 Received: by mail-ed1-f65.google.com with SMTP id p59so12404617edp.7; Sun, 17 Nov 2019 20:46:05 -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=VUOQUGby+FTDEOd45d8wOcDXQ1N8J/aKk3wSgOD09hw=; b=o0Jhwv8lA8GADwEVNXPAELicuQDbGgvA6LwgTgMI8RfEbCe6MqDpRADdWqX3/35Y+c wZwjp8sk2H9xlq2oXmT5IoIbUkTYd9YSu1jCPkf5qEXPiPM1l5yw46Gd4wmExzWsT/Cq CpQYlEZRJTSHBrv69I0u9TjzfwuuoeP2q8PU1x+q/bRDdE30W/r9EHGqboYtayYU2gtL Kz/+dRFmxdui8DL93zfF3UTDx8rk9Nkfu6zPmtuap437Z5nrj2DLAhawgqgeo5RMOh9o TDWqdhcxX0CgadFhGd8HB26dQG7DrtQd/IJn/z88Mbmoz3v6Xx3h4cpQ1hmJCncQb4hy Gffw== X-Gm-Message-State: APjAAAUbliMSDP2fiqE8e+dkYvSYxB1uFFDtk6aATkx2D7s7eQc68WHV SRpzturjuH/BoTQJ6BWcngA1rMC+fFIbkdkHxn0= X-Received: by 2002:a17:906:5251:: with SMTP id y17mr24339371ejm.108.1574052364573; Sun, 17 Nov 2019 20:46:04 -0800 (PST) MIME-Version: 1.0 References: <2717750.dCEzHT3DVQ@kreacher> In-Reply-To: <2717750.dCEzHT3DVQ@kreacher> From: Len Brown Date: Sun, 17 Nov 2019 23:45:53 -0500 Message-ID: Subject: Re: [PATCH] cpuidle: Consolidate disabled state checks To: "Rafael J. Wysocki" Cc: 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 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. 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. 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? 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. 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. -Len -- Len Brown, Intel Open Source Technology Center