All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Jisheng Zhang <jszhang@marvell.com>
Cc: rjw@rjwysocki.net, daniel.lezcano@linaro.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] cpuidle: arm: make enter idle operation a bit more efficient
Date: Thu, 24 Mar 2016 16:06:00 +0000	[thread overview]
Message-ID: <20160324160600.GA21749@red-moon> (raw)
In-Reply-To: <1458796038-6062-1-git-send-email-jszhang@marvell.com>

On Thu, Mar 24, 2016 at 01:07:18PM +0800, Jisheng Zhang wrote:
> Currently, entering idle need to check the idx every time to choose the
> real entering idle routine. But this check could be avoided by pointing
> the idle enter function pointer of each idle states to the routines
> suitable for each states directly.
> 
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> ---
>  drivers/cpuidle/cpuidle-arm.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
> index 545069d..48a620f 100644
> --- a/drivers/cpuidle/cpuidle-arm.c
> +++ b/drivers/cpuidle/cpuidle-arm.c
> @@ -23,6 +23,13 @@
>  
>  #include "dt_idle_states.h"
>  
> +static int arm_enter_wfi_state(struct cpuidle_device *dev,
> +			       struct cpuidle_driver *drv, int idx)
> +{
> +	cpu_do_idle();
> +	return 0;
> +}
> +
>  /*
>   * arm_enter_idle_state - Programs CPU to enter the specified state
>   *
> @@ -38,11 +45,6 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
>  {
>  	int ret;
>  
> -	if (!idx) {
> -		cpu_do_idle();
> -		return idx;
> -	}

Mmm...if I wanted to paint your bikeshed I would say idx is in a
register and you are removing a simple comparison to exchange it
with a function that adds to code footprint and may even make
performance worse instead of improving anything.

I am not sure this patch makes anything more efficient, happy to be
proven wrong, with significant data.

Thanks,
Lorenzo

> -
>  	ret = cpu_pm_enter();
>  	if (!ret) {
>  		/*
> @@ -69,7 +71,7 @@ static struct cpuidle_driver arm_idle_driver = {
>  	 * handler for idle state index 0.
>  	 */
>  	.states[0] = {
> -		.enter                  = arm_enter_idle_state,
> +		.enter                  = arm_enter_wfi_state,
>  		.exit_latency           = 1,
>  		.target_residency       = 1,
>  		.power_usage		= UINT_MAX,
> -- 
> 2.8.0.rc3
> 

WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] cpuidle: arm: make enter idle operation a bit more efficient
Date: Thu, 24 Mar 2016 16:06:00 +0000	[thread overview]
Message-ID: <20160324160600.GA21749@red-moon> (raw)
In-Reply-To: <1458796038-6062-1-git-send-email-jszhang@marvell.com>

On Thu, Mar 24, 2016 at 01:07:18PM +0800, Jisheng Zhang wrote:
> Currently, entering idle need to check the idx every time to choose the
> real entering idle routine. But this check could be avoided by pointing
> the idle enter function pointer of each idle states to the routines
> suitable for each states directly.
> 
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> ---
>  drivers/cpuidle/cpuidle-arm.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
> index 545069d..48a620f 100644
> --- a/drivers/cpuidle/cpuidle-arm.c
> +++ b/drivers/cpuidle/cpuidle-arm.c
> @@ -23,6 +23,13 @@
>  
>  #include "dt_idle_states.h"
>  
> +static int arm_enter_wfi_state(struct cpuidle_device *dev,
> +			       struct cpuidle_driver *drv, int idx)
> +{
> +	cpu_do_idle();
> +	return 0;
> +}
> +
>  /*
>   * arm_enter_idle_state - Programs CPU to enter the specified state
>   *
> @@ -38,11 +45,6 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
>  {
>  	int ret;
>  
> -	if (!idx) {
> -		cpu_do_idle();
> -		return idx;
> -	}

Mmm...if I wanted to paint your bikeshed I would say idx is in a
register and you are removing a simple comparison to exchange it
with a function that adds to code footprint and may even make
performance worse instead of improving anything.

I am not sure this patch makes anything more efficient, happy to be
proven wrong, with significant data.

Thanks,
Lorenzo

> -
>  	ret = cpu_pm_enter();
>  	if (!ret) {
>  		/*
> @@ -69,7 +71,7 @@ static struct cpuidle_driver arm_idle_driver = {
>  	 * handler for idle state index 0.
>  	 */
>  	.states[0] = {
> -		.enter                  = arm_enter_idle_state,
> +		.enter                  = arm_enter_wfi_state,
>  		.exit_latency           = 1,
>  		.target_residency       = 1,
>  		.power_usage		= UINT_MAX,
> -- 
> 2.8.0.rc3
> 

  parent reply	other threads:[~2016-03-24 16:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24  5:07 [PATCH] cpuidle: arm: make enter idle operation a bit more efficient Jisheng Zhang
2016-03-24  5:07 ` Jisheng Zhang
2016-03-24  5:07 ` Jisheng Zhang
2016-03-24 13:01 ` Rafael J. Wysocki
2016-03-24 13:01   ` Rafael J. Wysocki
2016-03-24 16:06 ` Lorenzo Pieralisi [this message]
2016-03-24 16:06   ` Lorenzo Pieralisi
2016-03-25  6:25   ` Jisheng Zhang
2016-03-25  6:25     ` Jisheng Zhang
2016-03-25  6:25     ` Jisheng Zhang
2016-03-25 13:20     ` Jisheng Zhang
2016-03-25 13:20       ` Jisheng Zhang
2016-03-25 13:20       ` Jisheng Zhang

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=20160324160600.GA21749@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=jszhang@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.