From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jeff Weber <jwamsc@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] avoiding page faults
Date: Thu, 14 Apr 2011 14:18:03 +0200 [thread overview]
Message-ID: <4DA6E5FB.1050204@domain.hid> (raw)
In-Reply-To: <BANLkTi=fp61zxZyg=gGt4moNNw_hLa8_og@domain.hid>
Jeff Weber wrote:
> I wish to avoid unwanted transitions of POSIX pthreads to secondary mode due
> to page faults.
>
> Does calling
> mlockall(MCL_CURRENT | MCL_FUTURE)
>
> lock pages when the memory is allocated, or referenced?
>
> From reviewing Xenomai, Linux RT_PREEMPT, and RTAI code, it appears the
> answer is that memory is locked when the page is "referenced" (not
> allocated), and that referencing by write is preferred over referencing by
> read. xeno_fault_stack() appears to pre-fault a subset of the stack when
> turning the calling thread into a Xenomai thread.
>
> If true, then I should allocate my own stack for each pthread created in my
> program, and write every page ahead of time, then
> call pthread_attr_setstack() prior to thread creation. I should also write
> every page of every dynamically allocated memory object.
>
> Please help me verify if this understanding is correct.
mlockall(MCL_CURRENT) locks all the memory currently mapped.
mlockall(MCL_FUTURE) will lock all the memory when it is allocated/mapped.
The only thing which remains allocated on demand is the main thread
stack. This explains why we use xeno_fault_stack(), which faults a
"reasonable" amount of stack, in order to get the kernel to allocate and
map memory.
--
Gilles.
next prev parent reply other threads:[~2011-04-14 12:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 15:59 [Xenomai-help] avoiding page faults Jeff Weber
2011-04-14 12:18 ` Gilles Chanteperdrix [this message]
2011-04-14 14:44 ` Jeff Weber
2011-04-14 15:03 ` Gilles Chanteperdrix
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=4DA6E5FB.1050204@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=jwamsc@domain.hid \
--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.