From: Philippe Gerum <rpm@xenomai.org>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: Jan Kiszka <jan.kiszka@domain.hid>,
Xenomai core <Xenomai-core@domain.hid>
Subject: Re: [Xenomai-core] Fragile lock usage tracking for auto-relax
Date: Tue, 31 May 2011 18:48:36 +0200 [thread overview]
Message-ID: <1306860516.2153.58.camel@domain.hid> (raw)
In-Reply-To: <4DE51970.7010006@domain.hid>
On Tue, 2011-05-31 at 18:38 +0200, Gilles Chanteperdrix wrote:
> On 05/31/2011 06:29 PM, Philippe Gerum wrote:
> > On Tue, 2011-05-31 at 13:37 +0200, Jan Kiszka wrote:
> >> Hi Philippe,
> >>
> >> enabling XENO_OPT_DEBUG_NUCLEUS reveals some shortcomings of the
> >> in-kernel lock usage tracking via xnthread_t::hrescnt. This BUGON in
> >> xnsynch_release triggers for RT threads:
> >>
> >> XENO_BUGON(NUCLEUS, xnthread_get_rescnt(lastowner) < 0);
> >>
> >> RT threads do not balance their lock and unlock syscalls, so their
> >> counter goes wild quite quickly.
> >>
> >> But just limiting the bug check to XNOTHER threads is neither a
> >> solution. How to deal with the counter on scheduling policy changes?
> >>
> >> So my suggestion is to convert the auto-relax feature into a service,
> >> user space can request based on a counter that user space maintains
> >> independently. I.e. we should create another shared word that user space
> >> increments and decrements on lock acquisitions/releases on its own. The
> >> nucleus just tests it when deciding about the relax on return to user space.
> >>
> >> But before hacking into that direction, I'd like to hear if it makes
> >> sense to you.
> >
> > At first glance, this does not seem to address the root issue. The
> > bottom line is that we should not have any thread release an owned lock
> > it does not hold, kthread or not.
> >
> > In that respect, xnsynch_release() looks fishy because it may be called
> > over a context which is _not_ the lock owner, but the thread who is
> > deleting the lock owner, so assuming lastowner == current_thread when
> > releasing is wrong.
> >
> > At the very least, the following patch would prevent
> > xnsynch_release_all_ownerships() to break badly. The same way, the
> > fastlock stuff does not track the owner properly in the synchro object.
> > We should fix those issues before going further, they may be related to
> > the bug described.
>
> It looks to me like xnsynch_fast_release uses cmpxchg, so, will not set
> the owner to NULL if the current owner is not the thread releasing the
> mutex. Is it not sufficient?
>
Yes, we need to move that swap to the irq off section to clear the owner
there as well.
--
Philippe.
next prev parent reply other threads:[~2011-05-31 16:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-31 11:37 [Xenomai-core] Fragile lock usage tracking for auto-relax Jan Kiszka
2011-05-31 16:29 ` Philippe Gerum
2011-05-31 16:38 ` Gilles Chanteperdrix
2011-05-31 16:48 ` Philippe Gerum [this message]
2011-05-31 16:38 ` Jan Kiszka
2011-05-31 16:50 ` Gilles Chanteperdrix
2011-05-31 16:54 ` Jan Kiszka
2011-05-31 16:58 ` Philippe Gerum
2011-05-31 17:06 ` Jan Kiszka
2011-05-31 17:58 ` Gilles Chanteperdrix
2011-05-31 18:01 ` Jan Kiszka
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=1306860516.2153.58.camel@domain.hid \
--to=rpm@xenomai.org \
--cc=Xenomai-core@domain.hid \
--cc=gilles.chanteperdrix@xenomai.org \
--cc=jan.kiszka@domain.hid \
/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.