glibc/manual
Florian Weimer 2359035ac5 Remove CPU set size checking from affinity functions [BZ #19143]
With current kernel versions, the check does not reliably detect that
unavailable CPUs are requested, for these reasons:

(1) The kernel will silently ignore non-allowed CPUs, that is, CPUs
    which are physically present but disallowed for the thread
    based on system configuration.

(2) Similarly, CPU bits which lack an online CPU (possible CPUs)
    are ignored.

(3) The existing probing code assumes that the CPU mask size is a
    power of two and at least 1024.  Neither has it to be a power
    of two, nor is the minimum possible value 1024, so the value
    determined is often too large.  This means that the CPU set
    size check in glibc accepts CPU bits beyond the actual hard
    system limit.

(4) Future kernel versions may not even have a fixed CPU set size.

After the removal of the probing code, the kernel still returns
EINVAL if no CPU in the requested set remains which can run the
thread after the affinity change.

Applications which care about the exact affinity mask will have
to query it using sched_getaffinity after setting it.  Due to the
effects described above, this commit does not change this.

The new tests supersede tst-getcpu, which is removed.  This
addresses bug 19164 because the new tests allocate CPU sets
dynamically.

	* nptl/check-cpuset.h: Remove.
	* nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new):
	Remove CPU set size check.
	* nptl/pthread_setattr_default_np.c (pthread_setattr_default_np):
	Likewise.
	* sysdeps/unix/sysv/linux/check-cpuset.h: Remove.
	* sysdeps/unix/sysv/linux/pthread_setaffinity.c
	(__kernel_cpumask_size, __determine_cpumask_size): Remove.
	(__pthread_setaffinity_new): Remove CPU set size check.
	* sysdeps/unix/sysv/linux/sched_setaffinity.c
	(__kernel_cpumask_size): Remove.
	(__sched_setaffinity_new): Remove CPU set size check.
	* manual/threads.texi (Default Thread Attributes): Remove stale
	reference to check_cpuset_attr, determine_cpumask_size in comment.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) == posix] (tests):
	Remove tst-getcpu.  Add tst-affinity, tst-affinity-pid.
	[$(subdir) == nptl] (tests): Add tst-thread-affinity-pthread,
	tst-thread-affinity-pthread2, tst-thread-affinity-sched.
	* sysdeps/unix/sysv/linux/tst-affinity.c: New file.
	* sysdeps/unix/sysv/linux/tst-affinity-pid.c: New file.
	* sysdeps/unix/sysv/linux/tst-skeleton-affinity.c: New skeleton test file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-skeleton-affinity.c: New
	skeleton test file.
	* sysdeps/unix/sysv/linux/tst-getcpu.c: Remove.  Superseded by
	tst-affinity-pid.
2015-11-24 17:21:01 +01:00
..
examples Convert 29 more function definitions to prototype style (multiple parameters in one K&R parameter declaration). 2015-10-20 11:52:27 +00:00
argp.texi manual/argp.texi (Specifying Argp Parsers): Fix typo. 2015-10-14 11:49:58 -04:00
arith.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
charset.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
check-safety.sh Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
conf.texi * manual/conf.texi: Document MTASC-safety properties. 2014-01-29 05:26:47 -02:00
contrib.texi glibc 2.21 pre-release update. 2015-02-05 23:14:38 -05:00
creature.texi Remove _BSD_SOURCE and _SVID_SOURCE. 2014-02-11 23:40:07 +00:00
crypt.texi * manual/crypt.texi: Document MTASC-safety properties. 2014-01-29 05:27:54 -02:00
ctype.texi * manual/ctype.texi: Document MTASC-safety properties. 2014-01-31 23:14:14 -02:00
debug.texi * manual/debug.texi: Document MTASC-safety properties. 2014-01-30 18:50:57 -02:00
dir .. 2005-11-21 15:45:19 +00:00
errno.texi manual: complete example in error message documentation 2015-03-06 00:59:49 -05:00
fdl-1.3.texi BZ#13738: Switch manual to FDL 1.3. 2012-02-24 12:58:10 -08:00
filesys.texi Fix manual argument order for posix_fallocate64 (Bug 19086). 2015-10-07 14:10:43 -04:00
freemanuals.texi Update to canonical freemanuals.texi file. 2013-09-24 14:06:56 -07:00
getopt.texi * manual/getopt.texi: Document MTASC-safety properties. 2014-01-31 23:16:56 -02:00
header.texi Use Texinfo macros to refer to the GNU C Library within the manual. 2012-02-28 14:44:20 +00:00
install-plain.texi BZ #15941: Fix INSTALL file regeneration failure with makeinfo 5.x 2013-12-05 09:58:20 +05:30
install.texi Require GCC 4.7 or later to build glibc. 2015-10-27 16:34:12 +00:00
intro.texi manual: Sort overview listing by manual order. 2014-04-17 19:41:09 -04:00
io.texi Clean up glibc manual references to "GNU system" (bug 6911). 2012-03-08 01:27:38 +00:00
ipc.texi manual/ipc.texi: Fix AC-safety notes. 2014-04-08 17:12:15 -04:00
job.texi ctermid: return string literal, document MT-Safety pitfall 2014-11-21 02:16:02 -02:00
lang.texi * manual/lang.texi: Document MTASC-safety properties. 2014-01-31 23:21:48 -02:00
lgpl-2.1.texi Use canonical FSF .texi files for LGPL and FDL texts. 2011-06-06 16:16:55 -07:00
libc-texinfo.sh Add @detailmenu to subsection node listing 2013-02-24 21:05:58 +10:00
libc.texinfo Update copyright dates not handled by scripts/update-copyrights. 2015-01-02 16:54:45 +00:00
libcbook.texi initial import 1995-02-18 01:27:10 +00:00
libdl.texi * manual/libdl.texi: New. 2014-01-31 23:23:59 -02:00
libm-err-tab.pl Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
llio.texi Fix exponents in manual. 2015-08-20 09:43:50 +02:00
locale.texi manual: Update the locale documentation 2014-07-10 16:30:40 +02:00
macros.texi Fix exponents in manual. 2015-08-20 09:43:50 +02:00
maint.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
Makefile manual: skip build when perl is unavailable 2015-08-21 17:10:59 -04:00
math.texi Refine documentation of libm exceptions goals. 2015-02-17 23:41:27 +00:00
memory.texi malloc: Rewrite with explicit TLS access using __thread 2015-10-17 12:06:48 +02:00
message.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
nss.texi manual: Remove frobnicate @pxref. 2013-02-20 13:30:23 -05:00
nsswitch.texi update from main archive 960814 1996-08-15 01:23:29 +00:00
pattern.texi Avoid SIGFPE in wordexp [BZ #18100] 2015-03-23 16:12:38 +01:00
pipe.texi * manual/pipe.texi: Document MTASC-safety properties. 2014-01-31 23:37:28 -02:00
platform.texi PowerPC: Extend Program Priority Register support 2015-08-19 17:43:26 -03:00
probes.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
process.texi Add a new "Inter-Process Communication" chapter. 2014-02-26 11:05:09 -05:00
resource.texi Fix typo in manual. 2014-06-05 01:13:04 +02:00
search.texi manual: Correct guarantee about pointers compared by qsort() 2014-12-21 14:11:32 +01:00
setjmp.texi manual/setjmp.texi: Clarify setcontext and signal handlers text 2014-04-17 11:40:36 +01:00
signal.texi Fix crossreference to nonexistent node BSD Handler 2014-11-18 11:19:20 +01:00
socket.texi Fix two spaces after sentence. 2014-02-26 23:27:38 +01:00
startup.texi Remove _BSD_SOURCE and _SVID_SOURCE. 2014-02-11 23:40:07 +00:00
stdio-fp.c update from main archive 970225 1997-02-25 05:18:05 +00:00
stdio.texi The va_list pointer is unspecified after a call to vfprintf [BZ #18982] 2015-10-17 12:02:22 +02:00
string.texi Fix typo in safety annotations in envz_remove 2015-05-20 02:36:13 +05:30
summary.awk Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
sysinfo.texi manual: fix addmntent's MT-Safety race annotation 2014-11-21 02:45:02 -02:00
syslog.texi * manual/syslog.texi: Document MTASC-safety properties. 2014-02-01 01:22:09 -02:00
terminal.texi * manual/terminal.texi: Document MTASC-safety properties. 2014-02-01 03:53:15 -02:00
texinfo.tex Update miscellaneous files from upstream sources. 2014-06-26 20:13:44 +00:00
texis.awk Correct close statement. 2001-05-18 13:01:32 +00:00
threads.texi Remove CPU set size checking from affinity functions [BZ #19143] 2015-11-24 17:21:01 +01:00
time.texi * manual/time.texi (TZ Variable): glibc no longer comes with tzdata. 2015-02-16 15:32:34 -08:00
tsort.awk Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
users.texi manual: cuserid is mtasurace if not passed a string 2014-11-21 02:15:09 -02:00
xtract-typefun.awk * manual/xtract-typefun.awk: Swallow [(){}*] from function names. 2003-11-12 00:50:03 +00:00