Re: [PATCH v5 tip/core/rcu 15/16] rcu: Make RCU-tasks wait for idle tasks

From: Peter Zijlstra
Date: Wed Aug 13 2014 - 13:24:27 EST


On Wed, Aug 13, 2014 at 04:42:19PM +0200, Peter Zijlstra wrote:
> Auditing all idle functions will be somewhat of a pain, but its entirely
> doable. Looking at this stuff, it appears we can clean it up massively;
> see how the generic cpuidle code already has the broadcast logic in, so
> we can remove that from the drivers by setting the right flags.
>
> We can similarly pull out the leave_mm() call by adding a
> CPUIDLE_FLAG_TLB_FLUSH. At which point all we'd need to do is mark the
> intel_idle (and all other cpuidle_state::enter functions with __notrace.

This removes the broadcast stuff from intel_idle.c; processor_idle.c hurts
my brain, but something similar should be possible.

---
drivers/idle/intel_idle.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 4d140bbbe100..6613d4ee60ce 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -508,11 +508,8 @@ static int intel_idle(struct cpuidle_device *dev,
unsigned long ecx = 1; /* break on interrupt flag */
struct cpuidle_state *state = &drv->states[index];
unsigned long eax = flg2MWAIT(state->flags);
- unsigned int cstate;
int cpu = smp_processor_id();

- cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) + 1;
-
/*
* leave_mm() to avoid costly and often unnecessary wakeups
* for flushing the user TLB's associated with the active mm.
@@ -520,14 +517,8 @@ static int intel_idle(struct cpuidle_device *dev,
if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
leave_mm(cpu);

- if (!(lapic_timer_reliable_states & (1 << (cstate))))
- clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
-
mwait_idle_with_hints(eax, ecx);

- if (!(lapic_timer_reliable_states & (1 << (cstate))))
- clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
-
return index;
}

@@ -670,6 +661,7 @@ static int __init intel_idle_probe(void)
{
unsigned int eax, ebx, ecx;
const struct x86_cpu_id *id;
+ int i;

if (max_cstate == 0) {
pr_debug(PREFIX "disabled\n");
@@ -705,6 +697,15 @@ static int __init intel_idle_probe(void)
else
on_each_cpu(__setup_broadcast_timer, (void *)true, 1);

+ for (i = 0; cpuidle_state_table[i].enter; i++) {
+ struct cpuidle_state *state = &cpuidle_state_table[i];
+ int cstate = ((flg2MWAIT(state->flags) >> MWAIT_SUBSTATE_SIZE) &
+ MWAIT_CSTATE_MASK) + 1;
+
+ if (!(lapic_timer_reliable_states & (1 << cstate)))
+ state->flags |= CPUIDLE_FLAG_TIMER_STOP;
+ }
+
pr_debug(PREFIX "v" INTEL_IDLE_VERSION
" model 0x%X\n", boot_cpu_data.x86_model);

Attachment: pgpRW677XI5OL.pgp
Description: PGP signature