* [4.19 stable-rt PATCH] tasklet: Fix UP case for tasklet CHAINED state
@ 2020-06-09 16:21 Tom Zanussi
2020-06-09 16:38 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 3+ messages in thread
From: Tom Zanussi @ 2020-06-09 16:21 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sebastian Andrzej Siewior, LKML
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 --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:
*/
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [4.19 stable-rt PATCH] tasklet: Fix UP case for tasklet CHAINED state
2020-06-09 16:21 [4.19 stable-rt PATCH] tasklet: Fix UP case for tasklet CHAINED state Tom Zanussi
@ 2020-06-09 16:38 ` Sebastian Andrzej Siewior
2020-06-09 16:59 ` Tom Zanussi
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2020-06-09 16:38 UTC (permalink / raw)
To: Tom Zanussi; +Cc: linux-rt-users, LKML
On 2020-06-09 11:21:44 [-0500], Tom Zanussi wrote:
> 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
This is still needed for RT && !SMP
> /*
> * If it got disabled meanwhile, bail out:
> */
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [4.19 stable-rt PATCH] tasklet: Fix UP case for tasklet CHAINED state
2020-06-09 16:38 ` Sebastian Andrzej Siewior
@ 2020-06-09 16:59 ` Tom Zanussi
0 siblings, 0 replies; 3+ messages in thread
From: Tom Zanussi @ 2020-06-09 16:59 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linux-rt-users, LKML
Hi Sebastian,
On Tue, 2020-06-09 at 18:38 +0200, Sebastian Andrzej Siewior wrote:
> On 2020-06-09 11:21:44 [-0500], Tom Zanussi wrote:
> > 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
>
> This is still needed for RT && !SMP
>
Yes, you're right - I'll change this and repost after testing all
cases.
Thanks,
Tom
> > /*
> > * If it got disabled meanwhile, bail out:
> > */
>
> Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-09 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 16:21 [4.19 stable-rt PATCH] tasklet: Fix UP case for tasklet CHAINED state Tom Zanussi
2020-06-09 16:38 ` Sebastian Andrzej Siewior
2020-06-09 16:59 ` Tom Zanussi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).