All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: venkatesh.pallipadi@intel.com
Cc: linux-acpi@vger.kernel.org
Subject: Re: [patch 4/4] CPUIDLE: Add a poll_idle method into CPU_IDLE
Date: Thu, 7 Feb 2008 02:38:14 -0500	[thread overview]
Message-ID: <200802070238.14291.lenb@kernel.org> (raw)
In-Reply-To: <20080201013629.746981000@intel.com>

applied,
thanks,
-len

On Thursday 31 January 2008 20:35, venkatesh.pallipadi@intel.com wrote:
> Add a default poll idle state with 0 latency. Provides an option to users
> to use poll_idle by using 0 as the latency requirement.
> 
> Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
> 
> Index: linux-2.6.25-rc/drivers/acpi/processor_idle.c
> ===================================================================
> --- linux-2.6.25-rc.orig/drivers/acpi/processor_idle.c
> +++ linux-2.6.25-rc/drivers/acpi/processor_idle.c
> @@ -1600,7 +1600,7 @@ struct cpuidle_driver acpi_idle_driver =
>   */
>  static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
>  {
> -	int i, count = 0;
> +	int i, count = CPUIDLE_DRIVER_STATE_START;
>  	struct acpi_processor_cx *cx;
>  	struct cpuidle_state *state;
>  	struct cpuidle_device *dev = &pr->power.dev;
> @@ -1659,6 +1659,8 @@ static int acpi_processor_setup_cpuidle(
>  		}
>  
>  		count++;
> +		if (count == CPUIDLE_STATE_MAX)
> +			break;
>  	}
>  
>  	dev->state_count = count;
> Index: linux-2.6.25-rc/drivers/cpuidle/cpuidle.c
> ===================================================================
> --- linux-2.6.25-rc.orig/drivers/cpuidle/cpuidle.c
> +++ linux-2.6.25-rc/drivers/cpuidle/cpuidle.c
> @@ -15,6 +15,7 @@
>  #include <linux/latency.h>
>  #include <linux/cpu.h>
>  #include <linux/cpuidle.h>
> +#include <linux/ktime.h>
>  
>  #include "cpuidle.h"
>  
> @@ -180,6 +181,44 @@ void cpuidle_disable_device(struct cpuid
>  
>  EXPORT_SYMBOL_GPL(cpuidle_disable_device);
>  
> +#ifdef CONFIG_ARCH_HAS_CPU_RELAX
> +static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
> +{
> +	ktime_t	t1, t2;
> +	s64 diff;
> +	int ret;
> +
> +	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;
> +
> +	ret = (int) diff;
> +	return ret;
> +}
> +
> +static void poll_idle_init(struct cpuidle_device *dev)
> +{
> +	struct cpuidle_state *state = &dev->states[0];
> +
> +	cpuidle_set_statedata(state, NULL);
> +
> +	snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)");
> +	state->exit_latency = 0;
> +	state->target_residency = 0;
> +	state->power_usage = -1;
> +	state->flags = CPUIDLE_FLAG_POLL | CPUIDLE_FLAG_TIME_VALID;
> +	state->enter = poll_idle;
> +}
> +#else
> +static void poll_idle_init(struct cpuidle_device *dev) {}
> +#endif /* CONFIG_ARCH_HAS_CPU_RELAX */
> +
>  /**
>   * cpuidle_register_device - registers a CPU's idle PM feature
>   * @dev: the cpu
> @@ -198,6 +237,8 @@ int cpuidle_register_device(struct cpuid
>  
>  	mutex_lock(&cpuidle_lock);
>  
> +	poll_idle_init(dev);
> +
>  	per_cpu(cpuidle_devices, dev->cpu) = dev;
>  	list_add(&dev->device_list, &cpuidle_detected_devices);
>  	if ((ret = cpuidle_add_sysfs(sys_dev))) {
> Index: linux-2.6.25-rc/include/linux/cpuidle.h
> ===================================================================
> --- linux-2.6.25-rc.orig/include/linux/cpuidle.h
> +++ linux-2.6.25-rc/include/linux/cpuidle.h
> @@ -46,9 +46,10 @@ struct cpuidle_state {
>  /* Idle State Flags */
>  #define CPUIDLE_FLAG_TIME_VALID	(0x01) /* is residency time measurable? */
>  #define CPUIDLE_FLAG_CHECK_BM	(0x02) /* BM activity will exit state */
> -#define CPUIDLE_FLAG_SHALLOW	(0x10) /* low latency, minimal savings */
> -#define CPUIDLE_FLAG_BALANCED	(0x20) /* medium latency, moderate savings */
> -#define CPUIDLE_FLAG_DEEP	(0x40) /* high latency, large savings */
> +#define CPUIDLE_FLAG_POLL	(0x10) /* no latency, no savings */
> +#define CPUIDLE_FLAG_SHALLOW	(0x20) /* low latency, minimal savings */
> +#define CPUIDLE_FLAG_BALANCED	(0x40) /* medium latency, moderate savings */
> +#define CPUIDLE_FLAG_DEEP	(0x80) /* high latency, large savings */
>  
>  #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000)
>  
> @@ -178,4 +179,10 @@ static inline void cpuidle_unregister_go
>  
>  #endif
>  
> +#ifdef CONFIG_ARCH_HAS_CPU_RELAX
> +#define CPUIDLE_DRIVER_STATE_START	1
> +#else
> +#define CPUIDLE_DRIVER_STATE_START	0
> +#endif
> +
>  #endif /* _LINUX_CPUIDLE_H */
> Index: linux-2.6.25-rc/arch/x86/Kconfig
> ===================================================================
> --- linux-2.6.25-rc.orig/arch/x86/Kconfig
> +++ linux-2.6.25-rc/arch/x86/Kconfig
> @@ -112,6 +112,9 @@ config GENERIC_TIME_VSYSCALL
>  	bool
>  	default X86_64
>  
> +config ARCH_HAS_CPU_RELAX
> +	def_bool y
> +
>  config ARCH_SUPPORTS_OPROFILE
>  	bool
>  	default y
> 

      reply	other threads:[~2008-02-07  7:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-01  1:35 [patch 0/4] ACPI, CPU_IDLE: ACPI processor_idle changes, C1 residency time, etc venkatesh.pallipadi
2008-02-01  1:35 ` [patch 1/4] ACPI: Fix acpi_safe_halt usages and interrupt enabling/disabling venkatesh.pallipadi
2008-02-07  7:21   ` Len Brown
2008-02-01  1:35 ` [patch 2/4] ACPI: Use mwait for C1 idle venkatesh.pallipadi
2008-02-07  7:38   ` Len Brown
2008-02-01  1:35 ` [patch 3/4] ACPI, CPU_IDLE: Support C1 idle time accounting venkatesh.pallipadi
2008-02-07  7:38   ` Len Brown
2008-02-01  1:35 ` [patch 4/4] CPUIDLE: Add a poll_idle method into CPU_IDLE venkatesh.pallipadi
2008-02-07  7:38   ` Len Brown [this message]

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=200802070238.14291.lenb@kernel.org \
    --to=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=venkatesh.pallipadi@intel.com \
    /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.