I/O priorities.
- From: Robert Love <rml novell com>
- To: dashboard-hackers gnome org
- Subject: I/O priorities.
- Date: Mon, 01 Aug 2005 15:06:10 -0400
We have I/O priorities now in the 2.6.12 kernel, although only the CFQ
I/O scheduler enforces them.
Attached patch implements the glue wrappers to use the new I/O priority
system calls in Beagle.
Right now, I only export a single function: set_io_priority_idle().
This function will make the invoking thread run in the idle I/O
priority, which is probably want we want for Beagle.
Robert Love
Index: glue/ioprio.c
===================================================================
RCS file: glue/ioprio.c
diff -N glue/ioprio.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ glue/ioprio.c 1 Aug 2005 19:02:54 -0000
@@ -0,0 +1,59 @@
+/*
+ * ioprio.c - I/O priority wrappers for the big dog
+ *
+ * Robert Love <rml novell com>
+ *
+ * Copyright (C) 2005 Novell, Inc.
+ */
+
+#if defined(__i386__)
+# define __NR_ioprio_set 289
+# define __NR_ioprio_get 290
+#elif defined(__ppc__)
+# define __NR_ioprio_set 273
+# define __NR_ioprio_get 274
+#elif defined(__x86_64__)
+# define __NR_ioprio_set 251
+# define __NR_ioprio_get 252
+#elif defined(__ia64__)
+# define __NR_ioprio_set 1274
+# define __NR_ioprio_get 1275
+#else
+# error "Unsupported archiecture!"
+#endif
+
+static inline int ioprio_set (int which, int who, int ioprio)
+{
+ return syscall (__NR_ioprio_set, which, who, ioprio);
+}
+
+static inline int ioprio_get (int which, int who)
+{
+ return syscall (__NR_ioprio_get, which, who);
+}
+
+enum {
+ IOPRIO_CLASS_NONE,
+ IOPRIO_CLASS_RT,
+ IOPRIO_CLASS_BE,
+ IOPRIO_CLASS_IDLE,
+};
+
+enum {
+ IOPRIO_WHO_PROCESS = 1,
+ IOPRIO_WHO_PGRP,
+ IOPRIO_WHO_USER,
+};
+
+#define IOPRIO_CLASS_SHIFT 13
+#define IOPRIO_PRIO_MASK 0xff
+
+int set_io_priority_idle (void)
+{
+ int ioprio, ioclass;
+
+ ioprio = 7; /* priority is ignored with idle class */
+ ioclass = IOPRIO_CLASS_IDLE << IOPRIO_CLASS_SHIFT;
+
+ return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio | ioclass);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]