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

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).