[PATCH] scheduler params ...

From: Davide Libenzi (davidel@xmailserver.org)
Date: Sun Dec 30 2001 - 16:12:07 EST


Linus, this is the patch the implement that tabled nice to ticks logic and
that decrease the actual time slice to ~40ms for 0 nice tasks.
Plus it brings the mm affinity to 1

- Davide

diff -Nru linux-2.5.2-pre3.vanilla/include/linux/sched.h linux-2.5.2-pre3.psch/include/linux/sched.h
--- linux-2.5.2-pre3.vanilla/include/linux/sched.h Thu Dec 27 20:11:25 2001
+++ linux-2.5.2-pre3.psch/include/linux/sched.h Fri Dec 28 10:37:17 2001
@@ -302,7 +302,7 @@
  * all fields in a single cacheline that are needed for
  * the goodness() loop in schedule().
  */
- long dyn_prio;
+ unsigned long dyn_prio;
         long nice;
         unsigned long policy;
         struct mm_struct *mm;
@@ -452,7 +452,7 @@
  */
 #define _STK_LIM (8*1024*1024)

-#define MAX_DYNPRIO 100
+#define MAX_DYNPRIO 40
 #define DEF_TSLICE (6 * HZ / 100)
 #define MAX_TSLICE (20 * HZ / 100)
 #define DEF_NICE (0)
diff -Nru linux-2.5.2-pre3.vanilla/kernel/sched.c linux-2.5.2-pre3.psch/kernel/sched.c
--- linux-2.5.2-pre3.vanilla/kernel/sched.c Thu Dec 27 20:11:25 2001
+++ linux-2.5.2-pre3.psch/kernel/sched.c Sun Dec 30 12:49:27 2001
@@ -53,23 +53,17 @@
  * is a "high-priority" task, and a "+10" is a low-priority
  * task.
  *
- * We want the time-slice to be around 50ms or so, so this
+ * We want the time-slice to be around 35ms or so, so this
  * calculation depends on the value of HZ.
  */
-#if HZ < 200
-#define TICK_SCALE(x) ((x) >> 2)
-#elif HZ < 400
-#define TICK_SCALE(x) ((x) >> 1)
-#elif HZ < 800
-#define TICK_SCALE(x) (x)
-#elif HZ < 1600
-#define TICK_SCALE(x) ((x) << 1)
-#else
-#define TICK_SCALE(x) ((x) << 2)
-#endif
-
-#define NICE_TO_TICKS(nice) (TICK_SCALE(20-(nice))+1)
+#define NICE_RANGE 40
+#define MIN_NICE_TSLICE 10000
+#define MAX_NICE_TSLICE 70000
+#define NICE_TO_TICKS(nice) ts_table[19 - nice]
+
+static unsigned char ts_table[NICE_RANGE];

+#define MM_AFFINITY_BONUS 1

 /*
  * Init task must be ok at boot for the ix86 as we will check its signals
@@ -181,7 +175,7 @@

                 /* .. and a slight advantage to the current MM */
                 if (p->mm == this_mm || !p->mm)
- weight += 1;
+ weight += MM_AFFINITY_BONUS;
                 weight += 20 - p->nice;
                 goto out;
         }
@@ -533,7 +527,7 @@
                 p->need_resched = 1;
         else {
                 if (!--p->time_slice) {
- if (p->dyn_prio > 0) {
+ if (p->dyn_prio) {
                                 --p->time_slice;
                                 --p->dyn_prio;
                         }
@@ -1324,6 +1318,15 @@

 extern void init_timervecs (void);

+static void fill_tslice_map(void)
+{
+ int i;
+
+ for (i = 0; i < NICE_RANGE; i++)
+ ts_table[i] = ((MIN_NICE_TSLICE +
+ ((MAX_NICE_TSLICE - MIN_NICE_TSLICE) / NICE_RANGE) * i) * HZ) / 1000000;
+}
+
 void __init sched_init(void)
 {
         /*
@@ -1337,6 +1340,8 @@

         for(nr = 0; nr < PIDHASH_SZ; nr++)
                 pidhash[nr] = NULL;
+
+ fill_tslice_map();

         init_timervecs();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Dec 31 2001 - 21:00:23 EST