man pages section 1M: System Administration Commands

Exit Print View

Updated: July 2014
 
 

pbind(1M)

Name

pbind - control and query bindings of processes or LWPs

Synopsis

pbind -b [-c | 
g | l] [target_list] [
-n] [-s | w] [-xft] [
-i idtype] [idlist]
pbind -b [-c | 
g | l] [target_list] [
-n] [-s | w] [-xft] [
-e command [argument(s)]]
pbind [-q] [-c | 
g | l] [-i idtype] [
idlist]
pbind -u [-i 
idtype] idlist
pbind -Q [-c | 
g | l] [target_list]
pbind -U [-c | 
g | l] [target_list]

Description

pbind controls and queries bindings and affinities of processes and LWPs (lightweight processes) to CPU(s). This utility allows users to determine on which processor(s) one or more LWPs should be scheduled to run, whether such binding should be strongly or weakly enforced and how it should be inherited by child LWPs. pbind can also be used to execute a command with a specific binding.

With strong affinity the target LWP(s) will only run on the specified processors, while weak affinity results in a best effort attempt at executing the LWP(s) on such CPUs. The binding determined by pbind is not exclusive, that is, the processor is free to execute other LWPs as well. This in turn means that bound threads can be prevented from running if other, higher priority LWPs are occupying the same processors.

The target CPUs can be specified directly by their processor IDs or indirectly by their Processor Group (PG) or Locality Group (lgroup) ID. The user may also specify negative affinity, indicating that the specified CPUs should be avoided.

When querying for bindings of specific LWPs, the user may request that the resulting set of CPUs be identified through their IDs, the Processor Groups or the Locality Groups that contain them. Similarly, when querying or removing all bindings of specific processors, the user may do so through their respective PG or lgroup IDs.

By default, bindings are inherited across exec(2), fork(2), and thr_create(3C), but the user can request that inheritance be broken across one or more of such actions.

It is important to note that the runtime behavior determined by pbind is subject to the continued online state of the specified CPUs and their affiliation to the same Processor Set as the target LWPs. If these underlying conditions change, a LWP will lose its affinity for a given CPU and will need to be reset once the conditions are restored.

Superusers may bind or unbind any process or LWP, while other users can bind or unbind any process or LWP for which they have permission to signal, that is, any process that has the same effective user ID as the user.

Options

The following options are supported:

–b

This option, along with one or more identifiers indicates which CPU(s), Processor Group(s) or Locality Group(s) are the target(s) of the requested binding.

The valid target types and their corresponding interpretations are as follows:

–c

CPU, or Processor ID (the default). All the given CPUs must be present and online. Use the psrinfo command to determine whether or not target_list is present and on-line. See psrinfo(1M) for more information.

–g

Processor Group ID. See pginfo(1M) for more information.

–l

Locality Group ID. The specified lgroups must contain at least one online CPU for the operation to proceed. See lgrpinfo(1M) for details.

–n

Indicates that the given target processors should be avoided.

–s

Indicates that the binding is to be strongly enforced (default) and the specified LWPs should only execute on the given processors.

–w

Indicates that the binding is to be weakly enforced, and the specified LWPs should preferably execute on the given processors but can run elsewhere if necessary.

–i idtype

This option, together with the idlist arguments specifies one or more processes or LWPs to which the binding will be applied. The interpretation of idlist depends on the value of idtype which, if ommitted defaults to pid.

–i pid[/lwps]

idlist is a list of process IDs with each ID possibly followed by a forward slash (/) and a list of comma-separated LWP IDs. A range of LWP IDs can be indicated by a - separating start and end of the range.

–i ppid

idlist is a list of parent process IDs. The binding command applies to all processes whose parent process ID is in the list.

–i pgid

idlist is a list of process group IDs. The binding command applies to all processes in the specified process groups.

–i uid

idlist is a list of user IDs. The binding command applies to all processes with an effective user ID equal to an ID from the list.

–i gid

idlist is a list of group IDs. The binding command applies to all processes with an effective group ID equal to an ID from the list.

–i taskid

idlist is a list of task IDs. The binding command applies to all processes in the specified tasks.

–i projid

idlist is a list of project IDs. The binding command applies to all processes with an effective project ID equal to an ID from the list.

–i zoneid

idlist is a list of zone IDs. The binding command applies to all processes with an effective zone ID equal to an ID from the list.

Note that The P_MYID identifier can be used in conjunction with any of the ID types above to indicate that the desired ID is that of the calling LWP for the given type (for example, P_PID and P_MYID result in the process identifier of the caller LWP).

–x

Do not inherit affinities across exec(2).

–f

Do not inherit affinities across fork(2).

–t

Do not inherit affinities across thr_create(3C).

–e

Executes a command with the specified bindings.

–q

Displays the CPU bindings of the specified processes or of all processes. If a process is composed of multiple LWPs which have different bindings and the LWPs are not explicitly specified, the bindings of only one of the bound LWPs will be displayed. The bindings of a subset of LWPs can be displayed by appending "/lwpids" to the process IDs. Multiple LWPs may be selected using "-" and "," delimiters.

Additionally, the [–gl] options may be included to request that the report include which Processor Groups or Locality Groups contain the CPUs to which the specified LWPs are bound. By default, the processor IDs are always displayed.

–Q

Displays the LWPs bound to the specified list of CPUs, Processor Groups or Locality Groups, or all LWPs with processor bindings. For processes composed of multiple LWPs, the bindings of individual LWPs will be displayed.

–u

Removes the bindings of all or a subset of the LWPs of the specified processes, allowing them to be executed on any online processor.

–U

Removes the bindings of all LWPs bound to the specified list of processors, or to any processor if no argument is specified.

Return Values

pbind returns 0 upon successful completion. If an error occurs, a positive integer is returned indicating the resulting error number.

Errors

The pbind command will fail if:

ESRCH

None of the specified processes or LWPs exist.

EINVAL

The specified idtype or IDs do not exist, all of the target processors are offline, faulted, part of different processor sets or the given combination of options is invalid.

EPERM

The {PRIV_PROC_OWNER} privilege is not asserted in the effective set of the calling process and its real or effective user ID does not match the real or effective user ID of one of the LWPs being bound.

Examples

Example 1 Equivalent ways of binding process 101048 to CPU 1
# pbind -b 1 101048
pbind(1M): pid 101048 strongly bound to processor(s) 1.
# pbind -b -c 1 101048
pbind(1M): pid 101048 strongly bound to processor(s) 1.
# pbind -b -c 1 -i pid 101048
pbind(1M): pid 101048 strongly bound to processor(s) 1.
# pbind -b -c 1 -s -i pid 101048
pbind(1M): pid 101048 strongly bound to processor(s) 1.
Example 2 Re-binding process 101048 to CPUs 0-3
# pbind -b -c 0-3 101048
pbind(1M): pid 101048 strongly bound to processor(s) 1.
pbind(1M): pid 101048 strongly bound to processor(s) 0 1 2 3.
Example 3 Re-binding process 101048 to the CPUs in Processor Group 1
# pbind -b -g 1 101048
pbind(1M): pid 101048 strongly bound to Processor Group(s) 1 2.
pbind(1M): pid 101048 strongly bound to Processor Group(s) 1.
Example 4 Re-binding process 101048 to the CPUs in Locality Group 2
# pbind -b -l 2 101048
pbind(1M): pid 101048 strongly bound to Locality Group(s) 0 1.
pbind(1M): pid 101048 strongly bound to Locality Group(s) 0 2.
Example 5 Weakly binding process 101048 to CPU 2
# pbind -b 2 -w 101048
pbind(1M): pid 101048 weakly bound to processor(s) 2.
Example 6 Binding process 101048 to all CPUs but CPU 1
# pbind -b 1 -n 101048
pbind(1M): pid 101048 strongly bound to processor(s) 0 2 3.
Example 7 Weakly binding process 101048 to all CPUs but the ones in Processor Group 1
# pbind -b -g 1 -n -w 101048
pbind(1M): pid 101048 strongly bound to Processor Group(s) 1 2.
pbind(1M): pid 101048 weakly bound to Processor Group(s) 2
Example 8 Querying bindings for process 101048 in terms of CPUs, Processor Groups and Locality Groups
# pbind -q 101048
pbind(1M): pid 101048 weakly bound to processor(s) 2 3.
# pbind -q -g 101048
pbind(1M): pid 101048 weakly bound to Processor Group(s) 2.
# pbind -q -l 101048
pbind(1M): pid 101048 weakly bound to Locality Group(s) 0 2.
Example 9 Querying bindings for process 101048
# pbind -q -i pid 101048
pbind(1M): pid 101048 weakly bound to processor(s) 2 3.
Example 10 Querying bindings for process 101048 in terms of Processor Groups
# pbind -q -g -i pid 101048
pbind(1M): pid 101048 weakly bound to Processor Group(s) 2.
Example 11 Querying all bindings for CPU 2
# pbind -Q 2
pbind(1M): LWP 101048/1 weakly bound to processor(s) 2 3.
pbind(1M): LWP 102122/1 weakly bound to processor(s) 2 3.
Example 12 Unbinding process 101048
# pbind -u 101048
pbind(1M): pid 101048 successfully unbound.
Example 13 Unbinding all processes from CPU 1
# pbind -U 1
Example 14 Unbinding all processes from Locality Group 2
# pbind -U -l 2
Example 15 Executing ls(1) with a specific binding
# pbind -b -c 3 -e ls
file1  file2  file3  file4

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os

Exit Status

The following exit values are returned:

0

Successful completion.

>0

An error occurred.

See also

psrinfo(1M), psradm(1M), psrset(1M), pginfo(1M), lgrpinfo(1), processor_info(2), processor_bind (2) , pset_create (2) , pset_assign (2) , pset_bind (2) , pset_destroy (2) , exec (2) , fork (2) , thr_create (3C) , procset.h (3HEAD) , attributes(5), privileges(5)

Diagnostics

pbind: cannot query pid 31: No such process

The process specified did not exist or has exited.

pbind: cannot bind pid 31: Not owner

The user does not have permission to bind the process.

pbind: cannot bind pid 31: Invalid argument

The specified processor is not on-line.