From: Maksim Krasnyanskiy <maxk@qualcomm.com>
To: jt@hpl.hp.com
Cc: "Richard B. Johnson" <root@chaos.analogic.com>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>,
Paul Mackerras <paulus@samba.org>
Subject: Re: Killing tasklet from interrupt
Date: Fri, 22 Mar 2002 09:56:10 -0800 [thread overview]
Message-ID: <5.1.0.14.2.20020322095459.02f70cf0@mail1.qualcomm.com> (raw)
In-Reply-To: <5.1.0.14.2.20020319105838.02f70cf0@mail1.qualcomm.com>
Did it help ?
>> > Sounds like what you need is tasklet_disable.
>> > tasklet_kill needs process context so you can't use it in timer.
>> >
>> > >It's a shame that the code doesn't explitely allow for it (i.e. you will
>> > >deadlock every time
>> > >in tasklet_unlock_wait(t);).
>> > Use tasklet_disable_nosync within the tasklet itself.
>>
>> Well. I thought about that. Not possible.
>> tasklet_disable is not the answer, because if the tasklet was
>>scheduled, it will stay forever in the tasklet queue. Also, I need to
>>forget forever about getting rid of the tasklet within the tasklet
>>itself, because it will just crash.
>How about something like this ?
>
>void tasklet_kill_from_interrupt(struct tasklet_struct *t)
>{
> while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state));
> tasklet_unlock_wait(t);
>}
>
>So, in your timer you would do:
> set_bit(CLOSING_PLEASE_DONT_SCHEDULE_ANYTHING, something->state);
> tasklet_kill_from_interrupt(something->tasklet);
> /* cleanup/kfree/etc */
>
>> Look below, comments by me (you've got to love uncommented
>>code). So, it's not today that I will use tasklets.
>Well, I use them without any problems in Bluetooth code. May be you should
>redesign your code a bit. For example don't kill tasklets from the timer.
>
>>P.S. : By the way, regarding flow control between TCP and netdevice
>>(our previous e-mail exchange with Paul), have you investigated the
>>effect of skb->destructor; (for example sock_wfree()).
>I'm sorry I must have missed skb->destructor part. How sock_wfree could
>affect flow ctl between TCP and netdev ?
>sock_wfree just wakes up process sleeping in sock_alloc_send_skb or alike.
>
>>-------------------------------------------------------------
>>
>>static void tasklet_action(struct softirq_action *a)
>>{
>> int cpu = smp_processor_id();
>> struct tasklet_struct *list;
>>
>> local_irq_disable();
>> list = tasklet_vec[cpu].list;
>> tasklet_vec[cpu].list = NULL;
>> local_irq_enable();
>>
>> while (list) {
>> struct tasklet_struct *t = list;
>>
>> list = list->next;
>>
>> if (tasklet_trylock(t)) {
>> if (!atomic_read(&t->count)) {
>> if
>> (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
>> BUG();
>> // Call tasklet handler
>> t->func(t->data);
>> // If tasklet was killed/destroyed/kfree above, we will die
>> tasklet_unlock(t);
>> continue;
>> }
>> tasklet_unlock(t);
>> }
>"kill" means "wait until tasklet terminates and is not in the queue". So
>it's not a problem
>And you would not want to destroy _locked_ tasklet. You'd wait until it's
>unlocked.
>
>Max
prev parent reply other threads:[~2002-03-22 17:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-18 19:53 Killing tasklet from interrupt Jean Tourrilhes
2002-03-18 20:38 ` Richard B. Johnson
2002-03-18 20:57 ` Jean Tourrilhes
2002-03-18 23:20 ` Maksim Krasnyanskiy
2002-03-18 23:33 ` Jean Tourrilhes
2002-03-19 19:41 ` Maksim Krasnyanskiy
2002-03-22 17:56 ` Maksim Krasnyanskiy [this message]
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=5.1.0.14.2.20020322095459.02f70cf0@mail1.qualcomm.com \
--to=maxk@qualcomm.com \
--cc=jt@hpl.hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=root@chaos.analogic.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;
as well as URLs for NNTP newsgroup(s).