Blame SOURCES/glibc-rh740506-2.patch

b9ba6d
	* malloc/arena.c (arena_get2): Avoid unnecessarily
b9ba6d
	retrieving #cpus from /proc.
b9ba6d
	* malloc/malloc.c (mALLOPt): Clamp arena_test based on
b9ba6d
	the value of arena_max.
b9ba6d
b9ba6d
diff --git a/malloc/arena.c b/malloc/arena.c
b9ba6d
index cb8548b..00f1da5 100644
b9ba6d
--- a/malloc/arena.c
b9ba6d
+++ b/malloc/arena.c
b9ba6d
@@ -828,7 +828,7 @@ arena_get2(mstate a_tsd, size_t size)
b9ba6d
 	{
b9ba6d
 	  if (mp_.arena_max != 0)
b9ba6d
 	    narenas_limit = mp_.arena_max;
b9ba6d
-	  else
b9ba6d
+	  else if (narenas > mp_.arena_test)
b9ba6d
 	    {
b9ba6d
 	      int n  = __get_nprocs ();
b9ba6d
 
b9ba6d
diff --git a/malloc/malloc.c b/malloc/malloc.c
b9ba6d
index 8608083..f8d32da 100644
b9ba6d
--- a/malloc/malloc.c
b9ba6d
+++ b/malloc/malloc.c
b9ba6d
@@ -6134,6 +6134,12 @@ int mALLOPt(param_number, value) int par
b9ba6d
     break;
b9ba6d
 #endif
b9ba6d
   }
b9ba6d
+#ifdef PER_THREAD
b9ba6d
+  /* Clamp ARENA_TEST from ARENA_MAX to avoid creating too many
b9ba6d
+     arenas.  */
b9ba6d
+  if (mp_.arena_max > 0 && mp_.arena_max <= mp_.arena_test)
b9ba6d
+    mp_.arena_test = mp_.arena_max - 1;
b9ba6d
+#endif
b9ba6d
   (void)mutex_unlock(&av->mutex);
b9ba6d
   return res;
b9ba6d
 }