From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: xenomai@xenomai.org
Subject: Re: [PATCH 1/5] cobalt/events: add auto-clear feature
Date: Thu, 07 Apr 2022 19:09:25 +0200 [thread overview]
Message-ID: <87v8vkerlb.fsf@xenomai.org> (raw)
In-Reply-To: <36839700-8ca3-48b2-476e-8723a2030560@siemens.com>
Jan Kiszka <jan.kiszka@siemens.com> writes:
> On 07.04.22 13:16, Philippe Gerum wrote:
>>
>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>>
>>> On 06.04.22 17:56, Philippe Gerum via Xenomai wrote:
>>>> From: Philippe Gerum <rpm@xenomai.org>
>>>>
>>>> The current implementation does not atomically consume+clear the event
>>>> set to be received by the waiter(s), which makes it useless for
>>>> anything but a plain one-time latch due to the race window this opens
>>>> with a consume[A]->signal[B]->clear[A] sequence.
>>>>
>>>> To address this issue, let's provide the auto-clear feature with
>>>> __cobalt_event_wait().
>>>>
>>>> This change affects the ABI by adding the auto-clear mode as an opt-in
>>>> feature, enabled by passing COBALT_EVENT_AUTOCLEAR to
>>>> cobalt_event_init().
>>>>
>>>
>>> Makes sense, but shouldn't autoclear be rather the default then? Which
>>> users are affected? None in-tree so far?
>>>
>>
>> There is one user in copperplate:
>> https://source.denx.de/Xenomai/xenomai/-/blob/28158391258eea52650856bef5d3ed6ebaaf813b/lib/copperplate/eventobj.c#L87
>>
>> which indirectly affects rt_event_signal() from the alchemy API:
>> https://source.denx.de/Xenomai/xenomai/-/blob/28158391258eea52650856bef5d3ed6ebaaf813b/lib/alchemy/event.c#L453
>>
>> Nobody raised the issue so far with alchemy, which is why I refrained
>> from turning the autoclear mode on by default so far. This is debatable,
>> since no documentation explains the limitation on usage caused by not
>> having the autoclear mode set.
>>
>
> So, the pattern via Alchemy would be
>
> Thread A Thread B
>
> rt_event_wait()
> rt_event_signal()
> rt_event_clear()
>
> That would force users to perform a state check via a side-channel after
> clearing the event to avoid starting to waiting if the condition was met
> again.
>
> OK, but how could users request the new mode in rt_event_create? There
> is not even a EV_AUTOCLEAR flag for it. Do you have more patches pending?
>
The alternative I see is:
- assume that some people might be expecting the current - fragile to
say the least - behavior, which means that we should add a flag to
rt_event_create() in order to enable the auto-clear mode for all
others.
- consider the current behavior as broken beyond recognition, and force
in the auto-clear mode for all alchemy events, at the expense of
requiring the folks who have been using a side-channel to paper over
the current misdesign, to fix their stuff the right way, based on the
auto-clear behavior.
IMHO, everyone would be better off with #2, because it would just work
in all cases. The side-channel would simply become a useless but
innocuous noise if present.
Which way should we go is debatable, this is why I did not issue any
patch changing the alchemy interface yet.
--
Philippe.
next prev parent reply other threads:[~2022-04-07 17:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 15:56 [PATCH 1/5] cobalt/events: add auto-clear feature Philippe Gerum
2022-04-06 15:56 ` [PATCH 2/5] cobalt/events: add single-waiter delivery mode Philippe Gerum
2022-04-07 9:49 ` Jan Kiszka
2022-04-07 11:26 ` Philippe Gerum
2022-04-06 15:56 ` [PATCH 3/5] copperplate, testsuite: convert to cobalt_event_broadcast() Philippe Gerum
2022-04-06 15:56 ` [PATCH 4/5] lib/cobalt: deprecate cobalt_event_post() Philippe Gerum
2022-04-06 15:56 ` [PATCH 5/5] drivers: ipc: enable non-blocking write from regular threads Philippe Gerum
2022-04-07 9:51 ` Jan Kiszka
2022-04-07 11:37 ` Philippe Gerum
2022-04-13 11:21 ` Jan Kiszka
2022-04-07 9:47 ` [PATCH 1/5] cobalt/events: add auto-clear feature Jan Kiszka
2022-04-07 11:16 ` Philippe Gerum
2022-04-07 16:39 ` Jan Kiszka
2022-04-07 17:09 ` Philippe Gerum [this message]
2022-04-13 11:20 ` 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=87v8vkerlb.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=jan.kiszka@siemens.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.