From 7538d461134bf306e31b40e4032f0c225bb40d51 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 2 Jun 2020 10:33:30 +0200 Subject: nptl: Make pthread_attr_t dynamically extensible This introduces the function __pthread_attr_extension to allocate the extension space, which is freed by pthread_attr_destroy. Reviewed-by: Carlos O'Donell --- sysdeps/unix/sysv/linux/createthread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sysdeps/unix') diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c index 21f9d24..6588893 100644 --- a/sysdeps/unix/sysv/linux/createthread.c +++ b/sysdeps/unix/sysv/linux/createthread.c @@ -52,8 +52,10 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, /* Determine whether the newly created threads has to be started stopped since we have to set the scheduling parameters or set the affinity. */ + bool need_setaffinity = (attr != NULL && attr->extension != NULL + && attr->extension->cpuset != 0); if (attr != NULL - && (__glibc_unlikely (attr->cpuset != NULL) + && (__glibc_unlikely (need_setaffinity) || __glibc_unlikely ((attr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0))) *stopped_start = true; @@ -113,12 +115,13 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, int res; /* Set the affinity mask if necessary. */ - if (attr->cpuset != NULL) + if (need_setaffinity) { assert (*stopped_start); res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, - attr->cpusetsize, attr->cpuset); + attr->extension->cpusetsize, + attr->extension->cpuset); if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res))) err_out: -- cgit v1.1