]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
softirq: use bit waits instead of var waits.
authorNeilBrown <neilb@suse.de>
Wed, 25 Sep 2024 05:31:44 +0000 (15:31 +1000)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 7 Oct 2024 07:28:39 +0000 (09:28 +0200)
The waiting in softirq.c is always waiting for a bit to be cleared.
This makes the bit wait functions seem more suitable.
By switching over we can rid of all explicit barriers.  We also use
wait_on_bit_lock() to avoid an explicit loop.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240925053405.3960701-8-neilb@suse.de
kernel/softirq.c

index d082e7840f88027a0972e301ec2c455dd3bc662f..b756d6b3fd0966b55161dee3a37af40af70fc41b 100644 (file)
@@ -748,10 +748,8 @@ EXPORT_SYMBOL(__tasklet_hi_schedule);
 
 static bool tasklet_clear_sched(struct tasklet_struct *t)
 {
-       if (test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) {
-               wake_up_var(&t->state);
+       if (test_and_clear_wake_up_bit(TASKLET_STATE_SCHED, &t->state))
                return true;
-       }
 
        WARN_ONCE(1, "tasklet SCHED state not set: %s %pS\n",
                  t->use_callback ? "callback" : "func",
@@ -871,8 +869,7 @@ void tasklet_kill(struct tasklet_struct *t)
        if (in_interrupt())
                pr_notice("Attempt to kill tasklet from interrupt\n");
 
-       while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
-               wait_var_event(&t->state, !test_bit(TASKLET_STATE_SCHED, &t->state));
+       wait_on_bit_lock(&t->state, TASKLET_STATE_SCHED, TASK_UNINTERRUPTIBLE);
 
        tasklet_unlock_wait(t);
        tasklet_clear_sched(t);
@@ -882,16 +879,13 @@ EXPORT_SYMBOL(tasklet_kill);
 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
 void tasklet_unlock(struct tasklet_struct *t)
 {
-       smp_mb__before_atomic();
-       clear_bit(TASKLET_STATE_RUN, &t->state);
-       smp_mb__after_atomic();
-       wake_up_var(&t->state);
+       clear_and_wake_up_bit(TASKLET_STATE_RUN, &t->state);
 }
 EXPORT_SYMBOL_GPL(tasklet_unlock);
 
 void tasklet_unlock_wait(struct tasklet_struct *t)
 {
-       wait_var_event(&t->state, !test_bit(TASKLET_STATE_RUN, &t->state));
+       wait_on_bit(&t->state, TASKLET_STATE_RUN, TASK_UNINTERRUPTIBLE);
 }
 EXPORT_SYMBOL_GPL(tasklet_unlock_wait);
 #endif