Skip to contentSkip to conversation

idle patches for 2.6.35

PATCH In review Len Brown 2 participants 18 messages May 28, 2010

Subsystems (4)
lore
Share & tools
lore

Len Brown

author reviewer
#0 lore raw

This patch series responds to all the feedback I've received.

I believe that this series is useful enough and clean enough to merit inclusion upstream.

Please look it over and try it out and let me know what I missed.

thanks,
Len Brown, Intel Open Source Technology Center

ps.
Note that you can get the patch series as a single patch here:
http://ftp.kernel.org/pub/linux/kernel/people/lenb/idle/patches/2.6.34/idle-test-2.6.34.diff.gz

or pull from this git branch
git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6.git idle-test

Note that I updated the series "in place", changing git history. So if you previously pulled from idle-test, you'll want to discard that branch and create a new one based on 2.6.34.

author reviewer
#1 lore raw

PATCH 1/8 cpuidle: fail to register if !CONFIG_CPU_IDLE

From: Len Brown <[email protected]>

---
 include/linux/cpuidle.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
include/linux/cpuidle.h +3 -3
index dcf77fa..f5e6480 100644
@@ -137,16 +137,16 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
 #else
 
 static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
-{return 0;}
+{return -ENODEV; }
 static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
 static inline int cpuidle_register_device(struct cpuidle_device *dev)
-{return 0;}
+{return -ENODEV; }
 static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
 
 static inline void cpuidle_pause_and_lock(void) { }
 static inline void cpuidle_resume_and_unlock(void) { }
 static inline int cpuidle_enable_device(struct cpuidle_device *dev)
-{return 0;}
+{return -ENODEV; }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
 
 #endif
Signature · 1 line
1.6.0.6
author reviewer
#2 lore raw

PATCH 2/8 cpuidle: add cpuidle_unregister_driver() error check

In reply to Len Brown

From: Len Brown <[email protected]>

Assure that cpuidle_unregister_driver() will not clobber the registered driver if unregistered by somebody else.

---
 drivers/cpuidle/driver.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/cpuidle/driver.c +4 -1
index 2257004..826b5c0 100644
@@ -45,8 +45,11 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
  */
 void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 {
-	if (!drv)
+	if (drv != cpuidle_curr_driver) {
+		WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
+			drv->name);
 		return;
+	}
 
 	spin_lock(&cpuidle_driver_lock);
 	cpuidle_curr_driver = NULL;
Signature · 1 line
1.6.0.6
author reviewer
#4 lore raw

PATCH 3/8 cpuidle: make cpuidle_curr_driver static

In reply to Len Brown

From: Len Brown <[email protected]>

cpuidle_register_driver() sets cpuidle_curr_driver cpuidle_unregister_driver() clears cpuidle_curr_driver

We should't expose cpuidle_curr_driver to
potential modification except via these interfaces.
So make it static and create cpuidle_get_driver() to observe it.

---
 drivers/cpuidle/cpuidle.c |   12 +++++++-----
 drivers/cpuidle/cpuidle.h |    1 -
 drivers/cpuidle/driver.c  |   11 ++++++++++-
 drivers/cpuidle/sysfs.c   |    5 +++--
 include/linux/cpuidle.h   |    2 ++
 5 files changed, 22 insertions(+), 9 deletions(-)
drivers/cpuidle/cpuidle.c +7 -5
index 12fdd39..1994885 100644
@@ -156,7 +156,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 
 	if (dev->enabled)
 		return 0;
-	if (!cpuidle_curr_driver || !cpuidle_curr_governor)
+	if (!cpuidle_get_driver() || !cpuidle_curr_governor)
 		return -EIO;
 	if (!dev->state_count)
 		return -EINVAL;
@@ -207,7 +207,7 @@ void cpuidle_disable_device(struct cpuidle_device *dev)
 {
 	if (!dev->enabled)
 		return;
-	if (!cpuidle_curr_driver || !cpuidle_curr_governor)
+	if (!cpuidle_get_driver() || !cpuidle_curr_governor)
 		return;
 
 	dev->enabled = 0;
@@ -271,10 +271,11 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
 {
 	int ret;
 	struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
+	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
 
 	if (!sys_dev)
 		return -EINVAL;
-	if (!try_module_get(cpuidle_curr_driver->owner))
+	if (!try_module_get(cpuidle_driver->owner))
 		return -EINVAL;
 
 	init_completion(&dev->kobj_unregister);
@@ -284,7 +285,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
 	per_cpu(cpuidle_devices, dev->cpu) = dev;
 	list_add(&dev->device_list, &cpuidle_detected_devices);
 	if ((ret = cpuidle_add_sysfs(sys_dev))) {
-		module_put(cpuidle_curr_driver->owner);
+		module_put(cpuidle_driver->owner);
 		return ret;
 	}
 
@@ -325,6 +326,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device);
 void cpuidle_unregister_device(struct cpuidle_device *dev)
 {
 	struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
+	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
 
 	if (dev->registered == 0)
 		return;
@@ -340,7 +342,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
 
 	cpuidle_resume_and_unlock();
 
-	module_put(cpuidle_curr_driver->owner);
+	module_put(cpuidle_driver->owner);
 }
 
 EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
drivers/cpuidle/cpuidle.h +0 -1
index 9476ba3..33e50d5 100644
@@ -9,7 +9,6 @@
 
 /* For internal use only */
 extern struct cpuidle_governor *cpuidle_curr_governor;
-extern struct cpuidle_driver *cpuidle_curr_driver;
 extern struct list_head cpuidle_governors;
 extern struct list_head cpuidle_detected_devices;
 extern struct mutex cpuidle_lock;
drivers/cpuidle/driver.c +10 -1
index 826b5c0..fd1601e 100644
@@ -14,7 +14,7 @@
 
 #include "cpuidle.h"
 
-struct cpuidle_driver *cpuidle_curr_driver;
+static struct cpuidle_driver *cpuidle_curr_driver;
 DEFINE_SPINLOCK(cpuidle_driver_lock);
 
 /**
@@ -40,6 +40,15 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
 EXPORT_SYMBOL_GPL(cpuidle_register_driver);
 
 /**
+ * cpuidle_get_driver - return the current driver
+ */
+struct cpuidle_driver *cpuidle_get_driver(void)
+{
+	return cpuidle_curr_driver;
+}
+EXPORT_SYMBOL_GPL(cpuidle_get_driver);
+
+/**
  * cpuidle_unregister_driver - unregisters a driver
  * @drv: the driver
  */
drivers/cpuidle/sysfs.c +3 -2
index 0ba9c8b..0310ffa 100644
@@ -47,10 +47,11 @@ static ssize_t show_current_driver(struct sysdev_class *class,
 				   char *buf)
 {
 	ssize_t ret;
+	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
 
 	spin_lock(&cpuidle_driver_lock);
-	if (cpuidle_curr_driver)
-		ret = sprintf(buf, "%s\n", cpuidle_curr_driver->name);
+	if (cpuidle_driver)
+		ret = sprintf(buf, "%s\n", cpuidle_driver->name);
 	else
 		ret = sprintf(buf, "none\n");
 	spin_unlock(&cpuidle_driver_lock);
include/linux/cpuidle.h +2 -0
index f5e6480..55215cc 100644
@@ -125,6 +125,7 @@ struct cpuidle_driver {
 #ifdef CONFIG_CPU_IDLE
 
 extern int cpuidle_register_driver(struct cpuidle_driver *drv);
+struct cpuidle_driver *cpuidle_get_driver(void);
 extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
 extern int cpuidle_register_device(struct cpuidle_device *dev);
 extern void cpuidle_unregister_device(struct cpuidle_device *dev);
@@ -138,6 +139,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
 
 static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
 {return -ENODEV; }
+static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; }
 static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
 static inline int cpuidle_register_device(struct cpuidle_device *dev)
 {return -ENODEV; }
Signature · 1 line
1.6.0.6
author reviewer
#5 lore raw

PATCH 4/8 ACPI: allow a native cpuidle driver to displace ACPI

In reply to Len Brown

From: Len Brown <[email protected]>

The ACPI driver would fail probe when it found that another driver had previously registered with cpuidle.

But this is a natural situation, as a native hardware cpuidle driver should be able to bind instead of ACPI, and the ACPI processor driver should be able to handle yielding control of C-states while still handling P-states and T-states.

Add a KERN_DEBUG line showing when acpi_idle does successfully register.

---
 drivers/acpi/processor_driver.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/processor_driver.c +6 -5
index 5675d97..deefa85 100644
@@ -616,7 +616,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
 	acpi_processor_get_limit_info(pr);
 
 
-	acpi_processor_power_init(pr, device);
+	if (cpuidle_get_driver() == &acpi_idle_driver)
+		acpi_processor_power_init(pr, device);
 
 	pr->cdev = thermal_cooling_device_register("Processor", device,
 						&processor_cooling_ops);
@@ -920,9 +921,10 @@ static int __init acpi_processor_init(void)
 	if (!acpi_processor_dir)
 		return -ENOMEM;
 #endif
-	result = cpuidle_register_driver(&acpi_idle_driver);
-	if (result < 0)
-		goto out_proc;
+
+	if (!cpuidle_register_driver(&acpi_idle_driver))
+		printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
+			acpi_idle_driver.name);
 
 	result = acpi_bus_register_driver(&acpi_processor_driver);
 	if (result < 0)
@@ -941,7 +943,6 @@ static int __init acpi_processor_init(void)
 out_cpuidle:
 	cpuidle_unregister_driver(&acpi_idle_driver);
 
-out_proc:
 #ifdef CONFIG_ACPI_PROCFS
 	remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
 #endif
Signature · 1 line
1.6.0.6
author reviewer
#6 lore raw

PATCH 5/8 sched: clarify commment for TS_POLLING

In reply to Len Brown

From: Len Brown <[email protected]>

TS_POLLING set tells the scheduler an idle_task will poll need_resched() to look for work.

TS_POLLING clear tells resched_task() and wake_up_idle_cpu() that the remote CPU's idle_task is now sleeping in idle, and thus requires a reschedule interrupt notice work.

Update the description of TS_POLLING to reflect how it works. "idle task polling need_resched, skip sending interrupt"

---
 arch/x86/include/asm/thread_info.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/thread_info.h +2 -2
index e0d2890..8121869 100644
@@ -241,8 +241,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TS_USEDFPU		0x0001	/* FPU was used by this task
 					   this quantum (SMP) */
 #define TS_COMPAT		0x0002	/* 32bit syscall active (64BIT)*/
-#define TS_POLLING		0x0004	/* true if in idle loop
-					   and not sleeping */
+#define TS_POLLING		0x0004	/* idle task polling need_resched,
+					   skip sending interrupt */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal() */
 #define TS_XSAVE		0x0010	/* Use xsave/xrstor */
 
Signature · 1 line
1.6.0.6
author reviewer
#8 lore raw

PATCH 6/8 acpi_pad: uses MONITOR/MWAIT, so it doesn't need to clear TS_POLLING

In reply to Len Brown

From: Len Brown <[email protected]>

api_pad exclusively uses MONITOR/MWAIT to sleep in idle, so it does not need the wakeup IPI during idle sleep that is provoked by clearing TS_POLLING.

---
 drivers/acpi/acpi_pad.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
drivers/acpi/acpi_pad.c +0 -9
index 6212213..7edf053 100644
@@ -168,13 +168,6 @@ static int power_saving_thread(void *data)
 
 		do_sleep = 0;
 
-		current_thread_info()->status &= ~TS_POLLING;
-		/*
-		 * TS_POLLING-cleared state must be visible before we test
-		 * NEED_RESCHED:
-		 */
-		smp_mb();
-
 		expire_time = jiffies + HZ * (100 - idle_pct) / 100;
 
 		while (!need_resched()) {
@@ -200,8 +193,6 @@ static int power_saving_thread(void *data)
 			}
 		}
 
-		current_thread_info()->status |= TS_POLLING;
-
 		/*
 		 * current sched_rt has threshold for rt task running time.
 		 * When a rt task uses 95% CPU time, the rt thread will be
Signature · 1 line
1.6.0.6
author reviewer
#10 lore raw

PATCH 7/8 ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

In reply to Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

Cc Venkatesh Pallipadi <[email protected]>
---
 drivers/acpi/processor_idle.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
drivers/acpi/processor_idle.c +16 -12
index 5939e7f..a4166e2 100644
@@ -881,6 +881,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 		return(acpi_idle_enter_c1(dev, state));
 
 	local_irq_disable();
+
 	if (cx->entry_method != ACPI_CSTATE_FFH) {
 		current_thread_info()->status &= ~TS_POLLING;
 		/*
@@ -888,12 +889,12 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 		 * NEED_RESCHED:
 		 */
 		smp_mb();
-	}
 
-	if (unlikely(need_resched())) {
-		current_thread_info()->status |= TS_POLLING;
-		local_irq_enable();
-		return 0;
+		if (unlikely(need_resched())) {
+			current_thread_info()->status |= TS_POLLING;
+			local_irq_enable();
+			return 0;
+		}
 	}
 
 	/*
@@ -918,7 +919,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
 
 	local_irq_enable();
-	current_thread_info()->status |= TS_POLLING;
+	if (cx->entry_method != ACPI_CSTATE_FFH)
+		current_thread_info()->status |= TS_POLLING;
 
 	cx->usage++;
 
@@ -968,6 +970,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	}
 
 	local_irq_disable();
+
 	if (cx->entry_method != ACPI_CSTATE_FFH) {
 		current_thread_info()->status &= ~TS_POLLING;
 		/*
@@ -975,12 +978,12 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 		 * NEED_RESCHED:
 		 */
 		smp_mb();
-	}
 
-	if (unlikely(need_resched())) {
-		current_thread_info()->status |= TS_POLLING;
-		local_irq_enable();
-		return 0;
+		if (unlikely(need_resched())) {
+			current_thread_info()->status |= TS_POLLING;
+			local_irq_enable();
+			return 0;
+		}
 	}
 
 	acpi_unlazy_tlb(smp_processor_id());
@@ -1032,7 +1035,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
 
 	local_irq_enable();
-	current_thread_info()->status |= TS_POLLING;
+	if (cx->entry_method != ACPI_CSTATE_FFH)
+		current_thread_info()->status |= TS_POLLING;
 
 	cx->usage++;
 
Signature · 1 line
1.6.0.6
author reviewer
#17 lore raw

PATCH 8/8 intel_idle: native hardware cpuidle driver for latest Intel processors

In reply to Len Brown

From: Len Brown <[email protected]>

This EXPERIMENTAL driver supersedes acpi_idle on Intel Atom Processors, Intel Core i3/i5/i7 Processors and associated Intel Xeon processors.

It does not support the Intel Core2 processor or earlier.

For kernels configured with ACPI, CONFIG_INTEL_IDLE=y allows intel_idle to probe before the ACPI processor driver. In this case, note that you can boot with "intel_idle.max_cstate=0" to disable intel_idle and to fall back on ACPI's "acpi_idle".

Typical Linux distributions load ACPI processor module early, making CONFIG_INTEL_IDLE=m not useful on ACPI platforms.

intel_idle probes all processors at module_init time. Processors that are hot-added later will be limited to using C1 in idle.

---
 MAINTAINERS                     |    7 +
 drivers/Makefile                |    2 +-
 drivers/acpi/processor_driver.c |    6 +-
 drivers/idle/Kconfig            |   11 +
 drivers/idle/Makefile           |    1 +
 drivers/idle/intel_idle.c       |  461 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 486 insertions(+), 2 deletions(-)
 create mode 100755 drivers/idle/intel_idle.c
MAINTAINERS +7 -0
index d329b05..276e79b 100644
@@ -2850,6 +2850,13 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
 S:	Maintained
 F:	drivers/input/
 
+INTEL IDLE DRIVER
+M:	Len Brown <[email protected]>
+L:	[email protected]
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6.git
+S:	Supported
+F:	drivers/idle/intel_idle.c
+
 INTEL FRAMEBUFFER DRIVER (excluding 810 and 815)
 M:	Maik Broemme <[email protected]>
 L:	[email protected]
drivers/Makefile +1 -1
index f42a030..91874e0 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_PCI)		+= pci/
 obj-$(CONFIG_PARISC)		+= parisc/
 obj-$(CONFIG_RAPIDIO)		+= rapidio/
 obj-y				+= video/
+obj-y				+= idle/
 obj-$(CONFIG_ACPI)		+= acpi/
 obj-$(CONFIG_SFI)		+= sfi/
 # PnP must come after ACPI since it will eventually need to check if acpi
@@ -91,7 +92,6 @@ obj-$(CONFIG_EISA)		+= eisa/
 obj-y				+= lguest/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_CPU_IDLE)		+= cpuidle/
-obj-y				+= idle/
 obj-$(CONFIG_MMC)		+= mmc/
 obj-$(CONFIG_MEMSTICK)		+= memstick/
 obj-$(CONFIG_NEW_LEDS)		+= leds/
drivers/acpi/processor_driver.c +5 -1
index deefa85..b1034a9 100644
@@ -922,9 +922,13 @@ static int __init acpi_processor_init(void)
 		return -ENOMEM;
 #endif
 
-	if (!cpuidle_register_driver(&acpi_idle_driver))
+	if (!cpuidle_register_driver(&acpi_idle_driver)) {
 		printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
 			acpi_idle_driver.name);
+	} else {
+		printk(KERN_DEBUG "ACPI: acpi_idle yielding to %s",
+			cpuidle_get_driver()->name);
+	}
 
 	result = acpi_bus_register_driver(&acpi_processor_driver);
 	if (result < 0)
drivers/idle/Kconfig +11 -0
index f15e90a..fb5c518 100644
@@ -1,3 +1,14 @@
+config INTEL_IDLE
+	tristate "Cpuidle Driver for Intel Processors"
+	depends on CPU_IDLE
+	depends on X86
+	depends on CPU_SUP_INTEL
+	depends on EXPERIMENTAL
+	help
+	  Enable intel_idle, a cpuidle driver that includes knowledge of
+	  native Intel hardware idle features.  The acpi_idle driver
+	  can be configured at the same time, in order to handle
+	  processors intel_idle does not support.
 
 menu "Memory power savings"
 depends on X86_64
drivers/idle/Makefile +1 -0
index 5f68fc3..23d295c 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_I7300_IDLE)			+= i7300_idle.o
+obj-$(CONFIG_INTEL_IDLE)			+= intel_idle.o
 
drivers/idle/intel_idle.c new file +461 -0

461 lines not on this page · raw message

Signature · 1 line
1.6.0.6
author reviewer
#3 lore raw

PATCH 2/8 cpuidle: add cpuidle_unregister_driver() error check

In reply to Len Brown

From: Len Brown <[email protected]>

Assure that cpuidle_unregister_driver() will not clobber the registered driver if unregistered by somebody else.

---
 drivers/cpuidle/driver.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/cpuidle/driver.c +4 -1
index 2257004..826b5c0 100644
@@ -45,8 +45,11 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
  */
 void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 {
-	if (!drv)
+	if (drv != cpuidle_curr_driver) {
+		WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
+			drv->name);
 		return;
+	}
 
 	spin_lock(&cpuidle_driver_lock);
 	cpuidle_curr_driver = NULL;
Signature · 1 line
1.6.0.6
author reviewer
#7 lore raw

PATCH 5/8 sched: clarify commment for TS_POLLING

In reply to Len Brown

From: Len Brown <[email protected]>

TS_POLLING set tells the scheduler an idle_task will poll need_resched() to look for work.

TS_POLLING clear tells resched_task() and wake_up_idle_cpu() that the remote CPU's idle_task is now sleeping in idle, and thus requires a reschedule interrupt notice work.

Update the description of TS_POLLING to reflect how it works. "idle task polling need_resched, skip sending interrupt"

---
 arch/x86/include/asm/thread_info.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/thread_info.h +2 -2
index e0d2890..8121869 100644
@@ -241,8 +241,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TS_USEDFPU		0x0001	/* FPU was used by this task
 					   this quantum (SMP) */
 #define TS_COMPAT		0x0002	/* 32bit syscall active (64BIT)*/
-#define TS_POLLING		0x0004	/* true if in idle loop
-					   and not sleeping */
+#define TS_POLLING		0x0004	/* idle task polling need_resched,
+					   skip sending interrupt */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal() */
 #define TS_XSAVE		0x0010	/* Use xsave/xrstor */
 
Signature · 1 line
1.6.0.6
author reviewer
#9 lore raw

PATCH 6/8 acpi_pad: uses MONITOR/MWAIT, so it doesn't need to clear TS_POLLING

In reply to Len Brown

From: Len Brown <[email protected]>

api_pad exclusively uses MONITOR/MWAIT to sleep in idle, so it does not need the wakeup IPI during idle sleep that is provoked by clearing TS_POLLING.

---
 drivers/acpi/acpi_pad.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
drivers/acpi/acpi_pad.c +0 -9
index 6212213..7edf053 100644
@@ -168,13 +168,6 @@ static int power_saving_thread(void *data)
 
 		do_sleep = 0;
 
-		current_thread_info()->status &= ~TS_POLLING;
-		/*
-		 * TS_POLLING-cleared state must be visible before we test
-		 * NEED_RESCHED:
-		 */
-		smp_mb();
-
 		expire_time = jiffies + HZ * (100 - idle_pct) / 100;
 
 		while (!need_resched()) {
@@ -200,8 +193,6 @@ static int power_saving_thread(void *data)
 			}
 		}
 
-		current_thread_info()->status |= TS_POLLING;
-
 		/*
 		 * current sched_rt has threshold for rt task running time.
 		 * When a rt task uses 95% CPU time, the rt thread will be
Signature · 1 line
1.6.0.6
#11 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

In reply to Len Brown
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

Thanks,
Venki

#12 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

In reply to Len Brown
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

Thanks,
Venki

author reviewer
#13 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

Quoted 24 lines · Venkatesh Pallipadi
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 8 lines
Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

I don't know if the write is more expensive than the read and branch. In the scheme of things, these things are free and it is the IO accesses and locks in the idle path that take time.

But when I saw this code fragment incorrectly copied into the new sfi_idle driver, I decided it was time to change it to make logical sense to the reader.

thanks,
-Len Brown, Intel Open Source Technology Center

author reviewer
#14 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

In reply to Venkatesh Pallipadi
Quoted 24 lines · Venkatesh Pallipadi
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 8 lines
Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

I don't know if the write is more expensive than the read and branch. In the scheme of things, these things are free and it is the IO accesses and locks in the idle path that take time.

But when I saw this code fragment incorrectly copied into the new sfi_idle driver, I decided it was time to change it to make logical sense to the reader.

thanks,
-Len Brown, Intel Open Source Technology Center

#15 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

Quoted 35 lines · Len Brown
Quoted 24 lines · Venkatesh Pallipadi
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 8 lines
Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

Quoted 4 lines

I don't know if the write is more expensive than the read and branch. In the scheme of things, these things are free and it is the IO accesses and locks in the idle path that take time.

#16 lore raw

Re: [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

In reply to Len Brown
Quoted 35 lines · Len Brown
Quoted 24 lines · Venkatesh Pallipadi
Quoted 15 lines · Len Brown

From: Len Brown <[email protected]>

commit d306ebc28649b89877a22158fe0076f06cc46f60
(ACPI: Be in TS_POLLING state during mwait based C-state entry) fixed an important power & performance issue where ACPI c2 and c3 C-states were clearing TS_POLLING even when using MWAIT (ACPI_STATE_FFH). That bug had been causing us to receive redundant scheduling interrups when we had already been woken up by MONITOR/MWAIT.

Following up on that...

In the MWAIT case, we don't have to subsequently
check need_resched(), as that c heck was there
for the TS_POLLING-clearing case.

Quoted 5 lines

Note that not only does the cpuidle calling function already check need_resched() before calling us, the low-level entry into monitor/mwait calls it twice -- guaranteeing that a write to the trigger address can not go un-noticed.

Ack this part of the change.

Quoted 8 lines
Quoted 2 lines

Also, in this case, we don't have to set TS_POLLING when we wake, because we never cleared it.

I thought about this part of the change while working on the original patch. But decided to leave the set to be done unconditionally as in this case we are replacing "one write" by either "one read and one jump" or "one read and one write" and I am not sure we gain much by that.

Quoted 4 lines

I don't know if the write is more expensive than the read and branch. In the scheme of things, these things are free and it is the IO accesses and locks in the idle path that take time.