]> git.ipfire.org Git - thirdparty/util-linux.git/blame - schedutils/taskset.1
wipefs: add --lock and LOCK_BLOCK_DEVICE
[thirdparty/util-linux.git] / schedutils / taskset.1
CommitLineData
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 25taskset \- 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
38is 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.
40CPU affinity is a
48d7b13a
KZ
41scheduler property that "bonds" a process to a given set of CPUs on the system.
42The Linux scheduler will honor the given CPU affinity and the process will not
43run on any other CPUs. Note that the Linux scheduler also supports natural
44CPU affinity: the scheduler attempts to keep processes on the same CPU as long
45as practical for performance reasons. Therefore, forcing a specific CPU
46affinity is useful only in certain applications.
47.sp
48The CPU affinity is represented as a bitmask, with the lowest order bit
49corresponding to the first logical CPU and the highest order bit corresponding
50to the last logical CPU. Not all CPUs may exist on a given system but a mask
51may specify more CPUs than are present. A retrieved mask will reflect only the
52bits that correspond to CPUs physically on the system. If an invalid mask is
53given (i.e., one that corresponds to no valid CPUs on the current system) an
47bd898e 54error is returned. The masks may be specified in hexadecimal (with or without
cef04ac8 55a leading "0x"), or as a CPU list with the
0bb7e904 56.B \-\-cpu\-list
47bd898e 57option. For example,
42f15e98
BS
58.RS 4
59.TP 12
0bb7e904 60.B 0x00000001
42f15e98 61is processor #0,
48d7b13a 62.TP
0bb7e904 63.B 0x00000003
42f15e98 64is processors #0 and #1,
48d7b13a 65.TP
0bb7e904 66.B 0xFFFFFFFF
47bd898e
CM
67is processors #0 through #31,
68.TP
0bb7e904 69.B 32
47bd898e
CM
70is processors #1, #4, and #5,
71.TP
0bb7e904 72.B \-\-cpu\-list\ 0-2,6
47bd898e 73is processors #0, #1, #2, and #6.
c313ee73
KZ
74.TP
75.B \-\-cpu\-list\ 0-10:2
76is processors #0, #2, #4, #6, #8 and #10. The suffix ":N" specifies stride in
77the range, for example 0-10:3 is interpreted as 0,3,6,9 list.
42f15e98 78.RE
48d7b13a
KZ
79.PP
80When
0bb7e904 81.B taskset
48d7b13a
KZ
82returns, it is guaranteed that the given program has been scheduled to a legal
83CPU.
84.SH OPTIONS
85.TP
b06c1ca6 86.BR \-a ,\ \-\-all\-tasks
64109bba 87Set or retrieve the CPU affinity of all the tasks (threads) for a given PID.
42708f12 88.TP
59e2fea1
YK
89.BR \-c ,\ \-\-cpu\-list
90Interpret \fImask\fR as numerical list of processors instead of a bitmask.
91Numbers 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 95Operate on an existing PID and do not launch a new task.
48d7b13a 96.TP
42f15e98
BS
97.BR \-V ,\ \-\-version
98Display version information and exit.
48d7b13a 99.TP
5ebbcdf9 100.BR \-h ,\ \-\-help
b4362b6f 101Display help text and exit.
48d7b13a
KZ
102.SH USAGE
103.TP
104The 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
109You can also retrieve the CPU affinity of an existing task:
5ebbcdf9
LJ
110.B taskset \-p
111.I pid
48d7b13a
KZ
112.TP
113Or set it:
5ebbcdf9
LJ
114.B taskset \-p
115.I mask pid
48d7b13a 116.SH PERMISSIONS
ab0e0fa7 117A user can change the CPU affinity of a process belonging to the same user.
48d7b13a 118A user must possess
5ebbcdf9 119.B CAP_SYS_NICE
ab0e0fa7
RR
120to change the CPU affinity of a process belonging to another user.
121A user can retrieve the affinity mask of any process.
ade04bb8
MK
122.SH AUTHORS
123Written by Robert M. Love.
124.SH COPYRIGHT
125Copyright \(co 2004 Robert M. Love.
126This is free software; see the source for copying conditions. There is NO
127warranty; 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
135See
154aede1 136.BR sched (7)
48d7b13a 137for a description of the Linux scheduling scheme.
86d62711 138.SH AVAILABILITY
601d12fb 139The taskset command is part of the util-linux package and is available from
d673b74e 140https://www.kernel.org/pub/linux/utils/util-linux/.