From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: "M. Koehrer" <mathias_koehrer@domain.hid>, xenomai@xenomai.org
Subject: Re: [Xenomai-core] RPI is good for you
Date: Wed, 25 Jul 2007 16:58:30 +0200 [thread overview]
Message-ID: <1185375510.5998.379.camel@domain.hid> (raw)
In-Reply-To: <46A736CB.1080502@domain.hid>
On Wed, 2007-07-25 at 13:40 +0200, Jan Kiszka wrote:
> Philippe Gerum schrieb:
> > On Fri, 2007-07-20 at 14:16 +0200, Philippe Gerum wrote:
> >
> > Now, regarding the deadlock issue, suppressing the RPI-specific locking
> > entirely would have been the best solution, but unfortunately, the
> > migration scheme makes this out of reach, at least without resorting to
> > some hairy and likely unreliable implementation. Therefore, the solution
> > I came with consists of making the RPI lock a per-cpu thing, so that
> > most RPI routines are actually grabbing a _local_ lock wrt the current
> > CPU, those routines being allowed hold the nklock as they wish. When
> > some per-CPU RPI lock is accessed from a remote CPU, it is guaranteed
> > that _no nklock_ may be held nested. Actually, the remote case only
> > occurs once, in rpi_clear_remote(), and all its callers are guaranteed
> > to be nklock-free (a debug assertion even enforces that).
>
> Yeah, it is actually safe against deadlocks now. Still, I wonder why we
> can't design xnshadow_rpi_check like this:
>
> ...
> int need_renice = 0;
>
> xnlock_get_irqsave(&rpislot->lock, s);
>
> if (sched_emptypq_p(&rpislot->threadq) &&
> xnpod_root_priority() != XNCORE_IDLE_PRIO)
> need_renice = 1;
>
> xnlock_put_irqrestore(&rpislot->lock, s);
>
> if (need_renice)
> xnpod_renice_root(XNCORE_IDLE_PRIO);
>
>
> If we can avoid nesting (even if it's safe), we should do so. Or does
> this pattern here introduce new, ugly race possibility?
Yeah, this would work, because what we need actually is that
xnshadow_rpi_check() runs with local interrupts off, which is the case
since it is called on behalf of an IPI with hardware interrupts
disabled. Otherwise, we would open a short window for this kind of
scenario:
xnshadow_rpi_check
empty-p(RPI list)?
<IRQ> switch to some primary mode thread
primary mode thread relaxes
push other thread to RPI list
(spuriously) downgrade root thread priority
This said, we have no interest ATM to let hw interrupts flow when
handling this IPI, so we could indeed flatten the locking sequence as
you described, provided we also put some big fat warning into that piece
of code too.
--
Philippe.
prev parent reply other threads:[~2007-07-25 14:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-19 13:27 [Xenomai-help] Sporadic PC freeze after rt_task_start M. Koehrer
2007-07-19 13:42 ` Philippe Gerum
2007-07-19 13:52 ` M. Koehrer
2007-07-20 0:14 ` [Xenomai-core] RPI is good for you Philippe Gerum
2007-07-20 7:32 ` M. Koehrer
2007-07-20 11:54 ` M. Koehrer
2007-07-20 12:16 ` Philippe Gerum
2007-07-23 15:01 ` Philippe Gerum
2007-07-23 17:15 ` Philippe Gerum
2007-07-23 17:45 ` [Xenomai-core] r2773 mistake? x86_64 adeos patch Jeff Koftinoff
2007-07-23 18:04 ` Philippe Gerum
2007-07-24 9:55 ` [Xenomai-core] RPI is good for you Philippe Gerum
2007-07-24 12:05 ` M. Koehrer
2007-07-25 6:54 ` M. Koehrer
2007-07-25 7:06 ` Philippe Gerum
2007-07-25 11:40 ` Jan Kiszka
2007-07-25 14:58 ` Philippe Gerum [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=1185375510.5998.379.camel@domain.hid \
--to=rpm@xenomai.org \
--cc=jan.kiszka@domain.hid \
--cc=mathias_koehrer@domain.hid \
--cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.