diff mbox series

[4.19,stable-rt] tasklet: Fix UP case for tasklet CHAINED state

Message ID 7642da1ef2578601d8c2b7bb739b0f8451e69bed.camel@kernel.org
State New
Headers show
Series [4.19,stable-rt] tasklet: Fix UP case for tasklet CHAINED state | expand

Commit Message

Tom Zanussi June 9, 2020, 4:21 p.m. UTC
4.19 stable-rt commit 62d0a2a30cd0 (tasklet: Address a race resulting in
double-enqueue) addresses a problem that can result in a tasklet being
enqueued on two cpus at the same time by combining the RUN flag with a
new CHAINED flag, and relies on the combination to be present in order
to zero it out, which can never happen on !SMP because the RUN flag
is SMP-only.

So make sure the above commit is only applied for the SMP case.

Signed-off-by: Tom Zanussi <zanussi@kernel.org>
---
 kernel/softirq.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 73dae64bfc9c..4f37a6173ab9 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -947,10 +947,12 @@  static void __tasklet_schedule_common(struct tasklet_struct *t,
 	 * is locked before adding it to the list.
 	 */
 	if (test_bit(TASKLET_STATE_SCHED, &t->state)) {
+#if defined(CONFIG_SMP)
 		if (test_and_set_bit(TASKLET_STATE_CHAINED, &t->state)) {
 			tasklet_unlock(t);
 			return;
 		}
+#endif
 		t->next = NULL;
 		*head->tail = t;
 		head->tail = &(t->next);
@@ -1044,7 +1046,11 @@  static void tasklet_action_common(struct softirq_action *a,
 again:
 		t->func(t->data);
 
+#if !defined(CONFIG_SMP)
+		while (!tasklet_tryunlock(t)) {
+#else
 		while (cmpxchg(&t->state, TASKLET_STATEF_RC, 0) != TASKLET_STATEF_RC) {
+#endif
 			/*
 			 * If it got disabled meanwhile, bail out:
 			 */