1 2011-11-14 Andreas Schwab <schwab@redhat.com>
3 * malloc/arena.c (arena_get2): Don't call reused_arena when
6 2011-11-10 Andreas Schwab <schwab@redhat.com>
8 * malloc/arena.c (_int_new_arena): Don't increment narenas.
9 (reused_arena): Don't check arena limit.
10 (arena_get2): Atomically check arena limit.
12 diff --git a/malloc/arena.c b/malloc/arena.c
13 index 9114fd2..042cac8 100644
16 @@ -747,8 +747,6 @@ _int_new_arena(size_t size)
22 (void)mutex_unlock(&list_lock);
25 @@ -786,30 +784,6 @@ get_free_list (void)
29 - if (narenas <= mp_.arena_test)
32 - static int narenas_limit;
33 - if (narenas_limit == 0)
35 - if (mp_.arena_max != 0)
36 - narenas_limit = mp_.arena_max;
39 - int n = __get_nprocs ();
42 - narenas_limit = NARENAS_FROM_NCORES (n);
44 - /* We have no information about the system. Assume two
46 - narenas_limit = NARENAS_FROM_NCORES (2);
50 - if (narenas < narenas_limit)
54 static mstate next_to_use;
55 if (next_to_use == NULL)
56 @@ -844,10 +818,41 @@ arena_get2(mstate a_tsd, size_t size)
60 - if ((a = get_free_list ()) == NULL
61 - && (a = reused_arena ()) == NULL)
62 - /* Nothing immediately available, so generate a new arena. */
63 - a = _int_new_arena(size);
64 + static size_t narenas_limit;
66 + a = get_free_list ();
69 + /* Nothing immediately available, so generate a new arena. */
70 + if (narenas_limit == 0)
72 + if (mp_.arena_max != 0)
73 + narenas_limit = mp_.arena_max;
76 + int n = __get_nprocs ();
79 + narenas_limit = NARENAS_FROM_NCORES (n);
81 + /* We have no information about the system. Assume two
83 + narenas_limit = NARENAS_FROM_NCORES (2);
88 + if (__builtin_expect (n <= mp_.arena_test || n < narenas_limit, 0))
90 + if (catomic_compare_and_exchange_bool_acq(&narenas, n + 1, n))
92 + a = _int_new_arena (size);
93 + if (__builtin_expect (a != NULL, 1))
95 + catomic_decrement(&narenas);
97 + a = reused_arena ();
101 a = a_tsd = &main_arena;
103 commit a5fb313cb7b7e692fd4684916aaa98e03ec7e8b6
104 Author: Andreas Schwab <schwab@redhat.com>
105 Date: Mon Nov 14 11:41:52 2011 +0100
107 Don't call reused_arena when _int_new_arena failed
109 diff --git a/malloc/arena.c b/malloc/arena.c
110 index 042cac8..cb8548b 100644
113 @@ -844,14 +844,14 @@ arena_get2(mstate a_tsd, size_t size)
115 if (__builtin_expect (n <= mp_.arena_test || n < narenas_limit, 0))
117 - if (catomic_compare_and_exchange_bool_acq(&narenas, n + 1, n))
118 + if (catomic_compare_and_exchange_bool_acq (&narenas, n + 1, n))
120 a = _int_new_arena (size);
121 - if (__builtin_expect (a != NULL, 1))
123 - catomic_decrement(&narenas);
124 + if (__builtin_expect (a == NULL, 0))
125 + catomic_decrement (&narenas);
127 - a = reused_arena ();
129 + a = reused_arena ();