public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Kazuki Hashimoto <kazukih0205@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Ingo Molnar <mingo@redhat.com>, Len Brown <len.brown@intel.com>,
	Pavel Machek <pavel@ucw.cz>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Hector Martin <marcan@marcan.st>
Subject: Re: [PATCH 1/2] cpuidle: Don't pass any values to cpuidle_not_available
Date: Tue, 11 Jul 2023 09:42:31 +0200	[thread overview]
Message-ID: <20230711074231.GD3062772@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20230711-cpuidle-v1-1-f391224b3140@gmail.com>

On Tue, Jul 11, 2023 at 02:54:21PM +0900, Kazuki Hashimoto wrote:
> There's no reason to pass any values to cpuidle_not_available() as the
> function works standalone. Since we're planning to use the function in
> other places, make it so to avoid code duplication.
> 
> Signed-off-by: Kazuki Hashimoto <kazukih0205@gmail.com>
> ---
>  drivers/cpuidle/cpuidle.c | 6 ++++--
>  include/linux/cpuidle.h   | 6 ++----
>  kernel/sched/idle.c       | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 737a026ef58a..c9ba51e0fa38 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -49,9 +49,11 @@ void disable_cpuidle(void)
>  	off = 1;
>  }
>  
> -bool cpuidle_not_available(struct cpuidle_driver *drv,
> -			   struct cpuidle_device *dev)
> +bool cpuidle_not_available(void)
>  {
> +	struct cpuidle_device *dev = cpuidle_get_device();
> +	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
> +
>  	return off || !initialized || !drv || !dev || !dev->enabled;
>  }

It appears to me these are a lot of conditions to check *every* time we
go idle -- especially since they hardly, if ever, change.

Can't cpuidle track all this in a single global variable, preferably as
a static_key ?

  reply	other threads:[~2023-07-11  7:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11  5:54 [PATCH 0/2] s2idle fixes for systems without cpuidle Kazuki Hashimoto
2023-07-11  5:54 ` [PATCH 1/2] cpuidle: Don't pass any values to cpuidle_not_available Kazuki Hashimoto
2023-07-11  7:42   ` Peter Zijlstra [this message]
2023-07-11 18:48     ` Kazuki Hashimoto
2023-07-11  5:54 ` [PATCH 2/2] PM: s2idle: Fully prevent the system from entering s2idle when cpuidle isn't supported Kazuki Hashimoto
2023-07-11 17:55   ` Rafael J. Wysocki
2023-07-11 18:38     ` Kazuki H
  -- strict thread matches above, loose matches on Subject: below --
2023-03-16  6:37 [PATCH 1/2] cpuidle: Don't pass any values to cpuidle_not_available Kazuki H
2023-03-16  7:43 ` Kazuki H

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230711074231.GD3062772@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=kazukih0205@gmail.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox