Page MenuHomeFreeBSD

D36390.id109969.diff
No OneTemporary

D36390.id109969.diff

diff --git a/usr.bin/cpuset/cpuset.c b/usr.bin/cpuset/cpuset.c
--- a/usr.bin/cpuset/cpuset.c
+++ b/usr.bin/cpuset/cpuset.c
@@ -59,6 +59,7 @@
static int iflag;
static int jflag;
static int lflag;
+static int Nflag;
static int nflag;
static int pflag;
static int rflag;
@@ -244,7 +245,7 @@
"prefer", "interleave" };
static void
-printaffinity(void)
+printaffinityorcount(void)
{
domainset_t domain;
cpuset_t mask;
@@ -252,17 +253,28 @@
if (cpuset_getaffinity(level, which, id, sizeof(mask), &mask) != 0)
err(EXIT_FAILURE, "getaffinity");
- printf("%s %jd%s mask: ", whichnames[which], (intmax_t)id,
- levelnames[level]);
- printset((struct bitset *)&mask, CPU_SETSIZE);
+ if (Nflag) {
+ printf("%s %jd%s CPU count: %d\n", whichnames[which],
+ (intmax_t)id, levelnames[level], CPU_COUNT(&mask));
+ } else {
+ printf("%s %jd%s mask: ", whichnames[which], (intmax_t)id,
+ levelnames[level]);
+ printset((struct bitset *)&mask, CPU_SETSIZE);
+ }
if (dflag || xflag)
goto out;
if (cpuset_getdomain(level, which, id, sizeof(domain), &domain,
&policy) != 0)
err(EXIT_FAILURE, "getdomain");
- printf("%s %jd%s domain policy: %s mask: ", whichnames[which],
- (intmax_t)id, levelnames[level], policynames[policy]);
- printset((struct bitset *)&domain, DOMAINSET_SETSIZE);
+ if (Nflag) {
+ printf("%s %jd%s domain count: %d\n",
+ whichnames[which], (intmax_t)id, levelnames[level],
+ DOMAINSET_COUNT(&domain));
+ } else {
+ printf("%s %jd%s domain policy: %s mask: ", whichnames[which],
+ (intmax_t)id, levelnames[level], policynames[policy]);
+ printset((struct bitset *)&domain, DOMAINSET_SETSIZE);
+ }
out:
exit(EXIT_SUCCESS);
}
@@ -300,7 +312,7 @@
level = CPU_LEVEL_WHICH;
which = CPU_WHICH_PID;
id = pid = tid = setid = -1;
- while ((ch = getopt(argc, argv, "Ccd:gij:l:n:p:rs:t:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "Ccd:gij:l:Nn:p:rs:t:x:")) != -1) {
switch (ch) {
case 'C':
Cflag = 1;
@@ -335,6 +347,9 @@
nflag = 1;
parsedomainlist(optarg, &domains, &policy);
break;
+ case 'N':
+ Nflag = 1;
+ break;
case 'p':
pflag = 1;
which = CPU_WHICH_PID;
@@ -368,17 +383,19 @@
if (gflag) {
if (argc || Cflag || lflag || nflag)
usage();
+ if (iflag && Nflag)
+ usage();
/* Only one identity specifier. */
if (dflag + jflag + xflag + sflag + pflag + tflag > 1)
usage();
if (iflag)
printsetid();
else
- printaffinity();
+ printaffinityorcount();
exit(EXIT_SUCCESS);
}
- if (dflag || iflag || rflag)
+ if (dflag || iflag || rflag || Nflag)
usage();
/*
* The user wants to run a command with a set and possibly cpumask.
@@ -469,7 +486,7 @@
" cpuset [-c] [-l cpu-list] [-n policy:domain-list]\n"
" [-j jailid | -p pid | -t tid | -s setid | -x irq]\n");
fprintf(stderr,
- " cpuset -g [-cir]\n"
+ " cpuset -g [-ciNr]\n"
" [-d domain | -j jailid | -p pid | -t tid | -s setid | -x irq]\n");
exit(1);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 20, 10:14 PM (6 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14748341
Default Alt Text
D36390.id109969.diff (2 KB)

Event Timeline