lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC tip/core/rcu 3/4] cpu: Make CPU-offline idle-loop transition point more precise
Date
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

This commit uses a per-CPU variable to make the CPU-offline code path
through the idle loop more precise, so that the outgoing CPU is
guaranteed to make it into the idle loop before it is powered off.
This commit is in preparation for putting the RCU offline-handling
code on this code path, which will eliminate the magic one-jiffy
wait that RCU uses as the maximum time for an outgoing CPU to get
all the way through the scheduler.

The magic one-jiffy wait for incoming CPUs remains a separate issue.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/cpu.c | 6 +++++-
kernel/sched/idle.c | 7 ++++++-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 1972b161c61e..9a4f0669a024 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -343,6 +343,8 @@ static int __ref take_cpu_down(void *_param)
return 0;
}

+DECLARE_PER_CPU(bool, cpu_dead_idle);
+
/* Requires cpu_add_remove_lock to be held */
static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
{
@@ -408,8 +410,10 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
*
* Wait for the stop thread to go away.
*/
- while (!idle_cpu(cpu))
+ while (!per_cpu(cpu_dead_idle, cpu))
cpu_relax();
+ smp_mb(); /* Read from cpu_dead_idle before __cpu_die(). */
+ per_cpu(cpu_dead_idle, cpu) = false;

/* This actually kills the CPU. */
__cpu_die(cpu);
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index c47fce75e666..42b51022d198 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -181,6 +181,8 @@ exit_idle:
start_critical_timings();
}

+DEFINE_PER_CPU(bool, cpu_dead_idle);
+
/*
* Generic idle loop implementation
*
@@ -205,8 +207,11 @@ static void cpu_idle_loop(void)
check_pgt_cache();
rmb();

- if (cpu_is_offline(smp_processor_id()))
+ if (cpu_is_offline(smp_processor_id())) {
+ smp_mb(); /* all activity before dead. */
+ this_cpu_write(cpu_dead_idle, true);
arch_cpu_idle_dead();
+ }

local_irq_disable();
arch_cpu_idle_enter();
--
1.8.1.5


\
 
 \ /
  Last update: 2015-01-30 01:41    [W:0.068 / U:1.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site