summaryrefslogtreecommitdiffstats
path: root/usr.bin/cpuset/cpuset.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-01-08 15:53:13 +0000
committerjhb <jhb@FreeBSD.org>2015-01-08 15:53:13 +0000
commit06e75f0dba830c7814f7c902918c6b00e3cb9f80 (patch)
treea8c0b10964b6a43594a95c578b257a516b7998a9 /usr.bin/cpuset/cpuset.c
parent7b0cd0edc9886415c53b5df6eb32e24e3f7df633 (diff)
downloadFreeBSD-src-06e75f0dba830c7814f7c902918c6b00e3cb9f80.zip
FreeBSD-src-06e75f0dba830c7814f7c902918c6b00e3cb9f80.tar.gz
Create a cpuset mask for each NUMA domain that is available in the
kernel via the global cpuset_domain[] array. To export these to userland, add a CPU_WHICH_DOMAIN level that can be used to fetch the mask for a specific domain. Add a -d flag to cpuset(1) that can be used to fetch the mask for a given domain. Differential Revision: https://reviews.freebsd.org/D1232 Submitted by: jeff (kernel bits) Reviewed by: adrian, jeff
Diffstat (limited to 'usr.bin/cpuset/cpuset.c')
-rw-r--r--usr.bin/cpuset/cpuset.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/usr.bin/cpuset/cpuset.c b/usr.bin/cpuset/cpuset.c
index 898c3e5..c619259 100644
--- a/usr.bin/cpuset/cpuset.c
+++ b/usr.bin/cpuset/cpuset.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
static int Cflag;
static int cflag;
+static int dflag;
static int gflag;
static int iflag;
static int jflag;
@@ -161,7 +162,8 @@ printset(cpuset_t *mask)
printf("\n");
}
-static const char *whichnames[] = { NULL, "tid", "pid", "cpuset", "irq", "jail" };
+static const char *whichnames[] = { NULL, "tid", "pid", "cpuset", "irq", "jail",
+ "domain" };
static const char *levelnames[] = { NULL, " root", " cpuset", "" };
static void
@@ -206,17 +208,20 @@ main(int argc, char *argv[])
level = CPU_LEVEL_WHICH;
which = CPU_WHICH_PID;
id = pid = tid = setid = -1;
- while ((ch = getopt(argc, argv, "Ccgij:l:p:rs:t:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "Ccd:gij:l:p:rs:t:x:")) != -1) {
switch (ch) {
case 'C':
Cflag = 1;
break;
case 'c':
- if (rflag)
- usage();
cflag = 1;
level = CPU_LEVEL_CPUSET;
break;
+ case 'd':
+ dflag = 1;
+ which = CPU_WHICH_DOMAIN;
+ id = atoi(optarg);
+ break;
case 'g':
gflag = 1;
break;
@@ -238,8 +243,6 @@ main(int argc, char *argv[])
id = pid = atoi(optarg);
break;
case 'r':
- if (cflag)
- usage();
level = CPU_LEVEL_ROOT;
rflag = 1;
break;
@@ -268,7 +271,7 @@ main(int argc, char *argv[])
if (argc || Cflag || lflag)
usage();
/* Only one identity specifier. */
- if (jflag + xflag + sflag + pflag + tflag > 1)
+ if (dflag + jflag + xflag + sflag + pflag + tflag > 1)
usage();
if (iflag)
printsetid();
@@ -276,13 +279,13 @@ main(int argc, char *argv[])
printaffinity();
exit(EXIT_SUCCESS);
}
- if (iflag)
+ if (dflag || iflag || rflag)
usage();
/*
* The user wants to run a command with a set and possibly cpumask.
*/
if (argc) {
- if (Cflag | pflag | rflag | tflag | xflag | jflag)
+ if (Cflag || pflag || tflag || xflag || jflag)
usage();
if (sflag) {
if (cpuset_setid(CPU_WHICH_PID, -1, setid))
@@ -303,9 +306,9 @@ main(int argc, char *argv[])
/*
* We're modifying something that presently exists.
*/
- if (Cflag && (sflag || rflag || !pflag || tflag || xflag || jflag))
+ if (Cflag && (jflag || !pflag || sflag || tflag || xflag))
usage();
- if (!lflag && (cflag || rflag))
+ if (!lflag && cflag)
usage();
if (!lflag && !(Cflag || sflag))
usage();
@@ -354,8 +357,9 @@ usage(void)
fprintf(stderr,
" cpuset [-c] [-l cpu-list] -C -p pid\n");
fprintf(stderr,
- " cpuset [-cr] [-l cpu-list] [-j jailid | -p pid | -t tid | -s setid | -x irq]\n");
+ " cpuset [-c] [-l cpu-list] [-j jailid | -p pid | -t tid | -s setid | -x irq]\n");
fprintf(stderr,
- " cpuset [-cgir] [-j jailid | -p pid | -t tid | -s setid | -x irq]\n");
+ " cpuset -g [-cir] [-d domain | -j jailid | -p pid | -t tid | -s setid |\n"
+ " -x irq]\n");
exit(1);
}
OpenPOWER on IntegriCloud