Re: tasklets in 2.4.6

From: Andrea Arcangeli (andrea@suse.de)
Date: Fri Jul 06 2001 - 06:28:13 EST


On Fri, Jul 06, 2001 at 03:08:05AM -0400, Jeff Garzik wrote:
> Ville Nummela wrote:
> > In kernel/softirq.c, line 178:
> >
> > if (test_bit(TASKLET_STATE_SCHED, &t->state))
> > tasklet_schedule(t);
> >
> > What's the idea behind this line? If the tasklet is already scheduled,
> > schedule it again? This does not make much sense to me.
> >
> > Also, few lines before:
> >
> > if (test_bit(TASKLET_STATE_SCHED, &t->state))
> > goto repeat;
> >
> > Here we'll loop forever if the tasklet should schedule itself.
>
> hmmm, it looks almost ok to me.
>
> The tasklet is locked before the "repeat" label, so any tasklet
> scheduling itself will set the bit, but NOT actually schedule iteself.
> For this see the tasket_schedule code, for the case where the bit is not
> set, but the tasklet is locked.
>
> The first statement above schedules the tasklet if the bit was set while
> the tasklet was locked. The second statement, as the comment right
> above it indicates, causes the tasklet to repeat itself.
>
> The only thing that appears fishy is that if the tasklet constantly
> reschedules itself, it will never leave the loop AFAICS. This affects
> tasklet_hi_action as well as tasklet_action.

another bug triggers when the tasklet is re-enabled by another cpu in
this point:

                        if (test_bit(TASKLET_STATE_SCHED, &t->state))
                                goto repeat;
                }
                XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                tasklet_unlock(t);
                if (test_bit(TASKLET_STATE_SCHED, &t->state))
                        tasklet_schedule(t);

then the check for test_bit(TASKLET_STATE_SCHED, &t->state) will
trigger, but the tasklet_schedule won't queue the tasklet because
TASKLET_STATE_SCHED is just set in t->state.

This is fixed in my ksoftirqd patch. However one thing I'd like to
change in my patch is to add the BUG() that triggers in the case
mentioned yesterday.

Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jul 07 2001 - 21:00:18 EST