[ppc] Default stack size on ppc64

Steven Munroe munroesj at linux.vnet.ibm.comcom
Tue Mar 24 16:35:30 UTC 2015


On Tue, 2015-03-24 at 12:19 +0000, Richard W.M. Jones wrote:
> For the OCaml packages on ppc64/ppc64le, we keep having bugs like this
> one: https://bugzilla.redhat.com/show_bug.cgi?id=1204876
> 
> The OCaml compiler is quite recursive, and so it can easily overflow
> the default stack.  For reasons that are not entirely clear this
> happens only on ppc64/ppc64le (not on x86 or aarch64).  Perhaps POWER
> stack frames are bigger, or the default stack size is smaller.
> 
The default thread stack is 8MB-64KB plus a 64KB guard page. PPC uses a
64K default page size.

So there are two possible problems:

1) running into the guard page for a single thread.
2) the sum of all thread stacks exceeds the ulimit -s

If changing the ulimit -s solves the problem the sum of all thread
stacks has exceeded the ulimit.

If in cases where increasing the ulimit -s to unlimited does no help
then you have at least one thread that has overflowed the default stack.

Power has lots of registers (32x64b GPRs + 32x64b FPRs + 32x128b VRs) so
we are likely to need a bigger stack frame at each level. The minimums
are 112 bytes for ELF V1 ABI (PPC64BE) and 48 for ELF V2 ABI (PPC64LE),
but any interesting function will need additional space to spill
non-volatiles across function calls and store any local variables.

You (ocaml runtime) can control the stack size on a per thread basis via
pthread_attr_setstack().

I am not sure how ocaml is generating code for PPC64, you could look in
to split stack support, but at this time GCC does not implement split
stack.


> One way to "fix" this would be to modify every single ocaml-* spec
> file to add:
> 
> %ifarch %{power64}
> ulimit -s 65536
> %endif
> 
> However that doesn't fix the problem for people running ocamlopt on
> their own programs.  The issue was discussed upstream, but upstream
> don't want to make the compiler stages less mutually recursive since
> (a) it makes the code far more complex and (b) stack memory is just a
> special use-case for ordinary memory so why should they?
> 
> Could we increase the default stack size on ppc64?
> 
> Or are there other alternatives?  (I thought briefly about carrying a
> downstream compiler patch which does the equivalent of 'ulimit -s 65536'
> inside the compiler).
> 
> Rich.
> 




More information about the ppc mailing list