ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, May 28, 2010 - 4:59 pm

Gitweb:     http://git.kernel.org/linus/02cf4f9808382af7265cafc33dc86ec5875526aa
Commit:     02cf4f9808382af7265cafc33dc86ec5875526aa
Parent:     a7d27c37533524e23bbdc9ba1d78e3241b7483ea
Author:     Len Brown <len.brown@intel.com>
AuthorDate: Mon May 24 14:27:44 2010 -0400
Committer:  Len Brown <len.brown@intel.com>
CommitDate: Fri May 28 13:58:57 2010 -0400

    ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case
    
    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.
    
    Signed-off-by: Len Brown <len.brown@intel.com>
    Acked-by: Venkatesh Pallipadi <venki@google.com>
---
 drivers/acpi/processor_idle.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 5939e7f..a4166e2 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -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++;
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case, Linux Kernel Mailing ..., (Fri May 28, 4:59 pm)