public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* hpux 10.20 and mmap everywhere
@ 2000-07-07 11:38 John David Anglin
  2000-07-07 11:44 ` Jeffrey A Law
  0 siblings, 1 reply; 6+ messages in thread
From: John David Anglin @ 2000-07-07 11:38 UTC (permalink / raw)
  To: gcc

Although hpux 10.20 doesn't have /dev/zero and mmap doesn't support MAP_ANON,
it recently came to my attention that mmap does support MAP_ANONYMOUS with a 
file descriptor of -1.  Also, you have to be somewhat careful the placement
of the mapped region.

The GNU gc routines will use mmap in preference to valloc if HAVE_MMAP_ANYWHERE
support is available.  Would the performance improvement from using mmap in
the gc routines be worth modifying configure and the gc routines for this
case?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: hpux 10.20 and mmap everywhere
  2000-07-07 11:38 hpux 10.20 and mmap everywhere John David Anglin
@ 2000-07-07 11:44 ` Jeffrey A Law
  2000-07-07 11:53   ` John David Anglin
  0 siblings, 1 reply; 6+ messages in thread
From: Jeffrey A Law @ 2000-07-07 11:44 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

  In message < 200007071838.OAA05020@hiauly1.hia.nrc.ca >you write:
  > The GNU gc routines will use mmap in preference to valloc if HAVE_MMAP_ANYW
  > HERE
  > support is available.  Would the performance improvement from using mmap in
  > the gc routines be worth modifying configure and the gc routines for this
  > case?
Using mmap is definitely preferred.  Yes, the hpux mmap is a little
different from the rest of the world.  I've complained to folks writing
autoconf tests to write them to be hpux-aware on and off for years....

jeff

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

* Re: hpux 10.20 and mmap everywhere
  2000-07-07 11:44 ` Jeffrey A Law
@ 2000-07-07 11:53   ` John David Anglin
  2000-07-07 13:38     ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: John David Anglin @ 2000-07-07 11:53 UTC (permalink / raw)
  To: law; +Cc: gcc

>   > The GNU gc routines will use mmap in preference to valloc if HAVE_MMAP_ANYW
>   > HERE
>   > support is available.  Would the performance improvement from using mmap in
>   > the gc routines be worth modifying configure and the gc routines for this
>   > case?
> Using mmap is definitely preferred.  Yes, the hpux mmap is a little
> different from the rest of the world.  I've complained to folks writing
> autoconf tests to write them to be hpux-aware on and off for years....

I believe gcc currently uses its own local autoconf tests re mmap.  They
are in aclocal.m4.  Thus, a change at this point wouldn't affect the
autoconf development, although I am sure they would be interested.  I think
what is needed is a MMAP_ANONYMOUS test.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: hpux 10.20 and mmap everywhere
  2000-07-07 11:53   ` John David Anglin
@ 2000-07-07 13:38     ` Richard Henderson
  2000-07-11 14:30       ` John David Anglin
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2000-07-07 13:38 UTC (permalink / raw)
  To: John David Anglin; +Cc: law, gcc

On Fri, Jul 07, 2000 at 02:53:19PM -0400, John David Anglin wrote:
> I think what is needed is a MMAP_ANONYMOUS test.

No, just extend the HAVE_MMAP_ANYWHERE test.  All that test is
trying to find out is if we can get zeroed pages anywhere in the
address space.

Something like

#if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif
...
#ifdef MAP_ANONYMOUS
  fd = -1;
#else
  fd = open("/dev/zero", O_RDWR);
  if (fd < 0)
    exit(1);
#endif

ggc-page.c already does something like this.  I'm surprised
that the autoconf test doesn't.


r~

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

* Re: hpux 10.20 and mmap everywhere
  2000-07-07 13:38     ` Richard Henderson
@ 2000-07-11 14:30       ` John David Anglin
  2000-07-11 21:04         ` Jeffrey A Law
  0 siblings, 1 reply; 6+ messages in thread
From: John David Anglin @ 2000-07-11 14:30 UTC (permalink / raw)
  To: Richard Henderson; +Cc: law, gcc, gcc-patches

> No, just extend the HAVE_MMAP_ANYWHERE test.  All that test is
> trying to find out is if we can get zeroed pages anywhere in the
> address space.
> 
> Something like
> 
> #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
> #define MAP_ANONYMOUS MAP_ANON
> #endif
> ...
> #ifdef MAP_ANONYMOUS
>   fd = -1;
> #else
>   fd = open("/dev/zero", O_RDWR);
>   if (fd < 0)
>     exit(1);
> #endif

The enclosed patch implements ~r's suggestion.  I revised various cooments.
I have run it through a complete bootstrap and test cycle under hpux 10.20.
There were no regressions observed.  Thus, the mmap MAP_ANONYMOUS support
under hpux appears to work ok for ggc.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2000-07-10  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* aclocal.m4 (AC_FUNC_MMAP_ANYWHERE): Extend test to detect systems
	with MAP_ANONYMOUS and MAP_ANON.
	* configure, config.in: Rebuilt.

--- aclocal.m4.orig	Mon Jun 26 12:39:16 2000
+++ aclocal.m4	Mon Jul 10 13:57:32 2000
@@ -684,19 +684,24 @@
 AC_SUBST($1)dnl
 ])
 
-# Check whether mmap can map an arbitrary page from /dev/zero, without
-# MAP_FIXED.
+# Check whether mmap can map an arbitrary page from /dev/zero or with
+# MAP_ANONYMOUS, without MAP_FIXED.
 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
 [AC_CHECK_HEADERS(unistd.h)
 AC_CHECK_FUNCS(getpagesize)
-AC_CACHE_CHECK(for working mmap from /dev/zero, ac_cv_func_mmap_anywhere,
+AC_CACHE_CHECK(for working mmap which provides zeroed pages anywhere,
+  ac_cv_func_mmap_anywhere,
 [AC_TRY_RUN([
 /* Test by Richard Henderson and Alexandre Oliva.
-   Check whether mmap from /dev/zero works. */
+   Check whether mmap MAP_ANONYMOUS or mmap from /dev/zero works. */
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/mman.h>
 
+#if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
 # ifdef HAVE_UNISTD_H
@@ -743,12 +748,19 @@
   char *x;
   int fd, pg;
 
+#ifndef MAP_ANONYMOUS
   fd = open("/dev/zero", O_RDWR);
   if (fd < 0)
     exit(1);
+#endif
 
   pg = getpagesize();
+#ifdef MAP_ANONYMOUS
+  x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE,
+                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#else
   x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+#endif
   if (x == (char *) -1)
     exit(2);
 
@@ -762,7 +774,7 @@
 ac_cv_func_mmap_anywhere=no)])
 if test $ac_cv_func_mmap_anywhere = yes; then
   AC_DEFINE(HAVE_MMAP_ANYWHERE, 1,
-	    [Define if mmap can get us zeroed pages from /dev/zero.])
+	    [Define if mmap can get us zeroed pages without MAP_FIXED.])
 fi
 ])
 

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

* Re: hpux 10.20 and mmap everywhere
  2000-07-11 14:30       ` John David Anglin
@ 2000-07-11 21:04         ` Jeffrey A Law
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey A Law @ 2000-07-11 21:04 UTC (permalink / raw)
  To: John David Anglin; +Cc: Richard Henderson, gcc, gcc-patches

  In message < 200007112129.RAA01932@hiauly1.hia.nrc.ca >you write:
  > 2000-07-10  J. David Anglin  <dave@hiauly1.hia.nrc.ca>
  > 
  > 	* aclocal.m4 (AC_FUNC_MMAP_ANYWHERE): Extend test to detect systems
  > 	with MAP_ANONYMOUS and MAP_ANON.
  > 	* configure, config.in: Rebuilt.
Thanks.  Installed.
jeff

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

end of thread, other threads:[~2000-07-11 21:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-07 11:38 hpux 10.20 and mmap everywhere John David Anglin
2000-07-07 11:44 ` Jeffrey A Law
2000-07-07 11:53   ` John David Anglin
2000-07-07 13:38     ` Richard Henderson
2000-07-11 14:30       ` John David Anglin
2000-07-11 21:04         ` Jeffrey A Law

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