]> git.ipfire.org Git - thirdparty/util-linux.git/blob - schedutils/taskset.1
libmount: fix comment referring to passno field
[thirdparty/util-linux.git] / schedutils / taskset.1
1 .\" taskset(1) manpage
2 .\"
3 .\" Copyright (C) 2004 Robert Love
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License,
7 .\" version 2, as published by the Free Software Foundation.
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 .\"
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.
22 .\"
23 .TH TASKSET 1 "August 2014" "util-linux" "User Commands"
24 .SH NAME
25 taskset \- set or retrieve a process's CPU affinity
26 .SH SYNOPSIS
27 .B taskset
28 [options]
29 .IR mask\ command\ [ argument ...]
30 .br
31 .B taskset
32 [options]
33 .B \-p
34 .RI [ mask ]\ pid
35 .SH DESCRIPTION
36 .PP
37 .B taskset
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
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
54 error is returned. The masks may be specified in hexadecimal (with or without
55 a leading "0x"), or as a CPU list with the
56 .B \-\-cpu\-list
57 option. For example,
58 .RS 4
59 .TP 12
60 .B 0x00000001
61 is processor #0,
62 .TP
63 .B 0x00000003
64 is processors #0 and #1,
65 .TP
66 .B 0xFFFFFFFF
67 is processors #0 through #31,
68 .TP
69 .B 32
70 is processors #1, #4, and #5,
71 .TP
72 .B \-\-cpu\-list\ 0-2,6
73 is processors #0, #1, #2, and #6.
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.
78 .RE
79 .PP
80 When
81 .B taskset
82 returns, it is guaranteed that the given program has been scheduled to a legal
83 CPU.
84 .SH OPTIONS
85 .TP
86 .BR \-a ,\ \-\-all\-tasks
87 Set or retrieve the CPU affinity of all the tasks (threads) for a given PID.
88 .TP
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:
92 .BR 0,5,8-11 .
93 .TP
94 .BR \-p ,\ \-\-pid
95 Operate on an existing PID and do not launch a new task.
96 .TP
97 .BR \-V ,\ \-\-version
98 Display version information and exit.
99 .TP
100 .BR \-h ,\ \-\-help
101 Display help text and exit.
102 .SH USAGE
103 .TP
104 The default behavior is to run a new command with a given affinity mask:
105 .B taskset
106 .I mask
107 .IR command\ [ arguments ]
108 .TP
109 You can also retrieve the CPU affinity of an existing task:
110 .B taskset \-p
111 .I pid
112 .TP
113 Or set it:
114 .B taskset \-p
115 .I mask pid
116 .SH PERMISSIONS
117 A user can change the CPU affinity of a process belonging to the same user.
118 A user must possess
119 .B CAP_SYS_NICE
120 to change the CPU affinity of a process belonging to another user.
121 A user can retrieve the affinity mask of any process.
122 .SH SEE ALSO
123 .BR chrt (1),
124 .BR nice (1),
125 .BR renice (1),
126 .BR sched_getaffinity (2),
127 .BR sched_setaffinity (2)
128 .sp
129 See
130 .BR sched (7)
131 for a description of the Linux scheduling scheme.
132 .SH AUTHOR
133 Written by Robert M. Love.
134 .SH COPYRIGHT
135 Copyright \(co 2004 Robert M. Love.
136 This is free software; see the source for copying conditions. There is NO
137 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
138 .SH AVAILABILITY
139 The taskset command is part of the util-linux package and is available from
140 https://www.kernel.org/pub/linux/utils/util-linux/.