[PATCH] ionice: Allow setting the none class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow users to set the "none" class on processes. Using the
none class has the distict advantage that the io priority
is inherited from the cpu nice level. Update the man page
to reflect the change.

Don't print the priority (there is none / it is always 0)
on a class "none" process.

Signed-off-by: Jakob Unterwurzacher <jakobunt@xxxxxxxxx>
---
 ionice.1 |    3 ++-
 ionice.c |    8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff -x nls.h -x a.out -uprN schedutils.orig/ionice.1 schedutils/ionice.1
--- schedutils.orig/ionice.1	2009-01-17 01:51:11.000000000 +0100
+++ schedutils/ionice.1	2009-01-17 02:18:07.000000000 +0100
@@ -45,7 +45,8 @@ io_priority = (cpu_nice + 20) / 5
 
 .SH OPTIONS
 .IP "\fB-c \fIclass\fP"
-The scheduling class. \fI1\fR for real time, \fI2\fR for best-effort, \fI3\fR for idle.
+The scheduling class. \fI0\fR for none, \fI1\fR for real time, \fI2\fR for
+best-effort, \fI3\fR for idle.
 .IP "\fB-n \fIclassdata\fP"
 The scheduling class data. This defines the class data, if the class
 accepts an argument. For real time and best-effort, \fI0-7\fR is valid
diff -x nls.h -x a.out -uprN schedutils.orig/ionice.c schedutils/ionice.c
--- schedutils.orig/ionice.c	2009-01-17 01:51:11.000000000 +0100
+++ schedutils/ionice.c	2009-01-17 01:47:56.000000000 +0100
@@ -57,7 +57,7 @@ static void ioprio_print(int pid)
 		err(EXIT_FAILURE, _("ioprio_get failed"));
 	else {
 		ioclass = ioprio >> IOPRIO_CLASS_SHIFT;
-		if (ioclass != IOPRIO_CLASS_IDLE) {
+		if (ioclass != IOPRIO_CLASS_IDLE && ioclass != IOPRIO_CLASS_NONE ) {
 			ioprio = ioprio & 0xff;
 			printf("%s: prio %d\n", to_prio[ioclass], ioprio);
 		} else
@@ -85,7 +85,7 @@ static void usage(int rc)
 	"\nOptions:\n"
 	"  -n <classdata>      class data (0-7, lower being higher prio)\n"
 	"  -c <class>          scheduling class\n"
-	"                      1: realtime, 2: best-effort, 3: idle\n"
+	"                      0: none, 1: realtime, 2: best-effort, 3: idle\n"
 	"  -t                  ignore failures\n"
 	"  -h                  this help\n\n"));
 	exit(rc);
@@ -147,7 +147,9 @@ int main(int argc, char *argv[])
 
 	switch (ioclass) {
 		case IOPRIO_CLASS_NONE:
-			ioclass = IOPRIO_CLASS_BE;
+			if (set & 1)
+				warnx(_("ignoring given class data for none class"));
+			ioprio = 0;
 			break;
 		case IOPRIO_CLASS_RT:
 		case IOPRIO_CLASS_BE:
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux