All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] mlockall error after calling mlockall()
Date: Tue, 02 Mar 2010 09:29:10 +0100	[thread overview]
Message-ID: <4B8CCC56.3000709@domain.hid> (raw)
In-Reply-To: <4B8C358E.9050303@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2828 bytes --]

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> Jan Kiszka wrote:
>>> Jan Kiszka wrote:
>>>> Gilles Chanteperdrix wrote:
>>>>> Jan Kiszka wrote:
>>>>>> Same issue exists in user space. And rt_cond_wait_inner needs fixing.
>>>>>> And then there is a spurious sign inversion:
>>>>>>
>>>>>> diff --git a/src/skins/native/cond.c b/src/skins/native/cond.c
>>>>>> index 478321d..f874678 100644
>>>>>> --- a/src/skins/native/cond.c
>>>>>> +++ b/src/skins/native/cond.c
>>>>>> @@ -96,9 +96,9 @@ int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
>>>>>>  				&saved_lockcnt, XN_REALTIME, &timeout);
>>>>>>  
>>>>>>  	while (err == -EINTR)
>>>>>> -		err = -XENOMAI_SKINCALL2(__native_muxid,
>>>>>> -					 __native_cond_wait_epilogue, mutex,
>>>>>> -					 saved_lockcnt);
>>>>>> +		err = XENOMAI_SKINCALL2(__native_muxid,
>>>>>> +					__native_cond_wait_epilogue, mutex,
>>>>>> +					saved_lockcnt);
>>>>>>  #endif /* !CONFIG_XENO_FASTSYNCH */
>>>>> Ok for the sign inversion, but in this case the status is Ok. We call
>>>>> cond_wait_epilogue only if prologue returned -EINTR, and update the
>>>>> status, this is what we want.
>>>>>
>>>>> There is only one way out which will not break the ABI: do not call
>>>>> cond_wait_epilogue in the kernel-space cond_wait_prologue.
>>>>>
>>>> Unfortunately, that ABI is broken: If we get -ETIMEDOUT on cond wait an
>>>> -EINTR on mutex lock, we lose the former, don't we?
>>>>
>>>> If we can't find a workaround, I'm for breaking the ABI for this
>>>> particular service - but let's search for an alternative first.
>>>>
>>> The only way around ABI changes: save the return code of cond_wait
>>> /somewhere/ across prologue and epilogue syscalls - but where???
>>>
>> In-kernel RT_TASK, that's probably the only place. Once
>> __rt_cond_wait_epilogue has acquired the mutex (or failed without
>> receiving a -EINTR), it can then pick up the original error that this
>> task received from rt_cond_wait_prologue and return it. What do you think?
> 
> I was thinking about the same idea, by using the xnthread errno.
> However, it is not reentrant, in the sense that if a signal handler
> emits a syscall which overrides this value, we are toast.

Right. But that's the price someone unable/unwilling to update their
user space libs along with the next kernel update will have to pay. I
don't expect there are many, though, and the sketched scenario is fairly
uncommon as well.

So let's head this way: Install some workaround for the existing
__rt_cond_wait_prologue syscall, but also introduce
__rt_cond_wait_prologue2 which writes the cond-wait error code back like
it already happens for lockcnt. That syscall is used by updated user
space libs if they find it, otherwise we fall back to the old pattern.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2010-03-02  8:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25 21:12 [Xenomai-help] mlockall error after calling mlockall() Charlton, John
2010-02-25 21:25 ` Gilles Chanteperdrix
2010-02-25 21:38 ` Jan Kiszka
2010-02-25 22:42   ` Jan Kiszka
2010-02-25 22:54     ` Gilles Chanteperdrix
2010-02-25 23:01       ` Jan Kiszka
2010-02-26 16:47         ` Charlton, John
2010-02-26 16:53           ` Gilles Chanteperdrix
2010-02-26 17:15             ` Charlton, John
2010-03-01 15:52             ` Charlton, John
2010-03-01 20:30               ` Charlton, John
2010-03-01 20:33                 ` Jan Kiszka
2010-03-01 20:38                   ` Gilles Chanteperdrix
2010-03-01 20:43                     ` Jan Kiszka
2010-03-01 20:46                       ` Jan Kiszka
2010-03-01 20:56                         ` Gilles Chanteperdrix
2010-03-01 21:00                           ` Gilles Chanteperdrix
2010-03-01 21:02                             ` Jan Kiszka
2010-03-01 21:06                               ` Jan Kiszka
2010-03-01 21:01                           ` Jan Kiszka
2010-03-01 21:05                             ` Gilles Chanteperdrix
2010-03-01 21:21                               ` Jan Kiszka
2010-03-01 21:25                                 ` Jan Kiszka
2010-03-01 21:39                                   ` Jan Kiszka
2010-03-01 21:45                                     ` Gilles Chanteperdrix
2010-03-02  8:29                                       ` Jan Kiszka [this message]
2010-03-02  8:36                                         ` Jan Kiszka
2010-03-01 21:53                                   ` Charlton, John
2010-03-02 13:26                                     ` Charlton, John
2010-03-02 14:05                                       ` Jan Kiszka
2010-03-01 20:30               ` 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=4B8CCC56.3000709@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --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.