[resend] Allow use of MAP_TRYFIXED for better mmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On NetBSD (upcoming 1.6.2, and 1.7/2.0-current), there is a new extension
flag MAP_TRYFIXED that essentially simulates current Linux mmap behavior:
try the mmap() hint first, without clobbering mapped pages, even if the hint
falls within traditionally "protected" malloc heap space.  If the fixed
mapping fails, the block is still mapped at a relocated address, as if mmap
were called with no flags set.

With this patch, mmapping PE files on NetBSD becomes an order of magnitude
faster, as the vfork()-and-mincore() silly walk is avoided altogether.

I've implemented the patch as forward-looking, allowing other platforms to
add MAP_TRYFIXED to gain the same benefit.  (This mmap flag name does not
appear to be used in any divergent fashion on any other platform, per my
research when picking the flag's name.)

Index: libs/wine/loader.c
===================================================================
RCS file: /home/wine/wine/libs/wine/loader.c,v
retrieving revision 1.4
diff -u -r1.4 loader.c
--- libs/wine/loader.c	3 Jul 2003 18:23:10 -0000	1.4
+++ libs/wine/loader.c	26 Aug 2003 21:20:17 -0000
@@ -428,7 +428,7 @@
 }


-#if defined(__svr4__) || defined(__NetBSD__)
+#if (defined(__svr4__) || defined(__NetBSD__)) && !defined(MAP_TRYFIXED)
 /***********************************************************************
  *             try_mmap_fixed
  *
@@ -506,7 +506,7 @@

     return result == addr;
 }
-#endif  /* __svr4__ || __NetBSD__ */
+#endif  /* (__svr4__ || __NetBSD__) && !MAP_TRYFIXED */


 /***********************************************************************
@@ -541,7 +541,10 @@
     flags |= MAP_PRIVATE;
 #endif

-#if defined(__svr4__) || defined(__NetBSD__)
+#ifdef MAP_TRYFIXED
+    /* If available, this will attempt a fixed mapping in-kernel */
+    flags |= MAP_TRYFIXED;
+#elif defined(__svr4__) || defined(__NetBSD__)
     if ( try_mmap_fixed( start, size, prot, flags, fdzero, 0 ) )
         return start;
 #endif

-- 
-- Todd Vierling <tv@pobox.com>


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux