TASKSET(1)
Linux User’s Manual TASKSET(1) NAME taskset - retrieve or set a process’s CPU affinity SYNOPSIS taskset [options] mask command [arg]... taskset [options] -p [mask] pid DESCRIPTION taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications. The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Not all CPUs may exist on a given system but a mask may specify more CPUs than are present. A retrieved mask will reflect only the bits that correspond to CPUs physically on the system. If an invalid mask is given (i.e., one that corresponds to no valid CPUs on the current system) an error is returned. The masks are typically given in hexadecimal. For example, 0x00000001 is processor #0 0x00000003 is processors #0 and #1 0xFFFFFFFF is all processors (#0 through #31) When taskset returns, it is guaranteed that the given program has been scheduled to a legal CPU. OPTIONS -p, --pid operate on an existing PID and not launch a new task -c, --cpu-list specify a numerical list of processors instead of a bitmask. The list may contain multiple items, separated by comma, and ranges. For example, 0,5,7,9-11. -h, --help display usage information and exit -V, --version output version information and exit USAGE The default behavior is to run a new command with a given affinity mask: taskset mask command [arguments] You can also retrieve the CPU affinity of an existing task: taskset -p pid Or set it: taskset -p mask pid PERMISSIONS A user must possess CAP_SYS_NICE to change the CPU affinity of a process. Any user can retrieve the affinity mask. AUTHOR Written by Robert M. Love. ======================================================================================================= Description of problem: Install Fedora 9 (sorry, I can not find the entry for F9 bug report). Set one task affinity to one CPU core, then set offline the CPU core. After that we can not set online the CPU core again. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. run the test.sh script: test.sh 1 ( 1 is the logical CPU ) test.sh script: #!/bin/bash main(){ typeset -i CPU=$1 ./task.sh > /dev/null& PID=$! if [ `cat /sys/devices/system/cpu/cpu${CPU}/online` = "0" ]; then echo "1" > /sys/devices/system/cpu/cpu${CPU}/online fi MASK=$((1<<${CPU})) `taskset -p ${MASK} ${PID} > /dev/null 2>&1` echo "0" > /sys/devices/system/cpu/cpu${CPU}/online echo "1" > /sys/devices/system/cpu/cpu${CPU}/online disown $PID kill -9 $PID > /dev/null 2>&1 echo "PASS\n" } typeset -i TEST_CPU=$1 main $TEST_CPU 2. task.sh script as following #!/bin/bash while : do NOOP=1 done 3. Actual results: The test.sh will block at set online the CPU ( echo "1" > /sys/devices/system/cpu/cpu${CPU}/online ). Expected results: Additional info: Happened in Intel Bensley platform (2xXeon 2.83G Harpertown C0, chipset Blackford G1, 160 SATA) ------- Comment #1
>From Bill Nottingham 2008-02-18 13:07:03
EDT -------
------- Comment #2
>From Song, Youquan 2008-02-21 03:59:48
EDT -------
Yes. the kernel 2.6.24 to 2.6.25-rc2 also exit the bug. But the bug is not exit at kernel 2.6.18. ------- Comment #3
>From Chuck Ebbert 2008-02-25 17:33:21 EDT
-------
Does the CPU mask of the running process get changed when the processor is offlined? And can you get a system state (alt-sysrq-t) when the script hangs? ------- Comment #4
>From Song, Youquan 2008-02-27 04:15:50
EDT -------
Yes, after I set offline the CPU, I use commands "taskset -p $PID and ps -- pid=$PID -o psr" to find that process CPU mask is change and process migrate to other CPU correctly. Attachment is the Screenshot.png ------- Comment #5
>From Song, Youquan 2008-02-27 04:18:13
EDT -------
Created an attachment (id=296037) [details]
CPU can not do hotplug when one task set affinity to it.
------- Comment #6
>From Song, Youquan 2008-02-27 05:02:48
EDT -------
Created an attachment (id=296040) [details]
Alt-Sysrq-t log after run the script
------- Comment #7
>From Song, Youquan 2008-04-11 07:17:23
EDT -------
This bug is still exits on FC9 Beta. ------- Comment #8
>From Bug Zapper 2008-05-14 01:12:51 EDT
-------
Changing version to '9' as part of upcoming Fedora 9 GA. More information and reason for this action is here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping |