]>
Commit | Line | Data |
---|---|---|
48d7b13a KZ |
1 | .\" taskset(1) manpage |
2 | .\" | |
3 | .\" Copyright (C) 2004 Robert Love | |
4 | .\" | |
5 | .\" This is free documentation; you can redistribute it and/or | |
5aab9a1a BS |
6 | .\" modify it under the terms of the GNU General Public License, |
7 | .\" version 2, as published by the Free Software Foundation. | |
48d7b13a KZ |
8 | .\" |
9 | .\" The GNU General Public License's references to "object code" | |
10 | .\" and "executables" are to be interpreted as the output of any | |
11 | .\" document formatting or typesetting system, including | |
12 | .\" intermediate and printed output. | |
13 | .\" | |
14 | .\" This manual is distributed in the hope that it will be useful, | |
15 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | .\" GNU General Public License for more details. | |
18 | .\" | |
7cebf0bb SK |
19 | .\" You should have received a copy of the GNU General Public License along |
20 | .\" with this program; if not, write to the Free Software Foundation, Inc., | |
21 | .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
48d7b13a | 22 | .\" |
42f15e98 | 23 | .TH TASKSET 1 "August 2014" "util-linux" "User Commands" |
48d7b13a | 24 | .SH NAME |
42f15e98 | 25 | taskset \- set or retrieve a process's CPU affinity |
48d7b13a KZ |
26 | .SH SYNOPSIS |
27 | .B taskset | |
42f15e98 BS |
28 | [options] |
29 | .IR mask\ command\ [ argument ...] | |
5ebbcdf9 LJ |
30 | .br |
31 | .B taskset | |
42f15e98 | 32 | [options] |
5ebbcdf9 LJ |
33 | .B \-p |
34 | .RI [ mask ]\ pid | |
48d7b13a KZ |
35 | .SH DESCRIPTION |
36 | .PP | |
232dc924 | 37 | .B taskset |
42f15e98 BS |
38 | is used to set or retrieve the CPU affinity of a running process given its |
39 | \fIpid\fR, or to launch a new \fIcommand\fR with a given CPU affinity. | |
40 | CPU affinity is a | |
48d7b13a KZ |
41 | scheduler property that "bonds" a process to a given set of CPUs on the system. |
42 | The Linux scheduler will honor the given CPU affinity and the process will not | |
43 | run on any other CPUs. Note that the Linux scheduler also supports natural | |
44 | CPU affinity: the scheduler attempts to keep processes on the same CPU as long | |
45 | as practical for performance reasons. Therefore, forcing a specific CPU | |
46 | affinity is useful only in certain applications. | |
47 | .sp | |
48 | The CPU affinity is represented as a bitmask, with the lowest order bit | |
49 | corresponding to the first logical CPU and the highest order bit corresponding | |
50 | to the last logical CPU. Not all CPUs may exist on a given system but a mask | |
51 | may specify more CPUs than are present. A retrieved mask will reflect only the | |
52 | bits that correspond to CPUs physically on the system. If an invalid mask is | |
53 | given (i.e., one that corresponds to no valid CPUs on the current system) an | |
47bd898e | 54 | error is returned. The masks may be specified in hexadecimal (with or without |
cef04ac8 | 55 | a leading "0x"), or as a CPU list with the |
0bb7e904 | 56 | .B \-\-cpu\-list |
47bd898e | 57 | option. For example, |
42f15e98 BS |
58 | .RS 4 |
59 | .TP 12 | |
0bb7e904 | 60 | .B 0x00000001 |
42f15e98 | 61 | is processor #0, |
48d7b13a | 62 | .TP |
0bb7e904 | 63 | .B 0x00000003 |
42f15e98 | 64 | is processors #0 and #1, |
48d7b13a | 65 | .TP |
0bb7e904 | 66 | .B 0xFFFFFFFF |
47bd898e CM |
67 | is processors #0 through #31, |
68 | .TP | |
0bb7e904 | 69 | .B 32 |
47bd898e CM |
70 | is processors #1, #4, and #5, |
71 | .TP | |
0bb7e904 | 72 | .B \-\-cpu\-list\ 0-2,6 |
47bd898e | 73 | is processors #0, #1, #2, and #6. |
c313ee73 KZ |
74 | .TP |
75 | .B \-\-cpu\-list\ 0-10:2 | |
76 | is processors #0, #2, #4, #6, #8 and #10. The suffix ":N" specifies stride in | |
77 | the range, for example 0-10:3 is interpreted as 0,3,6,9 list. | |
42f15e98 | 78 | .RE |
48d7b13a KZ |
79 | .PP |
80 | When | |
0bb7e904 | 81 | .B taskset |
48d7b13a KZ |
82 | returns, it is guaranteed that the given program has been scheduled to a legal |
83 | CPU. | |
84 | .SH OPTIONS | |
85 | .TP | |
b06c1ca6 | 86 | .BR \-a ,\ \-\-all\-tasks |
64109bba | 87 | Set or retrieve the CPU affinity of all the tasks (threads) for a given PID. |
42708f12 | 88 | .TP |
59e2fea1 YK |
89 | .BR \-c ,\ \-\-cpu\-list |
90 | Interpret \fImask\fR as numerical list of processors instead of a bitmask. | |
91 | Numbers are separated by commas and may include ranges. For example: | |
42f15e98 BS |
92 | .BR 0,5,8-11 . |
93 | .TP | |
5ebbcdf9 | 94 | .BR \-p ,\ \-\-pid |
64109bba | 95 | Operate on an existing PID and do not launch a new task. |
48d7b13a | 96 | .TP |
42f15e98 BS |
97 | .BR \-V ,\ \-\-version |
98 | Display version information and exit. | |
48d7b13a | 99 | .TP |
5ebbcdf9 | 100 | .BR \-h ,\ \-\-help |
b4362b6f | 101 | Display help text and exit. |
48d7b13a KZ |
102 | .SH USAGE |
103 | .TP | |
104 | The default behavior is to run a new command with a given affinity mask: | |
5ebbcdf9 LJ |
105 | .B taskset |
106 | .I mask | |
107 | .IR command\ [ arguments ] | |
48d7b13a KZ |
108 | .TP |
109 | You can also retrieve the CPU affinity of an existing task: | |
5ebbcdf9 LJ |
110 | .B taskset \-p |
111 | .I pid | |
48d7b13a KZ |
112 | .TP |
113 | Or set it: | |
5ebbcdf9 LJ |
114 | .B taskset \-p |
115 | .I mask pid | |
48d7b13a | 116 | .SH PERMISSIONS |
ab0e0fa7 | 117 | A user can change the CPU affinity of a process belonging to the same user. |
48d7b13a | 118 | A user must possess |
5ebbcdf9 | 119 | .B CAP_SYS_NICE |
ab0e0fa7 RR |
120 | to change the CPU affinity of a process belonging to another user. |
121 | A user can retrieve the affinity mask of any process. | |
ade04bb8 MK |
122 | .SH AUTHORS |
123 | Written by Robert M. Love. | |
124 | .SH COPYRIGHT | |
125 | Copyright \(co 2004 Robert M. Love. | |
126 | This is free software; see the source for copying conditions. There is NO | |
127 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
42f15e98 | 128 | .SH SEE ALSO |
48d7b13a KZ |
129 | .BR chrt (1), |
130 | .BR nice (1), | |
131 | .BR renice (1), | |
f053ff1e MK |
132 | .BR sched_getaffinity (2), |
133 | .BR sched_setaffinity (2) | |
48d7b13a KZ |
134 | .sp |
135 | See | |
154aede1 | 136 | .BR sched (7) |
48d7b13a | 137 | for a description of the Linux scheduling scheme. |
86d62711 | 138 | .SH AVAILABILITY |
601d12fb | 139 | The taskset command is part of the util-linux package and is available from |
d673b74e | 140 | https://www.kernel.org/pub/linux/utils/util-linux/. |