diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-05-24 10:33:02 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-05-24 10:33:02 +0000 |
commit | 619b79105b34179aab8ade7f232e2cfc505a22ed (patch) | |
tree | 265582300d98ffe130b2e76ff46f50834e6cdaa1 /nptl/pthread_create.c | |
parent | 75831cc48d3fef9b0bb247aabbcdaceef85efa23 (diff) | |
download | glibc-619b79105b34179aab8ade7f232e2cfc505a22ed.tar glibc-619b79105b34179aab8ade7f232e2cfc505a22ed.tar.gz glibc-619b79105b34179aab8ade7f232e2cfc505a22ed.tar.bz2 glibc-619b79105b34179aab8ade7f232e2cfc505a22ed.zip |
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r-- | nptl/pthread_create.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 79729ced03..22e8f01804 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -462,6 +462,30 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg) pd->flags = ((iattr->flags & ~(ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET)) | (self->flags & (ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET))); + /* Hack: realloc the main search list on the first pthread_create call + to minimize the number of global search scope reallocations. + Wastes at most 1KB on 32-bit and 2KB on 64-bit per process + which calls pthread_create. */ + if (__builtin_expect (self->header.multiple_threads == 0, 0) + && GL(dl_ns)[0]._ns_main_searchlist + && GL(dl_ns)[0]._ns_main_searchlist->r_nlist < 256 + && GL(dl_ns)[0]._ns_global_scope_alloc < 256) + { + struct link_map **new_global = (struct link_map **) + realloc (GL(dl_ns)[0]._ns_global_scope_alloc == 0 + ? NULL : GL(dl_ns)[0]._ns_main_searchlist->r_list, + 256 * sizeof (struct link_map *)); + if (new_global != NULL) + { + if (GL(dl_ns)[0]._ns_global_scope_alloc == 0) + memcpy (new_global, GL(dl_ns)[0]._ns_main_searchlist->r_list, + GL(dl_ns)[0]._ns_main_searchlist->r_nlist + * sizeof (struct link_map *)); + GL(dl_ns)[0]._ns_global_scope_alloc = 256; + GL(dl_ns)[0]._ns_main_searchlist->r_list = new_global; + } + } + /* Initialize the field for the ID of the thread which is waiting for us. This is a self-reference in case the thread is created detached. */ |