Skip to content

RFC stop_machine: kill stop_cpus_mutex and stop_cpus_lock

Oleg Nesterov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6stop_machine: move cpu_stopper_task and stop_cpus_work into struct cpu_stopperkernel/stop_machine.c+9 -80 replies
2/6stop_machine: don't do for_each_cpu() twice in queue_stop_cpus_work()kernel/stop_machine.c+7 -100 replies
3/6stop_machine: introduce stop_work_alloc() and stop_work_free()kernel/stop_machine.c+50 -00 replies
4/6stop_machine: kill stop_cpus_mutexkernel/stop_machine.c+6 -100 replies
5/6stop_machine: change stop_two_cpus() just use stop_cpu(), kill lg_double_lock/unlockinclude/linux/lglock.h kernel/locking/lglock.c kernel/stop_machine.c+11 -800 replies
6/6stop_machine: optimize stop_work_alloc()kernel/stop_machine.c+43 -41 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/6] stop_machine: kill stop_cpus_mutex and stop_cpus_lock
Quoted 15 lines · Peter Zijlstra
Quoted 13 lines · Oleg Nesterov
	lock_stop_cpus_works(cpumask)
	{
		for_each_cpu(cpu, cpumask)
			mutex_lock(per_cpu(cpu_stopper_task, cpu).work_mutex);
	}

	unlock_stop_cpus_works(cpumask)
	{
		for_each_cpu(cpu, cpumask)
			mutex_lock(...);
	}
Quoted 4 lines
Quoted 2 lines

which should be used instead of stop_cpus_mutex. After this change stop_two_cpus() can just use stop_cpus().

Right, lockdep annotating that will be 'interesting' though.

Sure, and this is too inefficient, this is only to explain what I mean.

How about this series? Untested. For review.

Quoted 2 lines

And
stop_two_cpus() then has the problem of allocating a cpumask.

Yes, but we can avoid this, see the changelog in 5/6.

Quoted 2 lines

Simpler to
let it keep 'abuse' the queueing spinlock in there.

Not sure.

And note that this series kills stop_cpus_mutex, so that multiple stop_cpus()'s / stop_machine()'s can run in parallel if cpumask's do not overlap.

Note also the changelog in 6/6, we can simplify + optimize this code a bit more.

What do you think?

Oleg.

 include/linux/lglock.h  |    5 -
 kernel/locking/lglock.c |   22 -----
 kernel/stop_machine.c   |  197 ++++++++++++++++++++++++++++-------------------
 3 files changed, 119 insertions(+), 105 deletions(-)