mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 00:31:08 +00:00
(allocate_stack): If MULTI_PAGE_ALIASING is defined and the size of the stack which must be allocated is a multiple, allocate one more page.
This commit is contained in:
parent
3be9dc8e14
commit
59b28a2e4b
@ -379,6 +379,15 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
|
|||||||
pd = get_cached_stack (&size, &mem);
|
pd = get_cached_stack (&size, &mem);
|
||||||
if (pd == NULL)
|
if (pd == NULL)
|
||||||
{
|
{
|
||||||
|
/* To avoid aliasing effects on a larger scale then pages we
|
||||||
|
adjust the allocated stack size if necessary. This way
|
||||||
|
allocations directly following each other will not have
|
||||||
|
aliasing problems. */
|
||||||
|
#if MULTI_PAGE_ALIASING != 0
|
||||||
|
if ((size % MULTI_PAGE_ALIASING) == 0)
|
||||||
|
size += pagesize_m1 + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
mem = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
mem = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS | ARCH_MAP_FLAGS, -1, 0);
|
MAP_PRIVATE | MAP_ANONYMOUS | ARCH_MAP_FLAGS, -1, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user