public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable
@ 2013-11-19 14:55 ams at sourceware dot org
  2013-11-19 15:55 ` [Bug ports/16191] " schwab@linux-m68k.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ams at sourceware dot org @ 2013-11-19 14:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

            Bug ID: 16191
           Summary: PAGE_SIZE defined constant on MIPS, but size is
                    configurable
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ports
          Assignee: unassigned at sourceware dot org
          Reporter: ams at sourceware dot org
                CC: carlos at redhat dot com, roland at gnu dot org

The sys/user.h header defines PAGE_SIZE to a constant (4096), but that figure
is not always accurate; the page size is a kernel configuration option.

  #define PAGE_SHIFT              12
  #define PAGE_SIZE               (1UL << PAGE_SHIFT)
  #define PAGE_MASK               (~(PAGE_SIZE-1))
  #define NBPG                    PAGE_SIZE
  #define UPAGES                  1
  #define HOST_TEXT_START_ADDR    (u.start_code)
  #define HOST_DATA_START_ADDR    (u.start_data)
  #define HOST_STACK_END_ADDR     (u.start_stack + u.u_ssize * NBPG)

A knock-on effect of this bug is that sysdeps/unix/sysv/linux/ifaddrs.c uses an
"optimization" when PAGE_SIZE is constant that means getifaddrs will always
fail when the real page size does not match PAGE_SIZE.

  #ifdef PAGE_SIZE
    /* Help the compiler optimize out the malloc call if PAGE_SIZE
       is constant and smaller or equal to PTHREAD_STACK_MIN/4.  */
    const size_t buf_size = PAGE_SIZE;
  #else
    const size_t buf_size = __getpagesize ();
  #endif

According to Andrew Pinski, the constant PAGE_SIZE is not appropriate on any
MIPS variant, so at least some of the above macros can be removed. Other
architectures appear to remove all of them, but it's not clear that that's
correct on MIPS.

This issue probably applied to other architectures also. Joseph Myers has
mentioned MicroBlaze.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
@ 2013-11-19 15:55 ` schwab@linux-m68k.org
  2013-11-19 16:02 ` joseph at codesourcery dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab@linux-m68k.org @ 2013-11-19 15:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |2.18

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
IMHO the PAGE_SIZE macro should be removed from all architectures.  BFD doesn't
need it, which is the only purpose of <sys/user.h>.  It is a mistake to use it
for anything else.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
  2013-11-19 15:55 ` [Bug ports/16191] " schwab@linux-m68k.org
@ 2013-11-19 16:02 ` joseph at codesourcery dot com
  2013-11-19 16:13 ` carlos at redhat dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2013-11-19 16:02 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=16191

--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
What about the other macros - PAGE_SHIFT, PAGE_MASK, NBPG, UPAGES, 
HOST_TEXT_START_ADDR, HOST_DATA_START_ADDR, HOST_STACK_END_ADDR?  Should 
some or all of those also be removed from <sys/user.h> for all 
architectures?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
  2013-11-19 15:55 ` [Bug ports/16191] " schwab@linux-m68k.org
  2013-11-19 16:02 ` joseph at codesourcery dot com
@ 2013-11-19 16:13 ` carlos at redhat dot com
  2013-11-19 16:45 ` schwab@linux-m68k.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: carlos at redhat dot com @ 2013-11-19 16:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Andrew Stubbs from comment #0)
> The sys/user.h header defines PAGE_SIZE to a constant (4096), but that
> figure is not always accurate; the page size is a kernel configuration
> option.
...
> According to Andrew Pinski, the constant PAGE_SIZE is not appropriate on any
> MIPS variant, so at least some of the above macros can be removed. Other
> architectures appear to remove all of them, but it's not clear that that's
> correct on MIPS.

>From the standards point of view if we define PAGE_SIZE we must also define
PAGESIZE and in limits.h. We don't define PAGESIZE or PAGE_SIZE in limits.h,
and therefore there are no compile-time constants for these values in standards
compliant headers.

The question of what to do with sys/user.h PAGE_SIZE define is less clear. We
still define PAGE_SIZE for x86, x86_64, MIPS, MicroBlaze, s390, s390x, and
Alpha. It isn't clear what user application compatibility issues will arise if
we remove the PAGE_SIZE definition for MIPS.

I agree that if the kernel built-in page size is larger then user applications
making use of PAGE_SIZE won't work correctly. However, they will work correctly
and continue to compile correctly if the kernel page size matches.

The other problem is that there are several kernel headers that use PAGE_SIZE
(/usr/include/linux/binfmts.h, /usr/include/linux/resource.h,
/usr/include/linux/kvm.h), what happens to those if glibc stops defining
PAGE_SIZE for MIPS? What of the applications that use those headers?

How do you propose we tackle the issue of:

(a) Compatibility with applications expecting PAGE_SIZE to be defined?

and

(b) Kernel headers that require PAGE_SIZE?

Note: In glibc we use EXEC_PAGESIZE which must be as big as the largest kernel
page size, and that's your limiting factor to increasing the page size in the
kernel (otherwise mapping anything including dlopen'd libraries won't work
reliably). Once we've started up sufficiently we obviously use AT_PAGESZ to
determine the correct page size value and that's what is returned via sysconf
(_SC_PAGESIZE).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (2 preceding siblings ...)
  2013-11-19 16:13 ` carlos at redhat dot com
@ 2013-11-19 16:45 ` schwab@linux-m68k.org
  2013-11-20 17:27 ` ams at sourceware dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab@linux-m68k.org @ 2013-11-19 16:45 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=16191

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
BFD's trad-core wants NBPG, UPAGES, HOST_TEXT_START_ADDR, HOST_STACK_END_ADDR,
HOST_DATA_START_ADDR, HOST_STACK_START_ADDR (the latter two being optional). 
The other macros are only defined because the kernel header <asm/user.h>
defines NBPG in terms of PAGE_SIZE for most architectures.

New architectures should not use trad-core, so have no need to defined these
macros at all.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (3 preceding siblings ...)
  2013-11-19 16:45 ` schwab@linux-m68k.org
@ 2013-11-20 17:27 ` ams at sourceware dot org
  2013-11-20 17:36 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ams at sourceware dot org @ 2013-11-20 17:27 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

Andrew Stubbs <ams at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #5 from Andrew Stubbs <ams at sourceware dot org> ---
Judging by the thread on libc-ports

https://sourceware.org/ml/libc-ports/2013-11/msg00028.html

and what's written here, I think the consensus is that we can probably just
apply Andrew Pinski's patch.

https://sourceware.org/ml/libc-ports/2013-11/msg00035.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ports/16191] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (4 preceding siblings ...)
  2013-11-20 17:27 ` ams at sourceware dot org
@ 2013-11-20 17:36 ` joseph at codesourcery dot com
  2014-02-11  0:29 ` [Bug libc/16191] [mips] " jsm28 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2013-11-20 17:36 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=16191

--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Based on the discussion so far I think we can conclude:

* tst-limits.c should, if PAGE_SIZE is kept at all, include <sys/user.h> 
to get and test the definition.

* If a platform has variable page size in the kernel, PAGE_SIZE, 
PAGE_SHIFT and PAGE_MASK should be removed.

* IA64, MIPS and MicroBlaze (a) have variable page size and (b) do not use 
trad-core, so the full set of these macros should be removed from their 
headers (not just the subset removed by Andrew Pinski's patch).  (IA64 
doesn't define PAGE_SIZE, so isn't actually affected by this bug, but 
defines NBPG in terms of PAGE_SIZE.)

Does someone wish to produce a patch removing all the relevant macros for 
MIPS, MicroBlaze and IA64, and send it to libc-ports, CC:ing the 
maintainers for those ports?  Then, if not also fixing tst-limits and 
working out whether PAGE_SIZE should be removed completely, file separate 
issues for those or put them on the wiki todo list 
<https://sourceware.org/glibc/wiki/Development_Todo/Master> so they don't 
get lost.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/16191] [mips] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (5 preceding siblings ...)
  2013-11-20 17:36 ` joseph at codesourcery dot com
@ 2014-02-11  0:29 ` jsm28 at gcc dot gnu.org
  2014-06-13 12:00 ` fweimer at redhat dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-02-11  0:29 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper.fsp at gmail dot com
          Component|ports                       |libc
               Host|                            |mips*-*-linux*
            Summary|PAGE_SIZE defined constant  |[mips] PAGE_SIZE defined
                   |on MIPS, but size is        |constant on MIPS, but size
                   |configurable                |is configurable

--- Comment #7 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Andrew, as I said in https://sourceware.org/ml/libc-ports/2013-12/msg00021.html
the MIPS changes from
https://sourceware.org/ml/libc-ports/2013-12/msg00017.html are OK and should be
committed (of course, now they won't involve ports at all, just the MIPS file
in libc, the NEWS file and the toplevel ChangeLog) - though MicroBlaze and IA64
will need separate bugs and weekly patch pings until those are fixed too.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/16191] [mips] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (6 preceding siblings ...)
  2014-02-11  0:29 ` [Bug libc/16191] [mips] " jsm28 at gcc dot gnu.org
@ 2014-06-13 12:00 ` fweimer at redhat dot com
  2015-01-05 13:48 ` cvs-commit at gcc dot gnu.org
  2015-02-16 16:23 ` jsm28 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 12:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/16191] [mips] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (7 preceding siblings ...)
  2014-06-13 12:00 ` fweimer at redhat dot com
@ 2015-01-05 13:48 ` cvs-commit at gcc dot gnu.org
  2015-02-16 16:23 ` jsm28 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-01-05 13:48 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  b1efe3bbcfd94941556ffd5b60539207023c8224 (commit)
      from  b93c2205ec57af3c0491cdb608b53a9b4d7ff57e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b1efe3bbcfd94941556ffd5b60539207023c8224

commit b1efe3bbcfd94941556ffd5b60539207023c8224
Author: Matthew Fortune <matthew.fortune@imgtec.com>
Date:   Mon Jan 5 13:34:41 2015 +0000

    Fix MIPS variable PAGE_SIZE bug (16191)

    MIPS supports a variable page size but glibc defines a constant.
    This causes at least two glibc tests to fail when the page size
    does not match the hard-coded size:

    inet/test-ifaddrs
    inet/test_ifindex

        [BZ #16191]
        * NEWS: Mention bug fix.
        * sysdeps/unix/sysv/linux/mips/sys/user.h (PAGE_SHIFT): Remove.
        (PAGE_SIZE, PAGE_MASK, NBPG, UPAGES): Likewise.
        (HOST_TEXT_START_ADDR, HOST_DATA_START_ADDR): Likewise.
        (HOST_STACK_END_ADDR): Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                               |    9 +++++++++
 NEWS                                    |   14 +++++++-------
 sysdeps/unix/sysv/linux/mips/sys/user.h |    9 ---------
 3 files changed, 16 insertions(+), 16 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/16191] [mips] PAGE_SIZE defined constant on MIPS, but size is configurable
  2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
                   ` (8 preceding siblings ...)
  2015-01-05 13:48 ` cvs-commit at gcc dot gnu.org
@ 2015-02-16 16:23 ` jsm28 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-02-16 16:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16191

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
The fix was checked in for 2.21.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-02-16 16:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19 14:55 [Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable ams at sourceware dot org
2013-11-19 15:55 ` [Bug ports/16191] " schwab@linux-m68k.org
2013-11-19 16:02 ` joseph at codesourcery dot com
2013-11-19 16:13 ` carlos at redhat dot com
2013-11-19 16:45 ` schwab@linux-m68k.org
2013-11-20 17:27 ` ams at sourceware dot org
2013-11-20 17:36 ` joseph at codesourcery dot com
2014-02-11  0:29 ` [Bug libc/16191] [mips] " jsm28 at gcc dot gnu.org
2014-06-13 12:00 ` fweimer at redhat dot com
2015-01-05 13:48 ` cvs-commit at gcc dot gnu.org
2015-02-16 16:23 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).