672 xargs doesn't support -0
[illumos-gate.git] / usr / src / man / man1 / plgrp.1
blob95dd491b44d766dd5b970d408226e81736ebb47c
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PLGRP 1 "Sep 8, 2006"
7 .SH NAME
8 plgrp \- observe and affect home lgroup and lgroup affinities of threads
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBplgrp\fR [\fB-F\fR] [\fB-h\fR] \fIpid\fR |\fI core\fR [/\fIlwps\fR] ...
13 .fi
15 .LP
16 .nf
17 \fBplgrp\fR [\fB-F\fR] \fB-a\fR \fIlgroup_list\fR \fIpid\fR[/\fIlwps\fR] ...
18 .fi
20 .LP
21 .nf
22 \fBplgrp\fR [\fB-F\fR] \fB-H\fR \fIlgroup_list\fR \fIpid\fR[/\fIlwps\fR] ...
23 .fi
25 .LP
26 .nf
27 \fBplgrp\fR [\fB-F\fR] \fB-A\fR \fIlgroup_list\fR/\fInone\fR | \fIweak\fR |\fIstrong\fR [,...] \fIpid\fR
28      [/\fIlwps\fR] ...
29 .fi
31 .SH DESCRIPTION
32 .sp
33 .LP
34 \fBplgrp\fR displays or sets the home \fBlgroup\fR and \fBlgroup\fR affinities
35 for one or more processes, threads, or LWPs.
36 .sp
37 .LP
38 An \fBlgroup\fR represents the set of CPU and memory-like hardware devices that
39 are at most some distance (latency) apart from each other. Each \fBlgroup\fR in
40 the system is identified by a unique \fBlgroup\fR ID. The \fBlgroups\fR are
41 organized into a hierarchy to facilitate finding the nearest resources (see
42 lgrpinfo(1) for more about \fBlgroups\fR and the \fBlgroup\fR hierarchy).
43 .sp
44 .LP
45 By default, each thread is assigned a home \fBlgroup\fR upon creation. When the
46 system needs to allocate a CPU or memory resource for a thread, it searches the
47 lgroup hierarchy from the thread's home \fBlgroup\fR for the nearest available
48 resources to the thread's home.
49 .sp
50 .LP
51 Typically, the home \fBlgroup\fR for a thread is the lgroup for which the
52 thread has the most affinity. Initially, the system chooses a home \fBlgroup\fR
53 for each thread, but leaves the thread's affinity for that \fBlgroup\fR set to
54 \fBnone\fR. If a thread sets a stronger affinity for an lgroup in its processor
55 set other than its home, the thread is rehomed to that lgroup as long as the
56 thread is not bound to a CPU. The thread can be re-homed to the \fBlgroup\fR in
57 its processor set with the next highest affinity when the affinity (if any) for
58 its home \fBlgroup\fR is removed (set to \fBnone\fR).
59 .sp
60 .LP
61 The different levels of lgroup affinities and their semantics are fully
62 described in \fBlgrp_affinity_set\fR(3LGRP).
63 .SH USAGE
64 .SS "Specifying lgroups"
65 .sp
66 .LP
67 \fIlgroup_list\fR is a comma separated list of one or more of the following:
68 .sp
69 .in +2
70 .nf
71 - \fIlgroup_ID\fR
72 - Range of \fIlgroup_ID\fRs specified as
73  <start \fIlgroup_ID\fR>-<end \fIlgroup_ID\fR>
74 - all
75 - root
76 - leaves
77 .fi
78 .in -2
79 .sp
81 .sp
82 .LP
83 The \fBall\fR keyword represents all lgroup IDs in the system. The \fBroot\fR
84 keyword represents the ID of the root \fBlgroup\fR. The \fBleaves\fR keyword
85 represents the IDs of all \fBleaf\fR \fBlgroups\fR, that is, lgroups which do
86 not have any children.
87 .SS "Specifying Processes and Threads"
88 .sp
89 .LP
90 \fBplgrp\fR takes one or more space separated processes or threads as
91 arguments. Processes and threads can be specified in a manner similiar to the
92 \fBproc\fR(1) tools. A process ID may be specified as an integer \fIpid\fR or
93 \fB/proc/\fR\fIpid\fR. Shell expansions can be used to specify processes when
94 \fB/proc/\fR\fIpid\fR is used. For example, \fB/proc/*\fR can be used to
95 specify all the processes in the system. If a process ID is given alone, then
96 all the threads of the process are included as arguments to \fBplgrp\fR.
97 .sp
98 .LP
99 A thread can be explicitly specified with its process ID and thread ID given
100 together as \fIpid\fR\fB/\fR\fIlwpid\fR. Multiple threads of a process can be
101 selected at once by using the hyphen (\fB-\fR) and comma(\fB,\fR). For example,
102 \fIpid\fR\fB/1,2,7-9\fR specifies threads 1, 2, 7, 8, and 9 of the process with
103 \fIpid\fR as its process ID.
104 .SH OPTIONS
107 The following options are supported:
109 .ne 2
111 \fB\fB-a\fR \fIlgroup_list\fR\fR
113 .sp .6
114 .RS 4n
115 Display \fBlgroup\fR affinities of specified processes or threads for the
116 specified \fIlgroup_list\fR.
120 .ne 2
122 \fB\fB-A\fR \fIlgroup_list\fR\fB/\fR\fInone\fR\fB|\fR\fIweak\fR\fB|\fR\fIstrong
123 \fR\fB[,...]\fR\fR
125 .sp .6
126 .RS 4n
127 Set affinity of specified processes or threads for the specified
128 \fIlgroup_list\fR.
130 A comma separated list of \fIlgroups\fR\fB/\fR\fIaffinity\fR assignments can be
131 given to set several affinities at once.
135 .ne 2
137 \fB\fB-F\fR\fR
139 .sp .6
140 .RS 4n
141 Force by grabbing the target process even if another process has control.
142 Caution should be exercised when using the \fB-F\fR flag. Imposing two
143 controlling processes on one victim process can lead to chaos. Safety is
144 assured only when the primary controlling process (typically a debugger) has
145 stopped the victim process, but isn't doing anything during the application of
146 this proc tool. See \fBWARNINGS\fR for more details.
150 .ne 2
152 \fB\fB-h\fR\fR
154 .sp .6
155 .RS 4n
156 Get home \fBlgroup\fR of specified processes and/or threads. If no options are
157 specified, this is the default.
161 .ne 2
163 \fB\fB-H\fR \fIlgroup_list\fR\fR
165 .sp .6
166 .RS 4n
167 Set home \fBlgroup\fR of specified processes and threads.
169 This sets a strong affinity for the desired lgroup to rehome the threads. If
170 more than one \fBlgroup\fR is specified, \fBplgrp\fR tries to home the threads
171 to the \fBlgroups\fR in a round robin fashion.
174 .SH OPERANDS
177 The following operands are supported:
179 .ne 2
181 \fB\fIlwps\fR\fR
183 .RS 8n
184 Specifies thread. See \fBUSAGE\fR.
188 .ne 2
190 \fB\fIpid\fR\fR
192 .RS 8n
193 Specifies process ID. See \fBUSAGE\fR.
196 .SH EXAMPLES
198 \fBExample 1 \fRGetting the Home \fBlgroup\fR for the Shell
201 The following example gets the home \fBlgroup\fR for the shell:
204 .in +2
206 % plgrp $$
207 PID/LWPID    HOME
208 3401/1        1
210 .in -2
214 \fBExample 2 \fRSetting the Home \fBlgroup\fR of Multiple Threads to the Root
215 \fBlgroup\fR
218 The following example sets the home \fBlgroup\fR of multiple threads to the
219 root \fBlgroup\fR:
222 .in +2
224 % plgrp -H root `pgrep firefox`
225      PID/LWPID    HOME
226      918/1        1 => 0
227      934/1        2 => 0
228      934/2        1 => 0
229      934/3        2 => 0
230      934/625      1 => 0
231      934/626      2 => 0
232      934/624      2 => 0
233      934/623      2 => 0
234      934/630      1 => 0
236 .in -2
240 \fBExample 3 \fRGetting Two Threads' Affinities for \fBlgroups 0-2\fR
243 The following example gets two threads' affinities for \fBlgroups 1-2\fR:
246 .in +2
248 % plgrp -a 0-2 101398/1 101337/1
249 PID/LWPID    HOME  AFFINITY
250 101398/1        1     0-2/none
251 101337/1        1     0-2/none
253 .in -2
257 \fBExample 4 \fRSetting \fBlgroup\fR Affinities
260 The following example sets lgroup affinities:
263 .in +2
265 % plgrp -A 0/weak,1/none,2/strong 101398
266 PID/LWPID    HOME       AFFINITY
267 101398/1        1 => 2     0,2/none => 2/strong,0/weak
269 .in -2
272 .SH EXIT STATUS
275 The following exit values are returned:
277 .ne 2
279 \fB\fB0\fR\fR
281 .RS 5n
282 Successful completion.
286 .ne 2
288 \fB\fB1\fR\fR
290 .RS 5n
291 Syntax error. Nothing was changed.
295 .ne 2
297 \fB\fB2\fR\fR
299 .RS 5n
300 Non-fatal error or interrupt. Something might have changed.
303 .SH ATTRIBUTES
306 See \fBattributes\fR(5) for descriptions of the following attributes:
311 box;
312 c | c
313 l | l .
314 ATTRIBUTE TYPE  ATTRIBUTE VALUE
316 Interface Stability     See below.
321 The command syntax is Unstable. The output formats are Unstable.
322 .SH SEE ALSO
325 \fBlgrpinfo\fR(1), \fBmadv.so.1\fR(1), \fBpmadvise\fR(1), \fBpmap\fR(1),
326 \fBproc\fR(1), \fBps\fR(1), \fBprstat\fR(1M), \fBlgrp_affinity_get\fR(3LGRP),
327 \fBlgrp_affinity_set\fR(3LGRP), \fBlgrp_home\fR(3LGRP), \fBliblgrp\fR(3LIB),
328 \fBproc\fR(4), \fBattributes\fR(5)
329 .SH WARNINGS
332 Like the \fBproc\fR(1) tools, the \fBplgrp\fR utility stops its target
333 processes while inspecting them and reports the results when invoked with any
334 option.
337 There are conditions under which processes can deadlock. A process can do
338 nothing while it is stopped. Stopping a heavily used process in a production
339 environment (even for a short amount of time) can cause severe bottlenecks and
340 even hangs of these processes, making them to be unavailable to users. Thus,
341 stopping a UNIX process in a production environment should be avoided. See
342 \fBproc\fR(1).
345 A process that is stopped by this tool might be identified by issuing the
346 following command:
348 .in +2
350 /usr/bin/ps -eflL
352 .in -2
357 and looking for a \fBT\fR in the first column of the output. Certain processes,
358 for example, \fBsched\fR, can show the \fBT\fR status by default most of the
359 time.