mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Update.
2003-02-03 Ulrich Drepper <drepper@redhat.com> * allocatestack.c (allocate_stack): Implement coloring of the allocated stack memory. Rename pagesize to pagesize_m1. It's the size minus one. Adjust users.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2003-02-03 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* allocatestack.c (allocate_stack): Implement coloring of the
|
||||||
|
allocated stack memory. Rename pagesize to pagesize_m1. It's the
|
||||||
|
size minus one. Adjust users.
|
||||||
|
|
||||||
2003-02-02 Ulrich Drepper <drepper@redhat.com>
|
2003-02-02 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* allocatestack.c: Improve comment throughout the file.
|
* allocatestack.c: Improve comment throughout the file.
|
||||||
|
@ -77,6 +77,9 @@ hidden_def (__stack_user)
|
|||||||
/* Number of threads running. */
|
/* Number of threads running. */
|
||||||
static unsigned int nptl_nthreads = 1;
|
static unsigned int nptl_nthreads = 1;
|
||||||
|
|
||||||
|
/* Number of threads created. */
|
||||||
|
static unsigned int nptl_ncreated;
|
||||||
|
|
||||||
|
|
||||||
/* Check whether the stack is still used or not. */
|
/* Check whether the stack is still used or not. */
|
||||||
#define FREE_P(descr) ((descr)->tid == 0)
|
#define FREE_P(descr) ((descr)->tid == 0)
|
||||||
@ -224,10 +227,10 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
|
|||||||
{
|
{
|
||||||
struct pthread *pd;
|
struct pthread *pd;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t pagesize = __sysconf (_SC_PAGESIZE);
|
size_t pagesize_m1 = __sysconf (_SC_PAGESIZE) - 1;
|
||||||
|
|
||||||
assert (attr != NULL);
|
assert (attr != NULL);
|
||||||
assert (powerof2 (pagesize));
|
assert (powerof2 (pagesize_m1 + 1));
|
||||||
assert (TCB_ALIGNMENT >= STACK_ALIGN);
|
assert (TCB_ALIGNMENT >= STACK_ALIGN);
|
||||||
|
|
||||||
/* Get the stack size from the attribute if it is set. Otherwise we
|
/* Get the stack size from the attribute if it is set. Otherwise we
|
||||||
@ -309,15 +312,24 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
|
|||||||
size_t reqsize;
|
size_t reqsize;
|
||||||
void *mem;
|
void *mem;
|
||||||
|
|
||||||
|
#if COLORING_INCREMENT != 0
|
||||||
|
/* Add one more page for stack coloring. Don't to it for stacks
|
||||||
|
with 16 times pagesize or larger. This might just cause
|
||||||
|
unnecessary misalignment. */
|
||||||
|
if (size <= 16 * pagesize_m1)
|
||||||
|
size += pagesize_m1 + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Adjust the stack size for alignment. */
|
/* Adjust the stack size for alignment. */
|
||||||
size &= ~(__static_tls_align - 1);
|
size &= ~(__static_tls_align - 1);
|
||||||
assert (size != 0);
|
assert (size != 0);
|
||||||
|
|
||||||
/* Make sure the size of the stack is enough for the guard and
|
/* Make sure the size of the stack is enough for the guard and
|
||||||
eventually the thread descriptor. */
|
eventually the thread descriptor. */
|
||||||
guardsize = (attr->guardsize + pagesize - 1) & ~(pagesize - 1);
|
guardsize = (attr->guardsize + pagesize_m1) & ~pagesize_m1;
|
||||||
if (__builtin_expect (size < (guardsize + __static_tls_size
|
if (__builtin_expect (size < (guardsize + __static_tls_size
|
||||||
+ MINIMAL_REST_STACK), 0))
|
+ MINIMAL_REST_STACK + pagesize_m1 + 1),
|
||||||
|
0))
|
||||||
/* The stack is too small (or the guard too large). */
|
/* The stack is too small (or the guard too large). */
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
@ -336,8 +348,31 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
|
|||||||
never get a NULL pointer back from MMAP. */
|
never get a NULL pointer back from MMAP. */
|
||||||
assert (mem != NULL);
|
assert (mem != NULL);
|
||||||
|
|
||||||
|
#if COLORING_INCREMENT != 0
|
||||||
|
/* Atomically increment NCREATED. */
|
||||||
|
unsigned int ncreated = atomic_exchange_and_add (&nptl_ncreated, 1);
|
||||||
|
|
||||||
|
/* We chose the offset for coloring by incrementing it for
|
||||||
|
every new thread by a fixed amount. The offset used
|
||||||
|
module the page size. Even if coloring would be better
|
||||||
|
relative to higher alignment values it makes no sense to
|
||||||
|
do it since the mmap() interface does not allow us to
|
||||||
|
specify any alignment for the returned memory block. */
|
||||||
|
size_t coloring = (ncreated * COLORING_INCREMENT) & pagesize_m1;
|
||||||
|
|
||||||
|
/* Make sure the coloring offsets does not disturb the alignment
|
||||||
|
of the TCB and static TLS block. */
|
||||||
|
if (__builtin_expect ((coloring & (__static_tls_align - 1)) != 0, 0))
|
||||||
|
coloring = (((coloring + __static_tls_align - 1)
|
||||||
|
& ~(__static_tls_align - 1))
|
||||||
|
& ~pagesize_m1);
|
||||||
|
#else
|
||||||
|
/* Unless specified we do not make any adjustments. */
|
||||||
|
# define coloring 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Place the thread descriptor at the end of the stack. */
|
/* Place the thread descriptor at the end of the stack. */
|
||||||
pd = (struct pthread *) ((char *) mem + size) - 1;
|
pd = (struct pthread *) ((char *) mem + size - coloring) - 1;
|
||||||
|
|
||||||
/* Remember the stack-related values. */
|
/* Remember the stack-related values. */
|
||||||
pd->stackblock = mem;
|
pd->stackblock = mem;
|
||||||
|
2
sysdeps/unix/sysv/linux/configure
vendored
2
sysdeps/unix/sysv/linux/configure
vendored
@ -117,7 +117,7 @@ case "$machine" in
|
|||||||
arch_minimum_kernel=2.0.10
|
arch_minimum_kernel=2.0.10
|
||||||
;;
|
;;
|
||||||
powerpc/powerpc64)
|
powerpc/powerpc64)
|
||||||
arch_minimum_kernel=2.4.21
|
arch_minimum_kernel=2.4.19
|
||||||
;;
|
;;
|
||||||
s390/s390-32)
|
s390/s390-32)
|
||||||
libc_cv_gcc_unwind_find_fde=yes
|
libc_cv_gcc_unwind_find_fde=yes
|
||||||
|
Reference in New Issue
Block a user