ICC Home Privacy and Legal Notice LC User Documents Banner

UCRL-WEB-200040

CHAOS: Linux from Livermore


TASKSET (Set CPU Affinity)

TASKSET lets you manage the CPU affinity of your processes on LC Linux/CHAOS machines that have NUMA hardware. The Linux scheduler honors the CPU affinity that you declare with TASKSET and will not run the specified process on any other CPUs (or you can discover a process's previously set CPU affinity). The parent of this subsection explains the meaning of NUMA hardware and CPU affinity more fully. TASKSET can operate on a running process (if you know its PID) or you can launch a new command with a specified CPU affinity. NUMACTL reports information helpful for planning your use of TASKSET.

SYNTAX:
TASKSET has a rather unusual execute-line syntax. To run it, type:

taskset options [mask|cpulist] [pid|command]

where (from right to left) pid or command specifies the process whose CPU affinity you want to control, mask or cpulist specifies which CPUs you want to bind to the target process (either by hexadecimal bitmask or comma-delimited list of CPU numbers, perhaps with hyphenated ranges), and options guide TASKSET's behavior. The available options are:

-p
(--pid) targets a specified running process using its PID instead of launching a new command. WARNING: the PID always comes at the right-hand end of the execute line even though the -p option comes at the left-hand end, counterintuitively separated by the affinity mask or list of CPUs. See the examples below.
-c
(--cpu-list) specifies CPU affinity with a comma-delimited list of CPU numbers instead of with a hexadecimal mask. (Again, the argument for -c falls between -p and its argument if both -p and -c are used. See the examples below.)
-h
(--help) displays a short list of available options and ends.
-V
(uppercase vee, --version) reports the current TASKSET version and ends.

EXAMPLES:
Typical examples of using TASKSET and its unusual syntax include--

(A) Report the current CPU affinity (mask) for the process with PID 10403:

taskset -p 10403

(B) Set to hexadecimal ff the CPU affinity (mask) for the process with PID 10403 (note the unusual ordering of the arguments here, with PID on the right-hand end of the excute line):

taskset -p ff 10403

(C) Set to CPUs 5 and 6 the affinity of running process 10403 (again note the unusual order of the two arguments):

taskset -pc 5-6 10403

(D) Execute the DATE command only on CPU 4:

taskset -c 4 date



Navigation Links: [ Document List ] [ HPC Home ] [ Next ]