From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752160AbaEBMDr (ORCPT ); Fri, 2 May 2014 08:03:47 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:64269 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752044AbaEBMDp (ORCPT ); Fri, 2 May 2014 08:03:45 -0400 From: "Rafael J. Wysocki" To: Daniel Lezcano Cc: Linux PM list , Linux Kernel Mailing List , Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH 2/2] cpuidle / menu: Return error code if there are no suitable states Date: Fri, 02 May 2014 14:20:18 +0200 Message-ID: <1684440.TX1lbQesgE@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/3.14.0-rc7+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <53635BB4.30900@linaro.org> References: <2471963.urOyfY8mOG@vostro.rjw.lan> <1516317.nEvPfS8aZ7@vostro.rjw.lan> <53635BB4.30900@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, May 02, 2014 10:47:48 AM Daniel Lezcano wrote: > On 04/30/2014 01:16 AM, Rafael J. Wysocki wrote: > > On Tuesday, April 29, 2014 01:28:03 AM Rafael J. Wysocki wrote: > >> On Monday, April 28, 2014 01:14:32 PM Daniel Lezcano wrote: > >>> On 04/27/2014 02:55 PM, Rafael J. Wysocki wrote: > > [ ... ] > > > --- > > From: Rafael J. Wysocki > > Subject: cpuidle / menu: Return (-1) if there are no suitable states > > > > If there is a PM QoS latency limit and all of the sufficiently shallow > > C-states are disabled, the cpuidle menu governor returns 0 which on > > some systems is CPUIDLE_DRIVER_STATE_START and shouldn't be returned > > if that C-state has been disabled. > > > > Fix the issue by modifying the menu governor to return (-1) in such > > situations. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > drivers/cpuidle/governors/menu.c | 2 +- > > include/linux/cpuidle.h | 2 ++ > > 2 files changed, 3 insertions(+), 1 deletion(-) > > > > Index: linux-pm/drivers/cpuidle/governors/menu.c > > =================================================================== > > --- linux-pm.orig/drivers/cpuidle/governors/menu.c > > +++ linux-pm/drivers/cpuidle/governors/menu.c > > @@ -296,7 +296,7 @@ static int menu_select(struct cpuidle_dr > > data->needs_update = 0; > > } > > > > - data->last_state_idx = 0; > > + data->last_state_idx = CPUIDLE_DRIVER_STATE_START - 1; > > In case of x86, CPUIDLE_DRIVER_STATE_START will be 1, so the select > function could return 0 even this one is disabled and this is not what > you want to happen, no ? OK, so that's a choice. We can choose to do the above or to return an error code if the 0 state is disabled too. The above is arguably simpler and matches the idea that 0 is a "fallback" state on x86. Of course, it also is confusing, because user space *can* set "disable" for the 0 state on x86, but that actually has no effect today AFAICS. I'm mostly worried about systems where CPUIDLE_DRIVER_STATE_START is 0 and where menu_select() explicitly checks "disabled" and then it returns 0 anyway if it cannot find any other suitable state. In my opinion that needs to be made consistent, but I don't care too much about which way as long as the change is not too intrusive. -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.