All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] pre-fault Xenomai thread stacks
@ 2012-06-15 19:12 Jeff Weber
  2012-06-15 19:16 ` Gilles Chanteperdrix
  2012-06-15 19:34 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff Weber @ 2012-06-15 19:12 UTC (permalink / raw)
  To: Xenomai Mailing List

I occasionally run across net lore which recommends "pre-faulting" a stack.
 For example:
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example

>From my understanding of mlockall(MCL_CURRENT|MCL_FUTURE), all process
memory is paged and locked in.  Thus, a pre-faulting exercise appears
useless.
(I don't care about the main() thread.)  Can you confirm?

thanks,
Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai] pre-fault Xenomai thread stacks
  2012-06-15 19:12 [Xenomai] pre-fault Xenomai thread stacks Jeff Weber
@ 2012-06-15 19:16 ` Gilles Chanteperdrix
  2012-06-15 19:22   ` Jeff Weber
  2012-06-15 19:34 ` Gilles Chanteperdrix
  1 sibling, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2012-06-15 19:16 UTC (permalink / raw)
  To: Jeff Weber; +Cc: Xenomai Mailing List

On 06/15/2012 09:12 PM, Jeff Weber wrote:
> I occasionally run across net lore which recommends "pre-faulting" a stack.
>  For example:
> https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example
> 
> From my understanding of mlockall(MCL_CURRENT|MCL_FUTURE), all process
> memory is paged and locked in.  Thus, a pre-faulting exercise appears
> useless.
> (I don't care about the main() thread.)  Can you confirm?

Last time I checked, only the main thread stack was grown on demand, so
required pre-faulting the stack, which is why xenomai takes care of
pre-faulting the main thread stack.

To verify this, you have to check /proc/self/maps. If the thread stack
belongs to a mapping of a size you would not expect, try writing below
the limit, to see if you get a fault, or if the mapping grows in
/proc/self/maps.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai] pre-fault Xenomai thread stacks
  2012-06-15 19:16 ` Gilles Chanteperdrix
@ 2012-06-15 19:22   ` Jeff Weber
  2012-06-15 19:27     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Weber @ 2012-06-15 19:22 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai Mailing List

On Fri, Jun 15, 2012 at 2:16 PM, Gilles Chanteperdrix <
gilles.chanteperdrix@xenomai.org> wrote:

> On 06/15/2012 09:12 PM, Jeff Weber wrote:
> > I occasionally run across net lore which recommends "pre-faulting" a
> stack.
> >  For example:
> >
> https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example
> >
> > From my understanding of mlockall(MCL_CURRENT|MCL_FUTURE), all process
> > memory is paged and locked in.  Thus, a pre-faulting exercise appears
> > useless.
> > (I don't care about the main() thread.)  Can you confirm?
>
> Last time I checked, only the main thread stack was grown on demand, so
> required pre-faulting the stack, which is why xenomai takes care of
> pre-faulting the main thread stack.
>
> To verify this, you have to check /proc/self/maps. If the thread stack
> belongs to a mapping of a size you would not expect, try writing below
> the limit, to see if you get a fault, or if the mapping grows in
> /proc/self/maps.


Shouldn't those cases be covered by MCL_FUTURE?

Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai] pre-fault Xenomai thread stacks
  2012-06-15 19:22   ` Jeff Weber
@ 2012-06-15 19:27     ` Gilles Chanteperdrix
  0 siblings, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2012-06-15 19:27 UTC (permalink / raw)
  To: Jeff Weber; +Cc: Xenomai Mailing List

On 06/15/2012 09:22 PM, Jeff Weber wrote:
> On Fri, Jun 15, 2012 at 2:16 PM, Gilles Chanteperdrix <
> gilles.chanteperdrix@xenomai.org> wrote:
> 
>> On 06/15/2012 09:12 PM, Jeff Weber wrote:
>>> I occasionally run across net lore which recommends "pre-faulting" a
>> stack.
>>>  For example:
>>>
>> https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example
>>>
>>> From my understanding of mlockall(MCL_CURRENT|MCL_FUTURE), all process
>>> memory is paged and locked in.  Thus, a pre-faulting exercise appears
>>> useless.
>>> (I don't care about the main() thread.)  Can you confirm?
>>
>> Last time I checked, only the main thread stack was grown on demand, so
>> required pre-faulting the stack, which is why xenomai takes care of
>> pre-faulting the main thread stack.
>>
>> To verify this, you have to check /proc/self/maps. If the thread stack
>> belongs to a mapping of a size you would not expect, try writing below
>> the limit, to see if you get a fault, or if the mapping grows in
>> /proc/self/maps.
> 
> 
> Shouldn't those cases be covered by MCL_FUTURE?

MCL_FUTURE will prevent the memory from being swapped out as soon as the
stack is grown, but the stack is grown upon page fault. How else would
you detect that the stack needs to be grown ?

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai] pre-fault Xenomai thread stacks
  2012-06-15 19:12 [Xenomai] pre-fault Xenomai thread stacks Jeff Weber
  2012-06-15 19:16 ` Gilles Chanteperdrix
@ 2012-06-15 19:34 ` Gilles Chanteperdrix
  1 sibling, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2012-06-15 19:34 UTC (permalink / raw)
  To: Jeff Weber; +Cc: Xenomai Mailing List

On 06/15/2012 09:12 PM, Jeff Weber wrote:
> I occasionally run across net lore which recommends "pre-faulting" a stack.
>  For example:
> https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example

Note that in order to pre-fault a stack, you do not need to memset the
whole stack, you can only write a few bytes per stack page.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-15 19:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15 19:12 [Xenomai] pre-fault Xenomai thread stacks Jeff Weber
2012-06-15 19:16 ` Gilles Chanteperdrix
2012-06-15 19:22   ` Jeff Weber
2012-06-15 19:27     ` Gilles Chanteperdrix
2012-06-15 19:34 ` Gilles Chanteperdrix

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.