Skip to contentSkip to conversation

Sched batch for staircase

PATCH In review Con Kolivas 1 participant 1 message Aug 4, 2004 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 Sched batch for staircase

This implements idle scheduling for the staircase scheduler.

SCHED_BATCH tasks are scheduled only when idle time is available, or transiently elevated to normal scheduling while in kernel mode.
Batch tasks have 10 times larger timeslices than normal policy tasks, so in compute mode (which already enlarges them 10 times) a nice 0 batch task has a 20 second long timeslice. Nice is supported between batch tasks.
Batch tasks are hyperthread aware and will not schedule if an SMT sibling is not idle or not running a batch tasks.

Schedtools and the heirloom toolchest currently have userspace support for the setting of sched_batch policy.

include/linux/init_task.h +2 -2
Index: linux-2.6.8-rc2-mm2/include/linux/init_task.h
===================================================================
@@ -72,8 +72,8 @@
 	.usage		= ATOMIC_INIT(2),				\
 	.flags		= 0,						\
 	.lock_depth	= -1,						\
-	.prio		= MAX_PRIO-20,					\
-	.static_prio	= MAX_PRIO-20,					\
+	.prio		= MAX_PRIO-21,					\
+	.static_prio	= MAX_PRIO-21,					\
 	.policy		= SCHED_NORMAL,					\
 	.cpus_allowed	= CPU_MASK_ALL,					\
 	.mm		= NULL,						\
include/linux/sched.h +5 -3
Index: linux-2.6.8-rc2-mm2/include/linux/sched.h
===================================================================
@@ -126,9 +126,10 @@
 #define SCHED_NORMAL		0
 #define SCHED_FIFO		1
 #define SCHED_RR		2
+#define SCHED_BATCH		3
 
 #define SCHED_MIN		0
-#define SCHED_MAX		2
+#define SCHED_MAX		3
 
 #define SCHED_RANGE(policy)	((policy) >= SCHED_MIN && \
 					(policy) <= SCHED_MAX)
@@ -327,9 +328,10 @@
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
-#define MAX_PRIO		(MAX_RT_PRIO + 40)
+#define MAX_PRIO		(MAX_RT_PRIO + 41)
 
-#define rt_task(p)		(unlikely((p)->prio < MAX_RT_PRIO))
+#define rt_task(p)		((p)->prio < MAX_RT_PRIO)
+#define batch_task(p)		((p)->policy == SCHED_BATCH)
 
 /*
  * Some day this will be a full-fledged user tracking system..
init/main.c +1 -1
Index: linux-2.6.8-rc2-mm2/init/main.c
===================================================================
@@ -685,7 +685,7 @@
 static int init(void * unused)
 {
 	lock_kernel();
-	current->prio = MAX_PRIO - 1;
+	current->prio = MAX_PRIO - 2;
 	/*
 	 * Tell the world that we're going to be the grim
 	 * reaper of innocent orphaned children.
kernel/sched.c +42 -16

150 lines not on this page · raw message