linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>, rjw@sisk.pl
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 18/21] cpuidle: don't call poll_idle_init() for every cpu
Date: Thu, 26 Sep 2013 00:22:47 +0200	[thread overview]
Message-ID: <52436237.3040500@linaro.org> (raw)
In-Reply-To: <495ffb1175175b0180ca3da96eb5ed72a8280364.1379779777.git.viresh.kumar@linaro.org>

On 09/22/2013 03:21 AM, Viresh Kumar wrote:
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

The optimization sounds good but IMHO if we can move this state out of
the cpuidle common framework that would be nicer.

The poll_idle is only applicable for x86 (acpi_driver and intel_idle),
hence I suggest we move this state to these drivers, that will cleanup
the framework code and will remove index shift macro
CPUIDLE_DRIVER_STATE_START which IMHO is weid and prone-to-error.

> ---
>  drivers/cpuidle/cpuidle.c | 41 -----------------------------------------
>  drivers/cpuidle/driver.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 43d5836..bf80236 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -226,45 +226,6 @@ void cpuidle_resume(void)
>  	mutex_unlock(&cpuidle_lock);
>  }
>  
> -#ifdef CONFIG_ARCH_HAS_CPU_RELAX
> -static int poll_idle(struct cpuidle_device *dev,
> -		struct cpuidle_driver *drv, int index)
> -{
> -	ktime_t	t1, t2;
> -	s64 diff;
> -
> -	t1 = ktime_get();
> -	local_irq_enable();
> -	while (!need_resched())
> -		cpu_relax();
> -
> -	t2 = ktime_get();
> -	diff = ktime_to_us(ktime_sub(t2, t1));
> -	if (diff > INT_MAX)
> -		diff = INT_MAX;
> -
> -	dev->last_residency = (int) diff;
> -
> -	return index;
> -}
> -
> -static void poll_idle_init(struct cpuidle_driver *drv)
> -{
> -	struct cpuidle_state *state = &drv->states[0];
> -
> -	snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
> -	snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
> -	state->exit_latency = 0;
> -	state->target_residency = 0;
> -	state->power_usage = -1;
> -	state->flags = 0;
> -	state->enter = poll_idle;
> -	state->disabled = false;
> -}
> -#else
> -static void poll_idle_init(struct cpuidle_driver *drv) {}
> -#endif /* CONFIG_ARCH_HAS_CPU_RELAX */
> -
>  /**
>   * cpuidle_enable_device - enables idle PM for a CPU
>   * @dev: the CPU
> @@ -294,8 +255,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
>  	if (!dev->state_count)
>  		dev->state_count = drv->state_count;
>  
> -	poll_idle_init(drv);
> -
>  	ret = cpuidle_add_device_sysfs(dev);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
> index 7b2510a..a4a93b4 100644
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/mutex.h>
>  #include <linux/module.h>
> +#include <linux/sched.h>
>  #include <linux/cpuidle.h>
>  #include <linux/cpumask.h>
>  #include <linux/clockchips.h>
> @@ -179,6 +180,45 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv)
>  	}
>  }
>  
> +#ifdef CONFIG_ARCH_HAS_CPU_RELAX
> +static int poll_idle(struct cpuidle_device *dev,
> +		struct cpuidle_driver *drv, int index)
> +{
> +	ktime_t	t1, t2;
> +	s64 diff;
> +
> +	t1 = ktime_get();
> +	local_irq_enable();
> +	while (!need_resched())
> +		cpu_relax();
> +
> +	t2 = ktime_get();
> +	diff = ktime_to_us(ktime_sub(t2, t1));
> +	if (diff > INT_MAX)
> +		diff = INT_MAX;
> +
> +	dev->last_residency = (int) diff;
> +
> +	return index;
> +}
> +
> +static void poll_idle_init(struct cpuidle_driver *drv)
> +{
> +	struct cpuidle_state *state = &drv->states[0];
> +
> +	snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
> +	snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
> +	state->exit_latency = 0;
> +	state->target_residency = 0;
> +	state->power_usage = -1;
> +	state->flags = 0;
> +	state->enter = poll_idle;
> +	state->disabled = false;
> +}
> +#else
> +static void poll_idle_init(struct cpuidle_driver *drv) {}
> +#endif /* !CONFIG_ARCH_HAS_CPU_RELAX */
> +
>  /**
>   * __cpuidle_register_driver: register the driver
>   * @drv: a valid pointer to a struct cpuidle_driver
> @@ -212,6 +252,8 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
>  		on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer,
>  				 (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1);
>  
> +	poll_idle_init(drv);
> +
>  	return 0;
>  }
>  
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2013-09-25 22:22 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-22  1:20 [PATCH 00/21] CPUIdle: Minor cleanups for 3.13 Viresh Kumar
2013-09-22  1:20 ` [PATCH 01/21] cpuidle: fix indentation of cpumask Viresh Kumar
2013-09-22  1:20 ` [PATCH 02/21] cpuidle: Fix comments in cpuidle core Viresh Kumar
2013-09-22  1:20 ` [PATCH 03/21] cpuidle: make __cpuidle_get_cpu_driver() inline Viresh Kumar
2013-09-25 21:27   ` Daniel Lezcano
2013-09-22  1:20 ` [PATCH 04/21] cpuidle: make __cpuidle_device_init() return void Viresh Kumar
2013-09-22  1:20 ` [PATCH 05/21] cpuidle: make __cpuidle_driver_init() " Viresh Kumar
2013-09-23  9:58   ` Hongbo Zhang
2013-09-23 10:02     ` Viresh Kumar
2013-09-22  1:20 ` [PATCH 06/21] cpuidle: rearrange code in __cpuidle_driver_init() Viresh Kumar
2013-09-25 21:40   ` Daniel Lezcano
2013-09-26  5:01     ` Viresh Kumar
2013-09-22  1:20 ` [PATCH 07/21] cpuidle: rearrange __cpuidle_register_device() to keep minimal exit points Viresh Kumar
2013-09-25 21:49   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 08/21] cpuidle: use cpuidle_disabled() instead of "off" Viresh Kumar
2013-09-25 21:52   ` Daniel Lezcano
2013-09-26  5:06     ` Viresh Kumar
2013-09-26  8:25       ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 09/21] cpuidle: merge two if() statements for checking error cases Viresh Kumar
2013-09-25 21:52   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 10/21] cpuidle: reduce code duplication inside cpuidle_idle_call() Viresh Kumar
2013-09-25 22:01   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 11/21] cpuidle: replace multiline statements with single line in cpuidle_idle_call() Viresh Kumar
2013-09-25 22:03   ` Daniel Lezcano
2013-09-26  5:51     ` Viresh Kumar
2013-09-26  7:55       ` Daniel Lezcano
2013-09-26  8:11         ` Viresh Kumar
2013-09-22  1:21 ` [PATCH 12/21] cpuidle: call cpuidle_get_driver() from after taking cpuidle_driver_lock Viresh Kumar
2013-09-25 22:04   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 13/21] cpuidle: use drv instead of cpuidle_driver in show_current_driver() Viresh Kumar
2013-09-25 22:05   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 14/21] cpuidle: coupled: don't compare cpu masks unnecessarily Viresh Kumar
2013-09-25 22:06   ` Daniel Lezcano
2013-09-26  0:25   ` Colin Cross
2013-09-26  6:36     ` Viresh Kumar
2013-09-26  6:50       ` Colin Cross
2013-09-22  1:21 ` [PATCH 15/21] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Viresh Kumar
2013-09-25 22:09   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 16/21] cpuidle: avoid unnecessary kzalloc/free of struct cpuidle_device_kobj Viresh Kumar
2013-09-25 22:12   ` Daniel Lezcano
2013-09-26  6:05     ` Viresh Kumar
2013-09-26  8:30       ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 17/21] cpuidle: avoid unnecessary kzalloc/free of struct cpuidle_driver_kobj Viresh Kumar
2013-09-25 22:16   ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 18/21] cpuidle: don't call poll_idle_init() for every cpu Viresh Kumar
2013-09-25 22:22   ` Daniel Lezcano [this message]
2013-09-26  6:09     ` Viresh Kumar
2013-09-26  8:28       ` Daniel Lezcano
2013-10-03 10:33         ` Viresh Kumar
2013-10-03 11:46           ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 19/21] cpuidle: create list of registered drivers Viresh Kumar
2013-09-25 22:30   ` Daniel Lezcano
2013-09-26  6:17     ` Viresh Kumar
2013-09-26  8:19       ` Daniel Lezcano
2013-09-28 21:33         ` Paul E. McKenney
2013-09-30 18:37           ` Daniel Lezcano
2013-10-03  4:38             ` Viresh Kumar
2013-10-03 10:47               ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 20/21] cpuidle: don't calculate time-diff if entered_state == 0 Viresh Kumar
2013-09-25 22:38   ` Daniel Lezcano
2013-09-26  6:24     ` Viresh Kumar
2013-09-26  8:25       ` Daniel Lezcano
2013-09-26  8:28         ` Viresh Kumar
2013-09-26  8:33           ` Daniel Lezcano
2013-09-22  1:21 ` [PATCH 21/21] cpuidle: change governor from within cpuidle_replace_governor() Viresh Kumar
2013-09-25 22:50   ` Daniel Lezcano
2013-09-26  6:37     ` Viresh Kumar
2013-09-26  8:20       ` Daniel Lezcano
2013-10-03 10:36         ` Viresh Kumar
2013-10-03 11:58           ` Daniel Lezcano

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=52436237.3040500@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rjw@sisk.pl \
    --cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).