File glibc-2.3.90-ld.so-madvise.diff of Package glibc

Index: elf/dl-load.c
===================================================================
--- elf/dl-load.c.orig
+++ elf/dl-load.c
@@ -1219,6 +1219,9 @@ cannot allocate TLS data structures for 
 	    goto call_lose_errno;
 	  }
 
+	if (GLRO(dl_madvise))
+	  posix_fadvise (fd, c->mapoff, maplength, POSIX_FADV_WILLNEED);
+
 	l->l_map_end = l->l_map_start + maplength;
 	l->l_addr = l->l_map_start - c->mapstart;
 
Index: elf/dl-support.c
===================================================================
--- elf/dl-support.c.orig
+++ elf/dl-support.c
@@ -41,6 +41,7 @@ size_t _dl_platformlen;
 
 int _dl_debug_mask;
 int _dl_lazy;
+int _dl_madvise;
 ElfW(Addr) _dl_use_load_bias = -2;
 int _dl_dynamic_weak;
 
@@ -240,6 +241,8 @@ _dl_non_dynamic_init (void)
 
   _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
 
+  _dl_madvise = *(getenv ("LD_NOMADVISE") ?: "") == '\0';
+
   _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
 
   _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
Index: elf/rtld.c
===================================================================
--- elf/rtld.c.orig
+++ elf/rtld.c
@@ -152,6 +152,7 @@ struct rtld_global_ro _rtld_global_ro at
     ._dl_lazy = 1,
     ._dl_fpu_control = _FPU_DEFAULT,
     ._dl_pointer_guard = 1,
+    ._dl_madvise = 1,
 
     /* Function pointers.  */
     ._dl_debug_printf = _dl_debug_printf,
@@ -2619,6 +2620,14 @@ process_envvars (enum mode *modep)
 	  break;
 
 	case 9:
+	  /* Test whether we should not advise the kernel
+	     about memory usage.  */
+	  if (memcmp (envline, "NOMADVISE", 9) == 0)
+	    {
+	      GLRO(dl_madvise) = envline[10] == '\0';
+	      break;
+	    }
+
 	  /* Test whether we want to see the content of the auxiliary
 	     array passed up from the kernel.  */
 	  if (!INTUSE(__libc_enable_secure)
Index: sysdeps/generic/ldsodefs.h
===================================================================
--- sysdeps/generic/ldsodefs.h.orig
+++ sysdeps/generic/ldsodefs.h
@@ -567,6 +567,9 @@ struct rtld_global_ro
   /* Do we do lazy relocations?  */
   EXTERN int _dl_lazy;
 
+  /* Should we advise kernel about memory usage? */
+  EXTERN int _dl_madvise;
+
   /* Nonzero if runtime lookups should not update the .got/.plt.  */
   EXTERN int _dl_bind_not;
openSUSE Build Service is sponsored by