All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Philippe Gerum <rpm@xenomai.org>,
	Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Re: I-pipe 1.7 breaks mlockall safety check
Date: Mon, 19 Feb 2007 13:31:26 +0100	[thread overview]
Message-ID: <45D9989E.4070103@domain.hid> (raw)
In-Reply-To: <45D95218.6000602@domain.hid>

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

Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>> Philippe Gerum wrote:
>>  > On Mon, 2007-02-19 at 00:31 +0100, Gilles Chanteperdrix wrote:
>>  > > Jan Kiszka wrote:
>>  > >  > Hi Philippe,
>>  > >  > 
>>  > >  > I just verfied that the mlockall issue persists. But it doesn't appear
>>  > >  > to be a regression anymore. This little posix demo exposes it now on
>>  > >  > both 2.6.20-1.7-02 and 2.6.19-1.6-06 against latest trunk:
>>  > >  > 
>>  > >  > #include <stdio.h>
>>  > >  > #include <sys/mman.h>
>>  > >  > #include <pthread.h>
>>  > >  > 
>>  > >  > int main(int argc, char *argv[])
>>  > >  > {
>>  > >  > 	struct sched_param param = { .sched_priority = 10 };
>>  > >  > 
>>  > >  > //	mlockall(MCL_CURRENT|MCL_FUTURE);
>>  > >  > 
>>  > >  > 	pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
>>  > >  > 
>>  > >  > 	printf("shouldn't be printed...\n");
>>  > >  > 	pause();
>>  > >  > }
>>  > >  > 
>>  > >  > 
>>  > >  > In contrast, the same done via the native skin (rt_task_shadow) triggers
>>  > >  > warning and program termination as expected.
>>  > >  > 
>>  > >  > It looks to me like the temporary mlockall during libpthread_rt init is
>>  > >  > not really reverted (but munlockall is actually called) or not
>>  > >  > propagated to the mm state that is later checked on xnshadow_map.
>>  > > 
>>  > > The problem is that the root thread is already shadowed in this program
>>  > > when pthread_setschedparam is called. So, xnshadow_map is not called and
>>  > > the flag is not checked.
>>  > > 
>>  > 
>>  > Yep. This makes sense, since kernel-wise, sys_munlockall does clear the
>>  > VM_LOCKED bit from the caller's mm default flags.
>>  > 
>>  > Since this behaviour is specific to the POSIX skin because it silently
>>  > shadows the main thread as a Xenomai thread from the SCHED_NORMAL class,
>>  > maybe we should check the mm state in the POSIX thread creation routine
>>  > too, when SCHED_FIFO or SCHED_RR are passed as the scheduling class.
>>
>> The flag is checked if another thread is created, since xnshadow_map is
>> called. The only solution I see at the moment is to remove the call to
>> munlockall in the library initialization.
>>
> 
> So this piece of code should trigger again?
> 
> #include <stdio.h>
> #include <sys/mman.h>
> #include <pthread.h>
> 
> void *thread(void *arg)
> {
>         struct sched_param param = { .sched_priority = 10 };
> 
>         pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
>         printf("shouldn't be printed...\n");
>         return NULL;
> }
> 
> int main(int argc, char *argv[])
> {
>         pthread_t th;
> 
>         pthread_create(&th, NULL, thread, NULL);
>         pthread_join(th, NULL);
> }
> 
> 
> Well, it doesn't in fact, and I think I found my regression again. This
> demo behaves as expected over 1.6-06, but remains silent over I-pipe 1.7-02.

May this hunk explain the behaviour?

http://www.rts.uni-hannover.de/xenomai/lxr/source/ksrc/arch/i386/patches/adeos-ipipe-2.6.20-i386-1.7-02.patch?a=i386;v=SVN-2.3.x#7755

munlockall is realised via mlockall, so OR'ing here would never take
away any flag.

Jan


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

  reply	other threads:[~2007-02-19 12:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-15 13:06 [Xenomai-core] I-pipe 1.7 breaks mlockall safety check Jan Kiszka
2007-02-15 13:56 ` [Xenomai-core] " Philippe Gerum
2007-02-15 13:58   ` Jan Kiszka
2007-02-15 17:25     ` Philippe Gerum
2007-02-16  9:07       ` Jan Kiszka
2007-02-18 23:20         ` Jan Kiszka
2007-02-18 23:31           ` Gilles Chanteperdrix
2007-02-18 23:50             ` Philippe Gerum
2007-02-19  0:20               ` Gilles Chanteperdrix
2007-02-19  7:30                 ` Jan Kiszka
2007-02-19 12:31                   ` Jan Kiszka [this message]
2007-02-19 12:36                     ` Philippe Gerum
2007-02-19 21:24                     ` Gilles Chanteperdrix
2007-02-19 22:43                       ` Philippe Gerum
2007-02-19  8:10                 ` Philippe Gerum
2007-02-19 22:48       ` Gilles Chanteperdrix
2007-02-19 23:26         ` 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=45D9989E.4070103@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=rpm@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.