From: Carlos O'Donell <carlos@systemhalted.org>
To: John David Anglin <dave.anglin@bell.net>
Cc: Parisc List <linux-parisc@vger.kernel.org>
Subject: Re: Thread stack allocation
Date: Mon, 10 Sep 2012 15:02:01 -0400 [thread overview]
Message-ID: <504E3929.1010605@systemhalted.org> (raw)
In-Reply-To: <504E0B28.6010406@bell.net>
On 9/10/2012 11:45 AM, John David Anglin wrote:
> On 9/10/2012 11:13 AM, Carlos O'Donell wrote:
>> On 9/9/2012 6:24 PM, John David Anglin wrote:
>>> >On 9-Sep-12, at 4:23 PM, John David Anglin wrote:
>>> >
>>>> >>It seems to me this must be a kernel bug:
>>> >
>>> >Nope, it's a problem with guard page allocation in openjdk.
>>> >It assumes stack grows down.
>> Yes, that's wrong:-)
>>
>> If you allocate your own stacks then glibc can't setup guard
>> pages for you since it violates some POSIX constraints.
> I need to study the situation in more detail but what I found is openjdk
> initially allocates a fairly large stack with pthread_attr_setstacksize,
> then it mucks with this region setting up guard pages, etc. This goes
> seriously wrong on parisc and the initial thread is only left with a stack
> which is 4096 bytes.
>
> I disabled guard pages and the build went a lot further, but died again
> due to what appears to be another stack related issue. If this package
> is to work again, it's going to need significant porting to fix the stack
> handling. I think there was a parisc patch at one time but I think it
> has been removed...
>
> If I understand correctly, we have on parisc a guard region followed
> by TLS stuff at the top of stack. I assume that the stack size allocated
> with pthread_attr_setstacksize is fully available to the user.
No. This is what the glibc bug is about and it's what I'm fixing right now.
No matter what you do glibc allocates static tls, guard pages, and several
other things *from* the stack size you set.
This is wrong for many reasons, and we're fixing stack size accounting
upstream. Until the fix is in, which would be ~2.17 timeframe this isn't
going to get better.
If you have a small-ish stack, with lots of static tls variables, then you
loose and need to manually allocate your own stack of the appropriate size
to hold everything you need (not that there is any API to figure that out)
and do it all manually.
After the fix goes in the size you request via pthread_attr_setstacksize
will be the real size you have access to use and proper stack analysis
tools will be useful again :-)
Cheers,
Carlos.
prev parent reply other threads:[~2012-09-10 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 17:52 Thread stack allocation John David Anglin
2012-09-09 20:23 ` John David Anglin
2012-09-09 22:24 ` John David Anglin
2012-09-10 15:13 ` Carlos O'Donell
2012-09-10 15:45 ` John David Anglin
2012-09-10 19:02 ` Carlos O'Donell [this message]
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=504E3929.1010605@systemhalted.org \
--to=carlos@systemhalted.org \
--cc=dave.anglin@bell.net \
--cc=linux-parisc@vger.kernel.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.