ll_rw_* i/o penalty patch...

Chad Page (cpage@best.com)
Wed, 12 Jul 1995 11:52:24 -0700 (PDT)


This patch, when activated, will penalize any process which does
block i/o to the actual device. This is for high load situations, in
which i/o bound processes will hopefully not be scheduled as much as before.

By default, this patch will not be active - you must uncomment the
#define COUNTER_DEC line for it to change the behavior. This makes it
safe for inclusion in the standard kernel. It also exacts a higher
penalty for any paging occuring during the processes turn... which could
help slow down memory intensive processes.

I wrote this because some users are complaining that i/o bound
processes are getting scheduled too much. If I am wrong here, tell me -
this patch won't hurt things anyway... :)

- Chad

--- ll_rw_blk.c.1.3.9 Sat Jul 1 09:05:59 1995
+++ ll_rw_blk.c Wed Jul 12 10:19:56 1995
@@ -21,6 +21,22 @@
#include <asm/io.h>
#include "blk.h"

+/* The following #define, when uncommented, adds a penalty to the current
+ processes priority (actually, the current->counter var.), which should
+ discourage excessive i/o... it only does anything when it gets to low-level
+ code, since the buffers go pretty fast anyway...
+*/
+
+/* #define COUNTER_DEC */
+
+#ifdef COUNTER_DEC
+ #define COUNTER_DEC_BLOCK 50
+ #define COUNTER_DEC_PAGE 200
+#else
+ #define COUNTER_DEC_BLOCK 0
+ #define COUNTER_DEC_PAGE 0
+#endif
+
/*
* The request-struct contains all necessary data
* to load a nr of sectors into memory
@@ -423,6 +439,11 @@
printk("Can't page to read-only device 0x%X\n",dev);
return;
}
+
+ current->counter -= COUNTER_DEC_PAGE;
+ if (current->counter < 0)
+ current->counter = 0;
+
req = get_request_wait(NR_REQUEST, dev);
/* fill up the request-info, and add it to the queue */
req->cmd = rw;
@@ -489,6 +510,13 @@
printk("Can't write to read-only device 0x%X\n",bh[0]->b_dev);
goto sorry;
}
+
+ /* At this point, let's change current->counter so the program won't go
+ straight for the block device again - if things are loaded... */
+
+ current->counter -= COUNTER_DEC_BLOCK;
+ if (current->counter < 0)
+ current->counter = 0;

/* If there are no pending requests for this device, then we insert
a dummy request for that device. This will prevent the request