All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Thomas De Schampheleire <patrickdepinguin+xenomai@gmail.com>,
	xenomai@xenomai.org, Jan Kiszka <jan.kiszka@siemens.com>,
	Ronny Meeus <Ronny.Meeus@gmail.com>
Subject: Re: [Xenomai] minimum xenomai stack size (mercury)
Date: Tue, 25 Aug 2015 16:19:27 +0200	[thread overview]
Message-ID: <55DC796F.1020404@xenomai.org> (raw)
In-Reply-To: <CAAXf6LUGJPnZk7wtU5u0nthkrSiPbOKzsVuMQzfU+AqhL-OCcw@mail.gmail.com>

On 07/24/2015 02:48 PM, Thomas De Schampheleire wrote:
> Hi,
> 
> With Xenomai Mercury (specifically the PSOS skin, but that doesn't
> matter for this question), the minimal stack size applied is
> PTHREAD_STACK_MIN * 4, even if the caller requested a smaller one.
> 
> On MIPS, and some other architectures, PTHREAD_STACK_MIN is already 128K:
> (<glibc>/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/local_lim.h)
> 
> /* Minimum size for a thread. At least two pages with 64k pages. */
> #define PTHREAD_STACK_MIN 131072
> 
> With Xenomai multiplying this with 4, every thread has half a megabyte
> of stack, which is way too much for systems with a large number of
> threads.
> It is possible to limit this in other ways, by setting 'ulimit -s 128'
> for example, but it is a dirty workaround in my opinion.
> 
> What is the real minimum stack requirement for Xenomai? I cannot
> imagine that this is in the order of 512K.
> 
> With PTHREAD_STACK_MIN varying so much on different platforms, what
> about code like:
> 
> minimum_stacksize = MAX(XENOMAI_STACK_MIN, PTHREAD_STACK_MIN);
> 
> if (stacksize < minimum_stacksize) {
>     stacksize = minimum_stacksize;
> }
> 
> where XENOMAI_STACK_MIN is a value that is not calculated based on
> PTHREAD_STACK_MIN?
> 

At the end of the day, your suggestion is the best option, at least the
one that won't cause regression. I tried the other one on a couple of
large applications (expecting users to do the right thing and pass a
reasonable stack size), and the result wasn't pretty, given the sheer
number of threads created with default attribute settings, but running
stack-hungry code.

Fixed in -next, thanks.

-- 
Philippe.


  parent reply	other threads:[~2015-08-25 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 12:48 [Xenomai] minimum xenomai stack size (mercury) Thomas De Schampheleire
2015-08-19 11:03 ` Thomas De Schampheleire
2015-08-19 14:58   ` Philippe Gerum
2015-08-19 15:12     ` Thomas De Schampheleire
2015-08-19 15:35       ` Philippe Gerum
2015-08-25 14:19 ` Philippe Gerum [this message]
2015-08-25 19:19   ` Thomas De Schampheleire

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=55DC796F.1020404@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=Ronny.Meeus@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=patrickdepinguin+xenomai@gmail.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.