summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/psrset/psrset.c64
-rw-r--r--usr/src/man/man1m/psrset.1m20
2 files changed, 63 insertions, 21 deletions
diff --git a/usr/src/cmd/psrset/psrset.c b/usr/src/cmd/psrset/psrset.c
index 35585499a9..41724137ef 100644
--- a/usr/src/cmd/psrset/psrset.c
+++ b/usr/src/cmd/psrset/psrset.c
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ */
/*
* psrset - create and manage processor sets
@@ -41,6 +44,7 @@
#include <procfs.h>
#include <libproc.h>
#include <stdarg.h>
+#include <zone.h>
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
@@ -69,6 +73,8 @@ static char nflag;
static char fflag;
static char Fflag;
static char eflag;
+static char zflag;
+static const char *zname;
extern int pset_assign_forced(psetid_t, processorid_t, psetid_t *);
@@ -128,7 +134,7 @@ rele_proc(struct ps_prochandle *Pr)
}
static void
-bind_err(psetid_t pset, id_t pid, id_t lwpid, int err)
+bind_err(psetid_t pset, const char *zname, id_t pid, id_t lwpid, int err)
{
char *msg;
@@ -145,7 +151,9 @@ bind_err(psetid_t pset, id_t pid, id_t lwpid, int err)
}
errno = err;
- if (lwpid == -1)
+ if (zname != NULL)
+ warn(gettext("cannot %s zone %s"), msg, zname);
+ else if (lwpid == -1)
warn(gettext("cannot %s pid %d"), msg, pid);
else
warn(gettext("cannot %s lwpid %d/%d"), msg, pid, lwpid);
@@ -281,7 +289,7 @@ bind_lwp(id_t pid, id_t lwpid, psetid_t pset)
psetid_t old_pset;
if (pset_bind_lwp(pset, lwpid, pid, &old_pset) != 0) {
- bind_err(pset, pid, lwpid, errno);
+ bind_err(pset, NULL, pid, lwpid, errno);
errors = ERR_FAIL;
}
if (errors != ERR_FAIL) {
@@ -491,7 +499,7 @@ query_all_proc(psinfo_t *psinfo, lwpsinfo_t *lwpsinfo, void *arg)
*/
if (errno == ESRCH)
return (0);
- bind_err(PS_QUERY, pid, -1, errno);
+ bind_err(PS_QUERY, NULL, pid, -1, errno);
errors = ERR_FAIL;
return (0);
}
@@ -542,6 +550,7 @@ usage(void)
"\t%1$s -r [-F] processor_id ...\n"
"\t%1$s -p [processorid ...]\n"
"\t%1$s -b processor_set_id pid[/lwpids] ...\n"
+ "\t%1$s -b -z zonename processor_set_id\n"
"\t%1$s -u pid[/lwpids] ...\n"
"\t%1$s -q [pid[/lwpids] ...]\n"
"\t%1$s -U [processor_set_id] ...\n"
@@ -574,23 +583,23 @@ do_lwps(id_t pid, const char *range, psetid_t pset)
if ((fd = open(procfile, O_RDONLY)) < 0) {
if (errno == ENOENT)
errno = ESRCH;
- bind_err(pset, pid, -1, errno);
+ bind_err(pset, NULL, pid, -1, errno);
return (ERR_FAIL);
}
if (pread(fd, &header, sizeof (header), 0) != sizeof (header)) {
(void) close(fd);
- bind_err(pset, pid, -1, errno);
+ bind_err(pset, NULL, pid, -1, errno);
return (ERR_FAIL);
}
nent = header.pr_nent;
size = header.pr_entsize * nent;
ptr = lpsinfo = malloc(size);
if (lpsinfo == NULL) {
- bind_err(pset, pid, -1, errno);
+ bind_err(pset, NULL, pid, -1, errno);
return (ERR_FAIL);
}
if (pread(fd, lpsinfo, size, sizeof (header)) != size) {
- bind_err(pset, pid, -1, errno);
+ bind_err(pset, NULL, pid, -1, errno);
free(lpsinfo);
(void) close(fd);
return (ERR_FAIL);
@@ -635,6 +644,7 @@ main(int argc, char *argv[])
id_t pid;
processorid_t cpu;
psetid_t pset, old_pset;
+ zoneid_t zid;
char *errptr;
progname = argv[0]; /* put actual command name in messages */
@@ -642,7 +652,7 @@ main(int argc, char *argv[])
(void) setlocale(LC_ALL, ""); /* setup localization */
(void) textdomain(TEXT_DOMAIN);
- while ((c = getopt(argc, argv, "cdFarpibqQuUnfe")) != EOF) {
+ while ((c = getopt(argc, argv, "cdFarpibqQuUnfez:")) != EOF) {
switch (c) {
case 'c':
cflag = 1;
@@ -693,6 +703,19 @@ main(int argc, char *argv[])
case 'n':
nflag = 1;
break;
+ case 'z':
+ if (!bflag) {
+ warn(gettext("-z can only be used after -b\n"));
+ return (usage());
+ }
+ if (zflag) {
+ warn(gettext("-z can only be specified "
+ "once\n"));
+ return (usage());
+ }
+ zflag = 1;
+ zname = optarg;
+ break;
default:
return (usage());
}
@@ -859,9 +882,28 @@ main(int argc, char *argv[])
/*
* Perform function for each pid/lwpid specified.
*/
- if (argc == 0) {
+ if (argc == 0 && !zflag) {
warn(gettext("must specify at least one pid\n"));
return (usage());
+ } else if (argc > 0 && zflag) {
+ warn(gettext("cannot specify extra pids with -z\n"));
+ return (usage());
+ }
+
+ if (zflag) {
+ zid = getzoneidbyname(zname);
+ if (zid < 0) {
+ warn(gettext("invalid zone name: %s\n"),
+ zname);
+ errors = ERR_FAIL;
+ } else if (pset_bind(pset, P_ZONEID, zid,
+ &old_pset) < 0) {
+ bind_err(pset, zname, -1, -1, errno);
+ errors = ERR_FAIL;
+ } else {
+ (void) printf(gettext("zone %s: bound to %d\n"),
+ zname, pset);
+ }
}
/*
@@ -902,7 +944,7 @@ main(int argc, char *argv[])
*/
if (pset_bind(pset, P_PID, pid,
&old_pset) < 0) {
- bind_err(pset, pid, -1, errno);
+ bind_err(pset, NULL, pid, -1, errno);
errors = ERR_FAIL;
continue;
}
diff --git a/usr/src/man/man1m/psrset.1m b/usr/src/man/man1m/psrset.1m
index 0212e6fa07..aa3e7e2aa0 100644
--- a/usr/src/man/man1m/psrset.1m
+++ b/usr/src/man/man1m/psrset.1m
@@ -1,9 +1,10 @@
'\" te
+.\" Copyright (c) 2013, Joyent, Inc. All Rights Reserved
.\" Copyright (c) 2008, 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 PSRSET 1M "Feb 25, 2008"
+.TH PSRSET 1M "Mar 11, 2013"
.SH NAME
psrset \- creation and management of processor sets
.SH SYNOPSIS
@@ -19,6 +20,11 @@ psrset \- creation and management of processor sets
.LP
.nf
+\fBpsrset\fR \fB-b\fR \fB-z\fR \fIzone name\fR \fIprocessor_set_id\fR
+.fi
+
+.LP
+.nf
\fBpsrset\fR \fB-c\fR [\fB-F\fR] [\fIprocessor_id\fR]...
.fi
@@ -78,7 +84,6 @@ psrset \- creation and management of processor sets
.fi
.SH DESCRIPTION
-.sp
.LP
The \fBpsrset\fR utility controls the management of processor sets. Processor
sets allow the binding of processes or LWPs to groups of processors, rather
@@ -90,7 +95,6 @@ This command cannot be used to modify processor disposition when pools are
enabled. Use \fBpooladm\fR(1M) and \fBpoolcfg\fR(1M) to modify processor set
configuration through the resource pools facility.
.SH OPTIONS
-.sp
.LP
The following options are supported:
.sp
@@ -110,11 +114,12 @@ privilege.
.sp
.ne 2
.na
-\fB\fB-b\fR\fR
+\fB\fB-b\fR [\fB-z\fr \fIzonename\fR]\fR
.ad
.RS 6n
Bind all or a subset of the \fBLWP\fRs of the specified processes to the
-specified processor set.
+specified processor set. If \fB-z\fR is specified, all processes and threads
+inside the specified zone are bound to the processor set.
.sp
LWPs bound to a processor set are restricted to run only on the processors in
that set. Processes can only be bound to non-empty processor sets, that is,
@@ -325,7 +330,6 @@ or to any processor set if no argument is specified.
.RE
.SH OPERANDS
-.sp
.LP
The following operands are supported:
.sp
@@ -379,7 +383,6 @@ Specify \fIprocessor_set_id\fR as a processor set \fBID\fR.
.RE
.SH EXIT STATUS
-.sp
.LP
The following exit values are returned:
.sp
@@ -401,7 +404,6 @@ An error occurred.
.RE
.SH ATTRIBUTES
-.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
@@ -417,7 +419,6 @@ Stability Level Stable
.TE
.SH SEE ALSO
-.sp
.LP
\fBpbind\fR(1M), \fBpooladm\fR(1M), \fBpoolcfg\fR(1M), \fBpsradm\fR(1M),
\fBpsrinfo\fR(1M), \fBprocessor_bind\fR(2), \fBprocessor_info\fR(2),
@@ -425,7 +426,6 @@ Stability Level Stable
\fBsysconf\fR(3C), \fBlibpool\fR(3LIB), \fBattributes\fR(5),
\fBprivileges\fR(5)
.SH DIAGNOSTICS
-.sp
.LP
The following output indicates that the specified process did not exist or has
exited: