Skip to content

Commit

Permalink
softirq: s/BUG/WARN_ONCE/ on tasklet SCHED state not set
Browse files Browse the repository at this point in the history
Replace BUG() with WARN_ONCE() on wrong tasklet state, in order to:

 - increase the verbosity / aid in debugging
 - avoid fatal/unrecoverable state

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210317102012.32399-1-erosca@de.adit-jv.com
  • Loading branch information
Dirk Behme authored and Ingo Molnar committed Mar 17, 2021
1 parent 5c982c5 commit 6b2c339
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,18 @@ void __tasklet_hi_schedule(struct tasklet_struct *t)
}
EXPORT_SYMBOL(__tasklet_hi_schedule);

static bool tasklet_should_run(struct tasklet_struct *t)
{
if (test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
return true;

WARN_ONCE(1, "tasklet SCHED state not set: %s %pS\n",
t->use_callback ? "callback" : "func",
t->use_callback ? (void *)t->callback : (void *)t->func);

return false;
}

static void tasklet_action_common(struct softirq_action *a,
struct tasklet_head *tl_head,
unsigned int softirq_nr)
Expand All @@ -550,13 +562,12 @@ static void tasklet_action_common(struct softirq_action *a,

if (tasklet_trylock(t)) {
if (!atomic_read(&t->count)) {
if (!test_and_clear_bit(TASKLET_STATE_SCHED,
&t->state))
BUG();
if (t->use_callback)
t->callback(t);
else
t->func(t->data);
if (tasklet_should_run(t)) {
if (t->use_callback)
t->callback(t);
else
t->func(t->data);
}
tasklet_unlock(t);
continue;
}
Expand Down

0 comments on commit 6b2c339

Please sign in to comment.