This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.23-229-g2bc983b


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  2bc983b78c215765979a29a2e98b0cc01791c2d1 (commit)
      from  00277a3f81bf023d4562da485f62efe5b5b30388 (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 -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2bc983b78c215765979a29a2e98b0cc01791c2d1

commit 2bc983b78c215765979a29a2e98b0cc01791c2d1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Apr 23 06:05:01 2016 -0700

    Reduce number of mmap calls from __libc_memalign in ld.so
    
    __libc_memalign in ld.so allocates one page at a time and tries to
    optimize consecutive __libc_memalign calls by hoping that the next
    mmap is after the current memory allocation.
    
    However, the kernel hands out mmap addresses in top-down order, so
    this optimization in practice never happens, with the result that we
    have more mmap calls and waste a bunch of space for each __libc_memalign.
    
    This change makes __libc_memalign to mmap one page extra.  Worst case,
    the kernel never puts a backing page behind it, but best case it allows
    __libc_memalign to operate much much better.  For elf/tst-align --direct,
    it reduces number of mmap calls from 12 to 9.
    
    	* elf/dl-minimal.c (__libc_memalign): Mmap one extra page.

diff --git a/ChangeLog b/ChangeLog
index 5cd8c40..744c0c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-04-23   H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf/dl-minimal.c (__libc_memalign): Mmap one extra page.
+
 2016-04-23  Mike Frysinger  <vapier@gentoo.org>
 
 	* locale/programs/ld-time.c (time_finish): Set week_1stweek to 7
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index 762e65b..c8a8f8d 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -66,15 +66,13 @@ __libc_memalign (size_t align, size_t n)
 
   if (alloc_ptr + n >= alloc_end || n >= -(uintptr_t) alloc_ptr)
     {
-      /* Insufficient space left; allocate another page.  */
+      /* Insufficient space left; allocate another page plus one extra
+	 page to reduce number of mmap calls.  */
       caddr_t page;
       size_t nup = (n + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
-      if (__glibc_unlikely (nup == 0))
-	{
-	  if (n)
-	    return NULL;
-	  nup = GLRO(dl_pagesize);
-	}
+      if (__glibc_unlikely (nup == 0 && n != 0))
+	return NULL;
+      nup += GLRO(dl_pagesize);
       page = __mmap (0, nup, PROT_READ|PROT_WRITE,
 		     MAP_ANON|MAP_PRIVATE, -1, 0);
       if (page == MAP_FAILED)

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

Summary of changes:
 ChangeLog        |    4 ++++
 elf/dl-minimal.c |   12 +++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]