From: Roland Dreier <rdreier@cisco.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: schedule (wait_event) vs. while
Date: Sat, 27 Feb 2010 12:11:37 -0800 [thread overview]
Message-ID: <ada8waev3pi.fsf@roland-alpha.cisco.com> (raw)
In-Reply-To: <b170af451002270152u228a46abr3b316da75b2fa3f0@mail.gmail.com> (=?utf-8?Q?=22Rafa=C5=82_Mi=C5=82ecki=22's?= message of "Sat, 27 Feb 2010 10:52:09 +0100")
> In radeon engine reclocking code I need to do some calculations and
> then wait for VBLANK interrupt. Right after VBLANK interrupt will
> happen I need to reclock ASAP.
>
> Interrupts are received by another context and I need some quite fast
> synchronization.
>
> 1) Schedule solution:
> reclocking() {
> calculations();
> radeon->vblank_sync = 0;
> wait_event_timeout(radeon->wq, radeon->vblank_sync, timeout);
> reclock();
> }
> i-handler() { radeon->vblank_sync = 1; }
What does reclock() involve? Is there any reason you can't do it in the
interrupt handler? (quite possibly it needs to sleep or something)
If you can do it in the interrupt handler, then your reclocking()
function could do the calculations, stash the result somewhere, and set
a flag that tells the interrupt handler to do the reclock(). Then you
could use a completion to have reclocking() wait until the reclock() was
actually done (the latency of that completion doesn't matter, since
you're not doing any actual work after the completion).
If you do need to wait for process context, then one possibility would
be to do reclocking() from a high-priority kernel thread. Then the wake
up latency should be low (but maybe not low enough). Or you could
convert the interrupt handler to use the new threaded interrupt support,
to get into a process context as fast as possible.
If you reall need to busy-wait, then
> reclocking() {
> calculations();
> del_timer(radeon->fake_vblank);
> radeon->vblank_sync = 0;
> mod_timer(radeon->fake_vblank, 10ms);
> while(!radeon->vblank_sync);
> reclock();
> }
> i-handler() { radeon->vblank_sync = 1; }
> fake-handler() { radeon->vblank_sync = 1; }
There's no need for the fake_vblank timer -- just keep track of the time
when you start busy-waiting and then exit the loop when 10ms passes.
- R.
--
Roland Dreier <rolandd@cisco.com>
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
prev parent reply other threads:[~2010-02-27 20:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-27 9:52 Rafał Miłecki
2010-02-27 20:11 ` Roland Dreier [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=ada8waev3pi.fsf@roland-alpha.cisco.com \
--to=rdreier@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zajec5@gmail.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
Powered by JetHome