mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Add single-threaded path to _int_malloc
This patch adds single-threaded fast paths to _int_malloc. * malloc/malloc.c (_int_malloc): Add SINGLE_THREAD_P path.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2017-10-23 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
|
* malloc/malloc.c (_int_malloc): Add SINGLE_THREAD_P path.
|
||||||
|
|
||||||
2017-10-23 Wilco Dijkstra <wdijkstr@arm.com>
|
2017-10-23 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
* malloc/malloc.c (__libc_malloc): Add SINGLE_THREAD_P path.
|
* malloc/malloc.c (__libc_malloc): Add SINGLE_THREAD_P path.
|
||||||
|
@ -3568,37 +3568,50 @@ _int_malloc (mstate av, size_t bytes)
|
|||||||
{
|
{
|
||||||
idx = fastbin_index (nb);
|
idx = fastbin_index (nb);
|
||||||
mfastbinptr *fb = &fastbin (av, idx);
|
mfastbinptr *fb = &fastbin (av, idx);
|
||||||
mchunkptr pp = *fb;
|
mchunkptr pp;
|
||||||
REMOVE_FB (fb, victim, pp);
|
victim = *fb;
|
||||||
if (victim != 0)
|
|
||||||
{
|
|
||||||
if (__builtin_expect (fastbin_index (chunksize (victim)) != idx, 0))
|
|
||||||
malloc_printerr ("malloc(): memory corruption (fast)");
|
|
||||||
check_remalloced_chunk (av, victim, nb);
|
|
||||||
#if USE_TCACHE
|
|
||||||
/* While we're here, if we see other chunks of the same size,
|
|
||||||
stash them in the tcache. */
|
|
||||||
size_t tc_idx = csize2tidx (nb);
|
|
||||||
if (tcache && tc_idx < mp_.tcache_bins)
|
|
||||||
{
|
|
||||||
mchunkptr tc_victim;
|
|
||||||
|
|
||||||
/* While bin not empty and tcache not full, copy chunks over. */
|
if (victim != NULL)
|
||||||
while (tcache->counts[tc_idx] < mp_.tcache_count
|
{
|
||||||
&& (pp = *fb) != NULL)
|
if (SINGLE_THREAD_P)
|
||||||
|
*fb = victim->fd;
|
||||||
|
else
|
||||||
|
REMOVE_FB (fb, pp, victim);
|
||||||
|
if (__glibc_likely (victim != NULL))
|
||||||
|
{
|
||||||
|
size_t victim_idx = fastbin_index (chunksize (victim));
|
||||||
|
if (__builtin_expect (victim_idx != idx, 0))
|
||||||
|
malloc_printerr ("malloc(): memory corruption (fast)");
|
||||||
|
check_remalloced_chunk (av, victim, nb);
|
||||||
|
#if USE_TCACHE
|
||||||
|
/* While we're here, if we see other chunks of the same size,
|
||||||
|
stash them in the tcache. */
|
||||||
|
size_t tc_idx = csize2tidx (nb);
|
||||||
|
if (tcache && tc_idx < mp_.tcache_bins)
|
||||||
{
|
{
|
||||||
REMOVE_FB (fb, tc_victim, pp);
|
mchunkptr tc_victim;
|
||||||
if (tc_victim != 0)
|
|
||||||
|
/* While bin not empty and tcache not full, copy chunks. */
|
||||||
|
while (tcache->counts[tc_idx] < mp_.tcache_count
|
||||||
|
&& (tc_victim = *fb) != NULL)
|
||||||
{
|
{
|
||||||
|
if (SINGLE_THREAD_P)
|
||||||
|
*fb = tc_victim->fd;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
REMOVE_FB (fb, pp, tc_victim);
|
||||||
|
if (__glibc_unlikely (tc_victim == NULL))
|
||||||
|
break;
|
||||||
|
}
|
||||||
tcache_put (tc_victim, tc_idx);
|
tcache_put (tc_victim, tc_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
void *p = chunk2mem (victim);
|
void *p = chunk2mem (victim);
|
||||||
alloc_perturb (p, bytes);
|
alloc_perturb (p, bytes);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user