Skip to contentSkip to conversation

use nice values in deadline IO scheduler

RFC PATCH New Charles Baylis 1 participant 1 message Dec 11, 2002 Block layer

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 use nice values in deadline IO scheduler

This untested patch uses the nice value of the current task to scale the deadline for new read requests.

Does current contain a pointer to the task which caused the IO request at this point? Is there any other reason why this might be a daft thing to do?

block/deadline-iosched.c renamed from block/deadline-iosched.c~std +15 -1
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/compiler.h>
 #include <linux/hash.h>
+#include <linux/sched.h>
 
 /*
  * feel free to try other values :-). read_expire value is the timeout for
@@ -81,6 +82,19 @@ static kmem_cache_t *drq_pool;
 #define RQ_DATA(rq)	((struct deadline_rq *) (rq)->elevator_private)
 
 /*
+ * scale_deadline
+ */
+static int scale_deadline(int default_deadline)
+{
+	int prio = current->static_prio - MAX_RT_PRIO;
+	/* make priorities higher than nice -10 equal to nice -10 */
+	if (prio < 10)
+		prio = 10;
+	/* scale the deadline according to priority */
+	return default_deadline * prio/20;
+}
+
+/*
  * rq hash
  */
 static inline void __deadline_del_rq_hash(struct deadline_rq *drq)
@@ -440,7 +454,7 @@ deadline_add_request(request_queue_t *q,
 		/*
 		 * set expire time and add to fifo list
 		 */
-		drq->expires = jiffies + dd->read_expire;
+		drq->expires = jiffies + scale_deadline(dd->read_expire);
 		list_add_tail(&drq->fifo, &dd->read_fifo);
 	}
 }