- Add support for interrupt bindig to cpuset(1). Interrupts are bound

by specifying the interrupt with -x <irq>.  The irq number matches
   those displayed by vmstat -i.

Sponsored by:	Nokia
This commit is contained in:
Jeff Roberson 2008-04-11 03:27:42 +00:00
parent 9b33b154b5
commit 86b3e19077
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178093

View File

@ -2,6 +2,9 @@
* Copyright (c) 2007, 2008 Jeffrey Roberson <jeff@freebsd.org>
* All rights reserved.
*
* Copyright (c) 2008 Nokia Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -51,6 +54,7 @@ int pflag;
int rflag;
int sflag;
int tflag;
int xflag;
id_t id;
cpulevel_t level;
cpuwhich_t which;
@ -149,7 +153,7 @@ printset(cpuset_t *mask)
printf("\n");
}
const char *whichnames[] = { NULL, "tid", "pid", "cpuset" };
const char *whichnames[] = { NULL, "tid", "pid", "cpuset", "irq" };
const char *levelnames[] = { NULL, " root", " cpuset", "" };
static void
@ -194,7 +198,7 @@ main(int argc, char *argv[])
level = CPU_LEVEL_WHICH;
which = CPU_WHICH_PID;
id = pid = tid = setid = -1;
while ((ch = getopt(argc, argv, "cgil:p:rs:t:")) != -1) {
while ((ch = getopt(argc, argv, "cgil:p:rs:t:x:")) != -1) {
switch (ch) {
case 'c':
if (rflag)
@ -233,6 +237,11 @@ main(int argc, char *argv[])
which = CPU_WHICH_TID;
id = tid = atoi(optarg);
break;
case 'x':
xflag = 1;
which = CPU_WHICH_IRQ;
id = atoi(optarg);
break;
default:
usage();
}
@ -243,7 +252,7 @@ main(int argc, char *argv[])
if (argc || lflag)
usage();
/* Only one identity specifier. */
if (sflag + pflag + tflag > 1)
if (xflag + sflag + pflag + tflag > 1)
usage();
if (iflag)
printsetid();
@ -257,7 +266,7 @@ main(int argc, char *argv[])
* The user wants to run a command with a set and possibly cpumask.
*/
if (argc) {
if (pflag | rflag | tflag)
if (pflag | rflag | tflag | xflag)
usage();
if (sflag) {
if (cpuset_setid(CPU_WHICH_PID, -1, setid))
@ -283,7 +292,10 @@ main(int argc, char *argv[])
if (!lflag && !sflag)
usage();
/* You can only set a mask on a thread. */
if (tflag && (sflag || pflag))
if (tflag && (sflag | pflag | xflag))
usage();
/* You can only set a mask on an irq. */
if (xflag && (pflag | sflag | tflag))
usage();
if (pflag && sflag) {
if (cpuset_setid(CPU_WHICH_PID, pid, setid))
@ -313,8 +325,8 @@ usage(void)
fprintf(stderr,
" cpuset [-l cpu-list] [-s setid] -p pid\n");
fprintf(stderr,
" cpuset [-cr] [-l cpu-list] [-p pid | -t tid | -s setid]\n");
" cpuset [-cr] [-l cpu-list] [-p pid | -t tid | -s setid | -x irq]\n");
fprintf(stderr,
" cpuset [-cgir] [-p pid | -t tid | -s setid]\n");
" cpuset [-cgir] [-p pid | -t tid | -s setid | -x irq]\n");
exit(1);
}