]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh740506.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/pmueller/ipfire-2.x.git] / src / patches / glibc / glibc-rh740506.patch
1 2011-11-14 Andreas Schwab <schwab@redhat.com>
2
3 * malloc/arena.c (arena_get2): Don't call reused_arena when
4 _int_new_arena failed.
5
6 2011-11-10 Andreas Schwab <schwab@redhat.com>
7
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.
11
12 diff --git a/malloc/arena.c b/malloc/arena.c
13 index 9114fd2..042cac8 100644
14 --- a/malloc/arena.c
15 +++ b/malloc/arena.c
16 @@ -747,8 +747,6 @@ _int_new_arena(size_t size)
17 main_arena.next = a;
18
19 #ifdef PER_THREAD
20 - ++narenas;
21 -
22 (void)mutex_unlock(&list_lock);
23 #endif
24
25 @@ -786,30 +784,6 @@ get_free_list (void)
26 static mstate
27 reused_arena (void)
28 {
29 - if (narenas <= mp_.arena_test)
30 - return NULL;
31 -
32 - static int narenas_limit;
33 - if (narenas_limit == 0)
34 - {
35 - if (mp_.arena_max != 0)
36 - narenas_limit = mp_.arena_max;
37 - else
38 - {
39 - int n = __get_nprocs ();
40 -
41 - if (n >= 1)
42 - narenas_limit = NARENAS_FROM_NCORES (n);
43 - else
44 - /* We have no information about the system. Assume two
45 - cores. */
46 - narenas_limit = NARENAS_FROM_NCORES (2);
47 - }
48 - }
49 -
50 - if (narenas < narenas_limit)
51 - return NULL;
52 -
53 mstate result;
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)
57 mstate a;
58
59 #ifdef PER_THREAD
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;
65 +
66 + a = get_free_list ();
67 + if (a == NULL)
68 + {
69 + /* Nothing immediately available, so generate a new arena. */
70 + if (narenas_limit == 0)
71 + {
72 + if (mp_.arena_max != 0)
73 + narenas_limit = mp_.arena_max;
74 + else
75 + {
76 + int n = __get_nprocs ();
77 +
78 + if (n >= 1)
79 + narenas_limit = NARENAS_FROM_NCORES (n);
80 + else
81 + /* We have no information about the system. Assume two
82 + cores. */
83 + narenas_limit = NARENAS_FROM_NCORES (2);
84 + }
85 + }
86 + repeat:;
87 + size_t n = narenas;
88 + if (__builtin_expect (n <= mp_.arena_test || n < narenas_limit, 0))
89 + {
90 + if (catomic_compare_and_exchange_bool_acq(&narenas, n + 1, n))
91 + goto repeat;
92 + a = _int_new_arena (size);
93 + if (__builtin_expect (a != NULL, 1))
94 + return a;
95 + catomic_decrement(&narenas);
96 + }
97 + a = reused_arena ();
98 + }
99 #else
100 if(!a_tsd)
101 a = a_tsd = &main_arena;
102
103 commit a5fb313cb7b7e692fd4684916aaa98e03ec7e8b6
104 Author: Andreas Schwab <schwab@redhat.com>
105 Date: Mon Nov 14 11:41:52 2011 +0100
106
107 Don't call reused_arena when _int_new_arena failed
108
109 diff --git a/malloc/arena.c b/malloc/arena.c
110 index 042cac8..cb8548b 100644
111 --- a/malloc/arena.c
112 +++ b/malloc/arena.c
113 @@ -844,14 +844,14 @@ arena_get2(mstate a_tsd, size_t size)
114 size_t n = narenas;
115 if (__builtin_expect (n <= mp_.arena_test || n < narenas_limit, 0))
116 {
117 - if (catomic_compare_and_exchange_bool_acq(&narenas, n + 1, n))
118 + if (catomic_compare_and_exchange_bool_acq (&narenas, n + 1, n))
119 goto repeat;
120 a = _int_new_arena (size);
121 - if (__builtin_expect (a != NULL, 1))
122 - return a;
123 - catomic_decrement(&narenas);
124 + if (__builtin_expect (a == NULL, 0))
125 + catomic_decrement (&narenas);
126 }
127 - a = reused_arena ();
128 + else
129 + a = reused_arena ();
130 }
131 #else
132 if(!a_tsd)