If no class is given than
.I COMMAND
-will be executed with "best effort" scheduling class. The default
+will be executed with "best-effort" scheduling class. The default
priority argument is 4.
As of this writing, a process can be in one of three scheduling classes:
io processes on normal system activity should be zero. This scheduling
class does not take a priority argument. Presently, this scheduling class
is permitted for an ordinary user (since kernel 2.6.25).
-.IP "\fBBest effort\fP"
+.IP "\fBBest-effort\fP"
This is the effective scheduling class for any process that has not asked for
a specific io priority.
This class takes a priority argument from \fI0-7\fR, with lower
an io priority inherits CPU scheduling class. The io priority is derived from
the cpu nice level of the process (same as before kernel 2.6.26).
-.IP "\fBReal time\fP"
+.IP "\fBRealtime\fP"
The RT scheduling class is given first access to the disk, regardless of
what else is going on in the system. Thus the RT class needs to be used with
some care, as it can starve other processes. As with the best effort class,
permitted for an ordinary (i.e., non-root) user.
.SH OPTIONS
.TP
-\fB\-c\fR, \fB\-\-class\fR \fINUM\fR
-The scheduling class. \fI0\fR for none, \fI1\fR for real time, \fI2\fR for
+\fB\-c\fR, \fB\-\-class\fR \fICLASS\fR
+The scheduling class name or number. \fI0\fR for none, \fI1\fR for realtime, \fI2\fR for
best-effort, \fI3\fR for idle.
.TP
\fB\-n\fR, \fB\-\-classdata\fR \fINUM\fR
Linux supports io scheduling priorities and classes since 2.6.13 with the CFQ
io scheduler.
.SH AUTHORS
+.nf
Jens Axboe <jens@axboe.dk>
+Karel Zak <kzak@redhat.com>
+.fi
.SH AVAILABILITY
The ionice command is part of the util-linux package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
#include <getopt.h>
#include <unistd.h>
#include <sys/syscall.h>
+#include <ctype.h>
#include "nls.h"
#include "strutils.h"
[IOPRIO_CLASS_IDLE] = "idle"
};
+static int parse_ioclass(const char *str)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(to_prio); i++)
+ if (!strcasecmp(str, to_prio[i]))
+ return i;
+ return -1;
+}
+
static void ioprio_print(int pid)
{
int ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid);
" %1$s [OPTION] COMMAND\n"
"\n"
"Options:\n"
- " -c, --class=NUM scheduling class\n"
- " 0: none, 1: realtime, 2: best-effort, 3: idle\n"
- " -n, --classdata=NUM scheduling class data\n"
- " 0-7 for realtime and best-effort classes\n"
- " -p, --pid=PID view or modify already running process\n"
- " -t, --ignore ignore failures\n"
- " -V, --version output version information and exit\n"
- " -h, --help display this help and exit\n\n"),
+ " -c, --class <class> scheduling class name or number\n"
+ " 0: none, 1: realtime, 2: best-effort, 3: idle\n"
+ " -n, --classdata <num> scheduling class data\n"
+ " 0-7 for realtime and best-effort classes\n"
+ " -p, --pid=PID view or modify already running process\n"
+ " -t, --ignore ignore failures\n"
+ " -V, --version output version information and exit\n"
+ " -h, --help display this help and exit\n\n"),
program_invocation_short_name);
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
set |= 1;
break;
case 'c':
- ioclass = strtol_or_err(optarg, _("failed to parse class"));
+ if (isdigit(*optarg))
+ ioclass = strtol_or_err(optarg,
+ _("failed to parse class"));
+ else {
+ ioclass = parse_ioclass(optarg);
+ if (ioclass < 0)
+ errx(EXIT_FAILURE,
+ _("unknown scheduling class: '%s'"),
+ optarg);
+ }
set |= 2;
break;
case 'p':