diff mbox series

[COMMITTED] ggc: Reduce GGC_QUIRE_SIZE on Solaris/SPARC [PR115031]

Message ID yddcyp3cv2p.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series [COMMITTED] ggc: Reduce GGC_QUIRE_SIZE on Solaris/SPARC [PR115031] | expand

Commit Message

Rainer Orth May 30, 2024, 1:01 p.m. UTC
g++.dg/modules/pr99023_b.X currently FAILs on 32-bit Solaris/SPARC:

FAIL: g++.dg/modules/pr99023_b.X -std=c++2a  1 blank line(s) in output
FAIL: g++.dg/modules/pr99023_b.X -std=c++2a (test for excess errors)

Excess errors:
cc1plus: out of memory allocating 1048344 bytes after a total of 7913472 bytes

It turns out that this exhaustion of the 32-bit address space happens
due to a combination of three issues:

* the SPARC pagesize of 8 kB,

* ggc-page.cc's chunk size of 512 * pagesize, i.e. 4 MB, and

* mmap adding two 8 kB unmapped red-zone pages to each mapping

which result in the 4 MB mappings to actually consume 4.5 MB of address
space.

To avoid this, this patch reduces the chunk size so it remains at 4 MB
even when combined with the red-zone pages, as recommended by mmap(2).

Tested on sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11, committed
to trunk.

	Rainer

Comments

Eric Botcazou May 30, 2024, 8:47 p.m. UTC | #1
> It turns out that this exhaustion of the 32-bit address space happens
> due to a combination of three issues:
> 
> * the SPARC pagesize of 8 kB,
> 
> * ggc-page.cc's chunk size of 512 * pagesize, i.e. 4 MB, and
> 
> * mmap adding two 8 kB unmapped red-zone pages to each mapping
> 
> which result in the 4 MB mappings to actually consume 4.5 MB of address
> space.
> 
> To avoid this, this patch reduces the chunk size so it remains at 4 MB
> even when combined with the red-zone pages, as recommended by mmap(2).

Nice investigation!  This size is a host parameter rather than a target one 
though, so config/sparc/sol2.h is probably not the most appropriate place to 
override it, but I personally do not mind.
Rainer Orth May 31, 2024, 9 a.m. UTC | #2
Hi Eric,

>> It turns out that this exhaustion of the 32-bit address space happens
>> due to a combination of three issues:
>> 
>> * the SPARC pagesize of 8 kB,
>> 
>> * ggc-page.cc's chunk size of 512 * pagesize, i.e. 4 MB, and
>> 
>> * mmap adding two 8 kB unmapped red-zone pages to each mapping
>> 
>> which result in the 4 MB mappings to actually consume 4.5 MB of address
>> space.
>> 
>> To avoid this, this patch reduces the chunk size so it remains at 4 MB
>> even when combined with the red-zone pages, as recommended by mmap(2).
>
> Nice investigation!  This size is a host parameter rather than a target one 
> though, so config/sparc/sol2.h is probably not the most appropriate place to 
> override it, but I personally do not mind.

ah, I tend to forget, not having built a cross compiler in ages.  I'll
leave it as is for the moment, though, since there's no Solaris host
header ATM.

Thanks for the hint.

	Rainer
diff mbox series

Patch

# HG changeset patch
# Parent  5c140588dce73c5358387df3bb9597de45fa5524
ggc: Reduce GGC_QUIRE_SIZE on 32-bit Solaris/SPARC [PR115031]

diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -38,6 +38,9 @@  along with GCC; see the file COPYING3.  
 #undef SPARC_DEFAULT_CMODEL
 #define SPARC_DEFAULT_CMODEL CM_MEDMID
 
+/* Redue ggc-page.cc's chunk size to account for mmap red-zone pages.  */
+#define GGC_QUIRE_SIZE 510
+
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.