All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Caffreyfans <Caffreyfans@163.com>, xenomai@xenomai.org
Subject: Re: [BUG] copperlate/eventobj.c ->>> eventobj_inquire(), don't work
Date: Fri, 10 Jul 2020 10:38:12 +0200	[thread overview]
Message-ID: <d926b5a5-da09-c2f1-0b81-544cae7cc9d9@xenomai.org> (raw)
In-Reply-To: <e371ebd5-519a-cf6e-998e-b2591d4f1c48@163.com>

On 7/10/20 8:04 AM, Caffreyfans via Xenomai wrote:
> Hi sir,
> 
>     I'm trying to make another skin for xenomai.  When I do something about
> "event". I use `eventobj_inquire()` to get event flags. But no matter what
> value I post, I always get 0.
> 
>     I find that eventobj_inquire() is not working. I know `alchemy/event` also
> use `eventobj`. So I write a test code by using alchemy skin. I am curious
> whether it is my own problem or there is an error in xenomai.
> 

Most likely a bug in Xenomai. In addition, looking at cobalt_event_post(),
there is a blatant race condition between the signal <-> wait operations. The
in-kernel wait() operation serializes on the ugly big lock which is not going
to help much against racing with the userland counterpart in
cobalt_event_post(), which does this:

	__sync_or_and_fetch(&state->value, bits); /* full barrier. */

	if ((state->flags & COBALT_EVENT_PENDED) == 0)
		return 0;

The somebody-is-waiting bit tested above should be part of some atomic
operation shared with the wait-side or covered by the ugly big lock, but the
way it is implemented today can lead to spurious waits.

The event code was fixed months ago for another bad issue, the whole thing
looks fragile. You may want to review all of it.

-- 
Philippe.


  reply	other threads:[~2020-07-10  8:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10  6:04 [BUG] copperlate/eventobj.c ->>> eventobj_inquire(), don't work Caffreyfans
2020-07-10  8:38 ` Philippe Gerum [this message]
2020-07-13 17:59   ` Jan Kiszka
2020-07-13 18:27     ` Philippe Gerum

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=d926b5a5-da09-c2f1-0b81-544cae7cc9d9@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=Caffreyfans@163.com \
    --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.