[PATCH 3/4] x86: Extend IPIless wake to C1_mwait and poll_idle

From: Venkatesh Pallipadi
Date: Fri Feb 24 2012 - 17:34:09 EST


poll_idle(), mwait_idle() [which is used for C1 mwait] and any other
polling based idle loops can also use the IPIless wakeup logic added
with mwait_idle_with_hints() in the earlier patch.

Signed-off-by: Venkatesh Pallipadi <venki@xxxxxxxxxx>
---
arch/x86/kernel/process.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 99a8109..43bb0a5 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -22,6 +22,7 @@
#include <asm/uaccess.h>
#include <asm/i387.h>
#include <asm/debugreg.h>
+#include <asm/ipiless_wake.h>

struct kmem_cache *task_xstate_cachep;
EXPORT_SYMBOL_GPL(task_xstate_cachep);
@@ -445,7 +446,8 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
/* Default MONITOR/MWAIT with no hints, used for default C1 state */
static void mwait_idle(void)
{
- if (!need_resched()) {
+ enter_ipiless_idle();
+ if (!is_ipiless_wakeup_pending()) {
trace_power_start(POWER_CSTATE, 1, smp_processor_id());
trace_cpu_idle(1, smp_processor_id());
if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
@@ -453,7 +455,7 @@ static void mwait_idle(void)

__monitor((void *)&current_thread_info()->flags, 0, 0);
smp_mb();
- if (!need_resched())
+ if (!is_ipiless_wakeup_pending())
__sti_mwait(0, 0);
else
local_irq_enable();
@@ -461,6 +463,7 @@ static void mwait_idle(void)
trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
} else
local_irq_enable();
+ exit_ipiless_idle();
}

/*
@@ -470,13 +473,15 @@ static void mwait_idle(void)
*/
static void poll_idle(void)
{
+ enter_ipiless_idle();
trace_power_start(POWER_CSTATE, 0, smp_processor_id());
trace_cpu_idle(0, smp_processor_id());
local_irq_enable();
- while (!need_resched())
+ while (!is_ipiless_wakeup_pending())
cpu_relax();
trace_power_end(smp_processor_id());
trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
+ exit_ipiless_idle();
}

/*
--
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/