Page MenuHomeFreeBSD

D36390.diff
No OneTemporary

D36390.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
@@ -56,9 +56,11 @@
static int cflag;
static int dflag;
static int gflag;
+static int Hflag;
static int iflag;
static int jflag;
static int lflag;
+static int Nflag;
static int nflag;
static int pflag;
static int rflag;
@@ -244,7 +246,7 @@
"prefer", "interleave" };
static void
-printaffinity(void)
+printaffinityorcount(void)
{
domainset_t domain;
cpuset_t mask;
@@ -252,10 +254,20 @@
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 (dflag || xflag)
+ if (!Hflag) {
+ if (Nflag) {
+ printf("%s %jd%s CPU count: ", whichnames[which],
+ (intmax_t)id, levelnames[level], CPU_COUNT(&mask));
+ } else {
+ printf("%s %jd%s mask: ", whichnames[which],
+ (intmax_t)id, levelnames[level]);
+ }
+ }
+ if (Nflag)
+ printf("%d\n", CPU_COUNT(&mask));
+ else
+ printset((struct bitset *)&mask, CPU_SETSIZE);
+ if (dflag || Hflag || Nflag || xflag)
goto out;
if (cpuset_getdomain(level, which, id, sizeof(domain), &domain,
&policy) != 0)
@@ -279,8 +291,11 @@
level = CPU_LEVEL_CPUSET;
if (cpuset_getid(level, which, id, &setid))
err(errno, "getid");
- printf("%s %jd%s id: %d\n", whichnames[which], (intmax_t)id,
- levelnames[level], setid);
+ if (!Hflag) {
+ printf("%s %jd%s id: ", whichnames[which], (intmax_t)id,
+ levelnames[level]);
+ }
+ printf("%d\n", setid);
}
int
@@ -300,7 +315,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:gHij:l:Nn:p:rs:t:x:")) != -1) {
switch (ch) {
case 'C':
Cflag = 1;
@@ -317,6 +332,9 @@
case 'g':
gflag = 1;
break;
+ case 'H':
+ Hflag = 1;
+ break;
case 'i':
iflag = 1;
break;
@@ -335,6 +353,9 @@
nflag = 1;
parsedomainlist(optarg, &domains, &policy);
break;
+ case 'N':
+ Nflag = 1;
+ break;
case 'p':
pflag = 1;
which = CPU_WHICH_PID;
@@ -368,17 +389,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 || Hflag || iflag || Nflag || rflag)
usage();
/*
* The user wants to run a command with a set and possibly cpumask.
@@ -469,7 +492,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 [-cHiNr]\n"
" [-d domain | -j jailid | -p pid | -t tid | -s setid | -x irq]\n");
exit(1);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 6, 3:36 PM (5 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29330662
Default Alt Text
D36390.diff (3 KB)

Event Timeline