1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH PLGRP 1 "April 9, 2016"
.SH NAME
plgrp \- observe and affect home lgroup and lgroup affinities of threads
.SH SYNOPSIS
.LP
.nf
\fBplgrp\fR [\fB-F\fR] [\fB-h\fR] \fIpid\fR |\fI core\fR [/\fIlwps\fR] ...
.fi
.LP
.nf
\fBplgrp\fR [\fB-F\fR] \fB-a\fR \fIlgroup_list\fR \fIpid\fR[/\fIlwps\fR] ...
.fi
.LP
.nf
\fBplgrp\fR [\fB-F\fR] \fB-H\fR \fIlgroup_list\fR \fIpid\fR[/\fIlwps\fR] ...
.fi
.LP
.nf
\fBplgrp\fR [\fB-F\fR] \fB-A\fR \fIlgroup_list\fR/\fInone\fR | \fIweak\fR |\fIstrong\fR [,...] \fIpid\fR
[/\fIlwps\fR] ...
.fi
.SH DESCRIPTION
.LP
\fBplgrp\fR displays or sets the home \fBlgroup\fR and \fBlgroup\fR affinities
for one or more processes, threads, or LWPs.
.sp
.LP
An \fBlgroup\fR represents the set of CPU and memory-like hardware devices that
are at most some distance (latency) apart from each other. Each \fBlgroup\fR in
the system is identified by a unique \fBlgroup\fR ID. The \fBlgroups\fR are
organized into a hierarchy to facilitate finding the nearest resources (see
lgrpinfo(1) for more about \fBlgroups\fR and the \fBlgroup\fR hierarchy).
.sp
.LP
By default, each thread is assigned a home \fBlgroup\fR upon creation. When the
system needs to allocate a CPU or memory resource for a thread, it searches the
lgroup hierarchy from the thread's home \fBlgroup\fR for the nearest available
resources to the thread's home.
.sp
.LP
Typically, the home \fBlgroup\fR for a thread is the lgroup for which the
thread has the most affinity. Initially, the system chooses a home \fBlgroup\fR
for each thread, but leaves the thread's affinity for that \fBlgroup\fR set to
\fBnone\fR. If a thread sets a stronger affinity for an lgroup in its processor
set other than its home, the thread is rehomed to that lgroup as long as the
thread is not bound to a CPU. The thread can be re-homed to the \fBlgroup\fR in
its processor set with the next highest affinity when the affinity (if any) for
its home \fBlgroup\fR is removed (set to \fBnone\fR).
.sp
.LP
The different levels of lgroup affinities and their semantics are fully
described in \fBlgrp_affinity_set\fR(3LGRP).
.SH USAGE
.SS "Specifying lgroups"
.LP
\fIlgroup_list\fR is a comma separated list of one or more of the following:
.sp
.in +2
.nf
- \fIlgroup_ID\fR
- Range of \fIlgroup_ID\fRs specified as
<start \fIlgroup_ID\fR>-<end \fIlgroup_ID\fR>
- all
- root
- leaves
.fi
.in -2
.sp
.sp
.LP
The \fBall\fR keyword represents all lgroup IDs in the system. The \fBroot\fR
keyword represents the ID of the root \fBlgroup\fR. The \fBleaves\fR keyword
represents the IDs of all \fBleaf\fR \fBlgroups\fR, that is, lgroups which do
not have any children.
.SS "Specifying Processes and Threads"
.LP
\fBplgrp\fR takes one or more space separated processes or threads as
arguments. Processes and threads can be specified in a manner similar to the
\fBproc\fR(1) tools. A process ID may be specified as an integer \fIpid\fR or
\fB/proc/\fR\fIpid\fR. Shell expansions can be used to specify processes when
\fB/proc/\fR\fIpid\fR is used. For example, \fB/proc/*\fR can be used to
specify all the processes in the system. If a process ID is given alone, then
all the threads of the process are included as arguments to \fBplgrp\fR.
.sp
.LP
A thread can be explicitly specified with its process ID and thread ID given
together as \fIpid\fR\fB/\fR\fIlwpid\fR. Multiple threads of a process can be
selected at once by using the hyphen (\fB-\fR) and comma(\fB,\fR). For example,
\fIpid\fR\fB/1,2,7-9\fR specifies threads 1, 2, 7, 8, and 9 of the process with
\fIpid\fR as its process ID.
.SH OPTIONS
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-a\fR \fIlgroup_list\fR\fR
.ad
.sp .6
.RS 4n
Display \fBlgroup\fR affinities of specified processes or threads for the
specified \fIlgroup_list\fR.
.RE
.sp
.ne 2
.na
\fB\fB-A\fR \fIlgroup_list\fR\fB/\fR\fInone\fR\fB|\fR\fIweak\fR\fB|\fR\fIstrong
\fR\fB[,...]\fR\fR
.ad
.sp .6
.RS 4n
Set affinity of specified processes or threads for the specified
\fIlgroup_list\fR.
.sp
A comma separated list of \fIlgroups\fR\fB/\fR\fIaffinity\fR assignments can be
given to set several affinities at once.
.RE
.sp
.ne 2
.na
\fB\fB-F\fR\fR
.ad
.sp .6
.RS 4n
Force by grabbing the target process even if another process has control.
Caution should be exercised when using the \fB-F\fR flag. Imposing two
controlling processes on one victim process can lead to chaos. Safety is
assured only when the primary controlling process (typically a debugger) has
stopped the victim process, but isn't doing anything during the application of
this proc tool. See \fBWARNINGS\fR for more details.
.RE
.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.sp .6
.RS 4n
Get home \fBlgroup\fR of specified processes and/or threads. If no options are
specified, this is the default.
.RE
.sp
.ne 2
.na
\fB\fB-H\fR \fIlgroup_list\fR\fR
.ad
.sp .6
.RS 4n
Set home \fBlgroup\fR of specified processes and threads.
.sp
This sets a strong affinity for the desired lgroup to rehome the threads. If
more than one \fBlgroup\fR is specified, \fBplgrp\fR tries to home the threads
to the \fBlgroups\fR in a round robin fashion.
.RE
.SH OPERANDS
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIlwps\fR\fR
.ad
.RS 8n
Specifies thread. See \fBUSAGE\fR.
.RE
.sp
.ne 2
.na
\fB\fIpid\fR\fR
.ad
.RS 8n
Specifies process ID. See \fBUSAGE\fR.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRGetting the Home \fBlgroup\fR for the Shell
.sp
.LP
The following example gets the home \fBlgroup\fR for the shell:
.sp
.in +2
.nf
% plgrp $$
PID/LWPID HOME
3401/1 1
.fi
.in -2
.sp
.LP
\fBExample 2 \fRSetting the Home \fBlgroup\fR of Multiple Threads to the Root
\fBlgroup\fR
.sp
.LP
The following example sets the home \fBlgroup\fR of multiple threads to the
root \fBlgroup\fR:
.sp
.in +2
.nf
% plgrp -H root `pgrep firefox`
PID/LWPID HOME
918/1 1 => 0
934/1 2 => 0
934/2 1 => 0
934/3 2 => 0
934/625 1 => 0
934/626 2 => 0
934/624 2 => 0
934/623 2 => 0
934/630 1 => 0
.fi
.in -2
.sp
.LP
\fBExample 3 \fRGetting Two Threads' Affinities for \fBlgroups 0-2\fR
.sp
.LP
The following example gets two threads' affinities for \fBlgroups 1-2\fR:
.sp
.in +2
.nf
% plgrp -a 0-2 101398/1 101337/1
PID/LWPID HOME AFFINITY
101398/1 1 0-2/none
101337/1 1 0-2/none
.fi
.in -2
.sp
.LP
\fBExample 4 \fRSetting \fBlgroup\fR Affinities
.sp
.LP
The following example sets lgroup affinities:
.sp
.in +2
.nf
% plgrp -A 0/weak,1/none,2/strong 101398
PID/LWPID HOME AFFINITY
101398/1 1 => 2 0,2/none => 2/strong,0/weak
.fi
.in -2
.sp
.SH EXIT STATUS
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 5n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB1\fR\fR
.ad
.RS 5n
Syntax error. Nothing was changed.
.RE
.sp
.ne 2
.na
\fB\fB2\fR\fR
.ad
.RS 5n
Non-fatal error or interrupt. Something might have changed.
.RE
.SH ATTRIBUTES
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability See below.
.TE
.sp
.LP
The command syntax is Unstable. The output formats are Unstable.
.SH SEE ALSO
.LP
\fBlgrpinfo\fR(1), \fBmadv.so.1\fR(1), \fBpmadvise\fR(1), \fBpmap\fR(1),
\fBproc\fR(1), \fBps\fR(1), \fBprstat\fR(1M), \fBlgrp_affinity_get\fR(3LGRP),
\fBlgrp_affinity_set\fR(3LGRP), \fBlgrp_home\fR(3LGRP), \fBliblgrp\fR(3LIB),
\fBproc\fR(4), \fBattributes\fR(5)
.SH WARNINGS
.LP
Like the \fBproc\fR(1) tools, the \fBplgrp\fR utility stops its target
processes while inspecting them and reports the results when invoked with any
option.
.sp
.LP
There are conditions under which processes can deadlock. A process can do
nothing while it is stopped. Stopping a heavily used process in a production
environment (even for a short amount of time) can cause severe bottlenecks and
even hangs of these processes, making them to be unavailable to users. Thus,
stopping a UNIX process in a production environment should be avoided. See
\fBproc\fR(1).
.sp
.LP
A process that is stopped by this tool might be identified by issuing the
following command:
.sp
.in +2
.nf
/usr/bin/ps -eflL
.fi
.in -2
.sp
.sp
.LP
and looking for a \fBT\fR in the first column of the output. Certain processes,
for example, \fBsched\fR, can show the \fBT\fR status by default most of the
time.
|