From: Rusty Russell <rusty@rustcorp.com.au>
To: Robin Holt <holt@sgi.com>
Cc: Dean Nelson <dcn@sgi.com>, Arjan van de Ven <arjanv@redhat.com>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: calling kthread_create() from interrupt thread
Date: Wed, 16 Jun 2004 09:40:55 +1000 [thread overview]
Message-ID: <1087342744.12229.73.camel@bach> (raw)
In-Reply-To: <20040615190114.GA6151@lnx-holt.americas.sgi.com>
On Wed, 2004-06-16 at 05:01, Robin Holt wrote:
> We receive an interrupt. The interrupt handler determines that some work
> needs to be done. Part of that work to be done may result in the process
> needing to go to sleep waiting for a resource to become available.
>
> Currently, the interrupt handler wakes a thread sleeping on a
> wait_event_interruptible(). This wakeup is taking approx 35uSec. Dean
> is looking for a lower latency means of doing the wakeup.
The best approach is, as suggested in this thread, to have a fastpath
which is called from interrupt handler, which fails if it needs to
sleep; in that case you back off to your own workqueue. It'd look
something like:
static DEFINE_PER_CPU(struct work_struct slow_work);
static workqueue_struct *wq;
irqreturn_t do_interrupt(...)
{
if (!fast_irq_handle())
queue_work(wq, &__get_cpu_var(slow_work));
}
static void do_slow_work(void *unused)
{
...
}
static int __init init(void)
{
int cpu;
wq = create_workqueue("drivername", 0);
for_each_cpu(cpu)
PREPARE_WORK(&per_cpu(slow_work, cpu),
do_slow_work, NULL);
}
You need to come up with a mechanism to pass details from the interrupt
handler to the do_slow_work() fn, probably a separate queue or array
which do_slow_work() will need to disable irqs to access. queue_work
will not requeue the work_struct if it's already pending, your
do_slow_work() needs to handle all the requests which are waiting.
Hope that helps,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell
next prev parent reply other threads:[~2004-06-15 23:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-15 17:42 calling kthread_create() from interrupt thread Dean Nelson
2004-06-15 17:49 ` Arjan van de Ven
2004-06-15 18:05 ` Dean Nelson
2004-06-15 18:14 ` Jesse Barnes
2004-06-15 22:14 ` Jeff Garzik
2004-06-15 18:15 ` Richard B. Johnson
2004-06-15 19:01 ` Robin Holt
2004-06-15 19:28 ` Roland Dreier
2004-06-15 19:30 ` Chris Wright
2004-06-15 23:40 ` Rusty Russell [this message]
2004-06-15 19:14 ` Dean Nelson
2004-06-15 19:27 ` Roland Dreier
2004-06-15 19:59 ` Chris Wright
[not found] <27qex-5LX-17@gated-at.bofh.it>
[not found] ` <27qoT-5Uy-15@gated-at.bofh.it>
[not found] ` <27qxQ-67a-27@gated-at.bofh.it>
2004-06-15 20:41 ` Andi Kleen
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=1087342744.12229.73.camel@bach \
--to=rusty@rustcorp.com.au \
--cc=arjanv@redhat.com \
--cc=dcn@sgi.com \
--cc=holt@sgi.com \
--cc=linux-kernel@vger.kernel.org \
/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