Skip to content

Commit de5b55c

Browse files
committed
stop_machine: Use raw spinlocks
Use raw-locks in stop_machine() to allow locking in irq-off and preempt-disabled regions on -RT. This also documents the possible locking context in general. [bigeasy: update patch description.] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://lkml.kernel.org/r/20180423191635.6014-1-bigeasy@linutronix.de
1 parent 02acc80 commit de5b55c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎kernel/stop_machine.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct cpu_stop_done {
3636
struct cpu_stopper {
3737
struct task_struct *thread;
3838

39-
spinlock_t lock;
39+
raw_spinlock_t lock;
4040
bool enabled; /* is this stopper enabled? */
4141
struct list_head works; /* list of pending works */
4242

@@ -78,13 +78,13 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
7878
unsigned long flags;
7979
bool enabled;
8080

81-
spin_lock_irqsave(&stopper->lock, flags);
81+
raw_spin_lock_irqsave(&stopper->lock, flags);
8282
enabled = stopper->enabled;
8383
if (enabled)
8484
__cpu_stop_queue_work(stopper, work);
8585
else if (work->done)
8686
cpu_stop_signal_done(work->done);
87-
spin_unlock_irqrestore(&stopper->lock, flags);
87+
raw_spin_unlock_irqrestore(&stopper->lock, flags);
8888

8989
return enabled;
9090
}
@@ -231,8 +231,8 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
231231
struct cpu_stopper *stopper2 = per_cpu_ptr(&cpu_stopper, cpu2);
232232
int err;
233233
retry:
234-
spin_lock_irq(&stopper1->lock);
235-
spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
234+
raw_spin_lock_irq(&stopper1->lock);
235+
raw_spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
236236

237237
err = -ENOENT;
238238
if (!stopper1->enabled || !stopper2->enabled)
@@ -255,8 +255,8 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
255255
__cpu_stop_queue_work(stopper1, work1);
256256
__cpu_stop_queue_work(stopper2, work2);
257257
unlock:
258-
spin_unlock(&stopper2->lock);
259-
spin_unlock_irq(&stopper1->lock);
258+
raw_spin_unlock(&stopper2->lock);
259+
raw_spin_unlock_irq(&stopper1->lock);
260260

261261
if (unlikely(err == -EDEADLK)) {
262262
while (stop_cpus_in_progress)
@@ -448,9 +448,9 @@ static int cpu_stop_should_run(unsigned int cpu)
448448
unsigned long flags;
449449
int run;
450450

451-
spin_lock_irqsave(&stopper->lock, flags);
451+
raw_spin_lock_irqsave(&stopper->lock, flags);
452452
run = !list_empty(&stopper->works);
453-
spin_unlock_irqrestore(&stopper->lock, flags);
453+
raw_spin_unlock_irqrestore(&stopper->lock, flags);
454454
return run;
455455
}
456456

@@ -461,13 +461,13 @@ static void cpu_stopper_thread(unsigned int cpu)
461461

462462
repeat:
463463
work = NULL;
464-
spin_lock_irq(&stopper->lock);
464+
raw_spin_lock_irq(&stopper->lock);
465465
if (!list_empty(&stopper->works)) {
466466
work = list_first_entry(&stopper->works,
467467
struct cpu_stop_work, list);
468468
list_del_init(&work->list);
469469
}
470-
spin_unlock_irq(&stopper->lock);
470+
raw_spin_unlock_irq(&stopper->lock);
471471

472472
if (work) {
473473
cpu_stop_fn_t fn = work->fn;
@@ -541,7 +541,7 @@ static int __init cpu_stop_init(void)
541541
for_each_possible_cpu(cpu) {
542542
struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
543543

544-
spin_lock_init(&stopper->lock);
544+
raw_spin_lock_init(&stopper->lock);
545545
INIT_LIST_HEAD(&stopper->works);
546546
}
547547

0 commit comments

Comments
 (0)