Skip to content

Commit

Permalink
cpu hotplug: Make cpu_active_map synchronization dependency clear
Browse files Browse the repository at this point in the history
This goes on top of the cpu_active_map (take 2) patch.

Currently we depend on the stop_machine to provide nescessesary
synchronization for the cpu_active_map updates.
As Dmitry Adamushko pointed this is fragile and is not much clearer
than the previous scheme. In other words we do not want to depend on
the internal stop machine operation here.
So make the synchronization rules clear by doing synchronize_sched()
after clearing out cpu active bit.

Tested on quad-Core2 with:

   while true; do
      for i in 1 2 3; do
        echo 0 > /sys/devices/system/cpu/cpu$i/online
      done
      for i in 1 2 3; do
        echo 1 > /sys/devices/system/cpu/cpu$i/online
      done
   done
and
   stress -c 200

No lockdep, preempt or other complaints.

Signed-off-by: Max Krasnyansky <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Izabela48 authored and Ingo Molnar committed Jul 18, 2008
1 parent e761b77 commit 39b0fad
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ int __ref cpu_down(unsigned int cpu)

cpu_clear(cpu, cpu_active_map);

/*
* Make sure the all cpus did the reschedule and are not
* using stale version of the cpu_active_map.
* This is not strictly necessary becuase stop_machine()
* that we run down the line already provides the required
* synchronization. But it's really a side effect and we do not
* want to depend on the innards of the stop_machine here.
*/
synchronize_sched();

err = _cpu_down(cpu, 0);

if (cpu_online(cpu))
Expand Down

0 comments on commit 39b0fad

Please sign in to comment.