Set SHMLBA to page size on hppa (BZ locale/19838)

Submitted by John David Anglin on April 16, 2017, 6:48 p.m.

Details

Message ID E9292D0C-BC4F-45BC-919C-290E3195FF13@bell.net
State New
Headers show

Commit Message

John David Anglin April 16, 2017, 6:48 p.m.
Setting SHMLBA to 4MB results in applications failing to allocate memory using mmap too early.
Examples are localedef and perl.

The attached patch fixes this by reducing SHMLBA to the page size (4096).

The patch has been installed on Debian for a long time.  It goes back to the following discussion:
https://patchwork.kernel.org/patch/3933841/

Although there may be issues in old IPC applications, the general consensus is that the smaller
4KB value is more useful.  I might add that the kernel code in sys_parisc.c does 4MB color alignment
for file and shared maps.

Please install.

Dave
--
John David Anglin	dave.anglin@bell.net
2017-04-16  John David Anglin  <danglin@gcc.gnu.org>

	[BZ locale/19838]
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h (SHMLBA): Align to page
	boundary using __getpagesize.

Comments

Andreas Schwab April 16, 2017, 8 p.m.
On Apr 16 2017, John David Anglin <dave.anglin@bell.net> wrote:

> +#define SHMLBA		(__getpagesize ())

SHMLBA must be a constant.

Andreas.
John David Anglin April 16, 2017, 8:17 p.m.
On 2017-04-16, at 4:00 PM, Andreas Schwab wrote:

> On Apr 16 2017, John David Anglin <dave.anglin@bell.net> wrote:
> 
>> +#define SHMLBA		(__getpagesize ())
> 
> SHMLBA must be a constant.


Are you sure?  __getpagesize() is used on some other targets including x86.

Dave
--
John David Anglin	dave.anglin@bell.net
Andreas Schwab April 16, 2017, 8:25 p.m.
On Apr 16 2017, John David Anglin <dave.anglin@bell.net> wrote:

> On 2017-04-16, at 4:00 PM, Andreas Schwab wrote:
>
>> On Apr 16 2017, John David Anglin <dave.anglin@bell.net> wrote:
>> 
>>> +#define SHMLBA		(__getpagesize ())
>> 
>> SHMLBA must be a constant.
>
>
> Are you sure?

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_shm.h.html#tag_13_59_03

Andreas.
Florian Weimer April 16, 2017, 9:11 p.m.
* John David Anglin:

> On 2017-04-16, at 4:00 PM, Andreas Schwab wrote:
>
>> On Apr 16 2017, John David Anglin <dave.anglin@bell.net> wrote:
>> 
>>> +#define SHMLBA		(__getpagesize ())
>> 
>> SHMLBA must be a constant.
>
>
> Are you sure?  __getpagesize() is used on some other targets including x86.

Well, we should probably fix that.

I find it difficult to believe that we will ever get anything but 4K
pages on x86-64 because much too much would break as a result.

But it seems to me that POSIX is wrong here because the page size
isn't a context in other contexts, and as you describe, just having
some arbitrary multiple of the actual page size tends to cause
problems.

Patch hide | download patch | download mbox

diff --git a/sysdeps/unix/sysv/linux/hppa/bits/shm.h b/sysdeps/unix/sysv/linux/hppa/bits/shm.h
index 794f0ab2da..52632d0dea 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/shm.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/shm.h
@@ -37,7 +37,7 @@ 
 #define SHM_UNLOCK	12		/* unlock segment (root only) */
 
 /* Segment low boundary address multiple.  */
-#define SHMLBA 0x00400000		/* address needs to be 4 Mb aligned */
+#define SHMLBA		(__getpagesize ())
 
 /* Type to count number of attaches.  */
 typedef unsigned long int shmatt_t;