From: Juergen Quade <quade@hsnr.de>
To: Nagendra Singh Tomar <nagendra_tomar@adaptec.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: tasklet_kill will always hang for recursive tasklets on a UP
Date: Mon, 25 Aug 2003 16:11:33 +0200 [thread overview]
Message-ID: <20030825141133.GA17305@hsnr.de> (raw)
In-Reply-To: <Pine.LNX.4.44.0308250518380.26988-100000@localhost.localdomain>
> Hi,
> While going thru the code for tasklet_kill(), I cannot figure out
> how recursive tasklets (tasklets that schedule themselves from within
> their tasklet handler) can be killed by this function. To me it looks that
> tasklet_kill will never complete for such tasklets.
It is realy a sophisticated piece of code! I think it is not
the only bug you found. Some weeks ago I pointed out another
problem with tasklet_kill but got no answer.
To work our questions out is not done in just 1 minute :-(
And I was not able to find the person, who is responsible for the code.
As far as I can see, you missed nothing.
The tasklet enters itself to the "task_vec" list, because the
SCHED-Bit is always resetted, when "tasklet_schedule" is called.
It will always succeed.
Maybe you have a look to another (my) problem:
The function "tasklet_schedule" schedules a tasklet only, if the SCHED-Bit
ist _not_ set. So the trick is, to _set_ the SCHED-Bit and
to _not_ enter the tasklet in the "task_vec" list (ok, you showed
that this trick can fail). But anyway, if you look at the
code, tasklet_kill resets the bit in any case!!! It would have to
set the bit, not to reset it. Any comments?
void tasklet_kill(struct tasklet_struct *t)
{
...
while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
do
yield();
while (test_bit(TASKLET_STATE_SCHED, &t->state));
}
tasklet_unlock_wait(t);
clear_bit(TASKLET_STATE_SCHED, &t->state);
}
> void tasklet_kill(struct tasklet_struct *t)
> {
> ...
> ...
> while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
> current->state = TASK_RUNNING;
> do
> sys_sched_yield();
> while (test_bit(TASKLET_STATE_SCHED, &t->state));
> }
> ...
> ...
> }
>
> The above while loop will only exit if TASKLET_STATE_SCHED is not set
> (tasklet is not scheduled).
> Now if we see tasklet_action
>
> static void tasklet_action(struct softirq_action *a)
> {
> ...
> ...
> if (!atomic_read(&t->count)) {
> --> TASKLET_STATE_SCHED is set here
> if(!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
> BUG();
> t->func(t->data);
> --> if we schedule the tasklet inside its handler,
> --> TASKLET_STATE_SCHED will be set here also
> tasklet_unlock(t);
> continue;
> }
> ...
> ...
> }
>
> The only small window when TASKLET_STATE_SCHED is not set is between the
> time when test_and_clear_bit above clears it and by the time the tasklet
> handler again calls tasklet_schedule(). But since tasklet_kill is called
> from user context the while loop in tasklet_kill checking for
> TASKLET_STATE_SCHED to be cleared cannot interleave between the above two
> lines in tasklet_action and hence tasklet_kill will never come out of the
> while loop.
> This is true only for UP machines.
>
> Pleae point me out if I am missing something.
>
> Thanx
> tomar
>
>
> -
> 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/
>
next prev parent reply other threads:[~2003-08-25 14:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-25 0:00 tasklet_kill will always hang for recursive tasklets on a UP Nagendra Singh Tomar
2003-08-25 1:53 ` Nagendra Singh Tomar
2003-08-25 14:11 ` Juergen Quade [this message]
2003-08-25 17:14 ` Nagendra Singh Tomar
2003-08-27 18:21 ` Juergen Quade
2003-08-27 17:46 ` Nagendra Singh Tomar
2003-08-28 15:29 ` Juergen Quade
2003-08-28 15:53 ` kuznet
2003-08-28 16:17 ` Juergen Quade
2003-08-29 2:22 ` Werner Almesberger
2003-08-26 5:48 ` Werner Almesberger
2003-08-25 18:45 ` Nagendra Singh Tomar
2003-08-26 7:38 ` Werner Almesberger
2003-08-26 8:32 ` Juergen Quade
2003-08-26 17:56 ` Werner Almesberger
2003-08-27 1:47 ` kuznet
2003-08-26 16:17 ` Nagendra Singh Tomar
2003-08-28 13:17 ` kuznet
2003-08-28 16:25 ` Nagendra Singh Tomar
2003-09-04 13:25 ` kuznet
2003-08-29 2:30 ` Werner Almesberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030825141133.GA17305@hsnr.de \
--to=quade@hsnr.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nagendra_tomar@adaptec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox