Skip to contentSkip to conversation

Staircase scheduler v7.7

PATCH In review Con Kolivas 2 participants 2 messages Jun 27, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staircase scheduler v7.7

This is a scheduler policy rewrite designed to be interactive by design without tweaks or tuning and be lean and extensible for all sorts of settings. (see previous announcements for more detail).

Patches (including incrementals from previous versions) against 2.6.7 and 2.6.7-ck2 can be downloaded from:
http://ck.kolivas.org/patches/2.6/

Changes since v7.4:

Two major bugs:
- Nanosecond to jiffy conversion meant it was possible to queue a task with no timeslice. Fixed.
- The preempt logic I added to 7.4 to allow preempted tasks to continue where they left off turned out to be a DoS recipe. Fixed.

Cleanup:
- Cleaned up comments.

Additions:
- None! Aiming for stability in this release.

Thanks to all those giving feedback I've been able to track down quite subtle bugs.

Please test, comment
Con

Full patch against 2.6.7 attached.

7 files changed, 267 insertions(+), 609 deletions(-)
fs/proc/array.c +2 -2
Index: linux-2.6.7-staircase/fs/proc/array.c
===================================================================
@@ -155,7 +155,7 @@
 	read_lock(&tasklist_lock);
 	buffer += sprintf(buffer,
 		"State:\t%s\n"
-		"SleepAVG:\t%lu%%\n"
+		"Burst:\t%d\n"
 		"Tgid:\t%d\n"
 		"Pid:\t%d\n"
 		"PPid:\t%d\n"
@@ -163,7 +163,7 @@
 		"Uid:\t%d\t%d\t%d\t%d\n"
 		"Gid:\t%d\t%d\t%d\t%d\n",
 		get_task_state(p),
-		(p->sleep_avg/1024)*100/(1020000000/1024),
+		p->burst,
 	       	p->tgid,
 		p->pid, p->pid ? p->real_parent->pid : 0,
 		p->pid && p->ptrace ? p->parent->pid : 0,
include/linux/sched.h +5 -8
Index: linux-2.6.7-staircase/include/linux/sched.h
===================================================================
@@ -164,6 +164,7 @@
 
 void io_schedule(void);
 long io_schedule_timeout(long timeout);
+extern int interactive, compute;
 
 extern void cpu_init (void);
 extern void trap_init(void);
@@ -325,7 +326,6 @@
 extern struct user_struct root_user;
 #define INIT_USER (&root_user)
 
-typedef struct prio_array prio_array_t;
 struct backing_dev_info;
 struct reclaim_state;
 
@@ -392,16 +392,13 @@
 
 	int prio, static_prio;
 	struct list_head run_list;
-	prio_array_t *array;
-
-	unsigned long sleep_avg;
-	long interactive_credit;
 	unsigned long long timestamp;
-	int activated;
+	unsigned long runtime, totalrun;
+	unsigned int burst;
 
 	unsigned long policy;
 	cpumask_t cpus_allowed;
-	unsigned int time_slice, first_time_slice;
+	unsigned int slice, time_slice;
 
 	struct list_head tasks;
 	struct list_head ptrace_children;
@@ -549,6 +546,7 @@
 #define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
 #define PF_SYNCWRITE	0x00200000	/* I am doing a sync write */
+#define PF_FORKED	0x00400000	/* I have just forked */
 
 #ifdef CONFIG_SMP
 #define SCHED_LOAD_SCALE	128UL	/* increase resolution of load */
@@ -742,7 +740,6 @@
  }
 #endif
 extern void FASTCALL(sched_fork(task_t * p));
-extern void FASTCALL(sched_exit(task_t * p));
 
 extern int in_group_p(gid_t);
 extern int in_egroup_p(gid_t);
include/linux/sysctl.h +2 -0
Index: linux-2.6.7-staircase/include/linux/sysctl.h
===================================================================
@@ -133,6 +133,8 @@
 	KERN_NGROUPS_MAX=63,	/* int: NGROUPS_MAX */
 	KERN_SPARC_SCONS_PWROFF=64, /* int: serial console power-off halt */
 	KERN_HZ_TIMER=65,	/* int: hz timer on or off */
+	KERN_INTERACTIVE=66,	/* interactive tasks can have cpu bursts */
+	KERN_COMPUTE=67,	/* adjust timeslices for a compute server */
 };
 
 
init/main.c +8 -1
Index: linux-2.6.7-staircase/init/main.c
===================================================================
@@ -314,8 +314,15 @@
 #define smp_init()	do { } while (0)
 #endif
 
+unsigned long cache_decay_ticks;
 static inline void setup_per_cpu_areas(void) { }
-static inline void smp_prepare_cpus(unsigned int maxcpus) { }
+static void smp_prepare_cpus(unsigned int maxcpus)
+{
+	// Generic 2 tick cache_decay for uniprocessor
+	cache_decay_ticks = 2;
+	printk("Generic cache decay timeout: %ld msecs.\n",
+		(cache_decay_ticks * 1000 / HZ));
+}
 
 #else
 
kernel/exit.c +0 -1
Index: linux-2.6.7-staircase/kernel/exit.c
===================================================================
@@ -96,7 +96,6 @@
 	p->parent->cmaj_flt += p->maj_flt + p->cmaj_flt;
 	p->parent->cnvcsw += p->nvcsw + p->cnvcsw;
 	p->parent->cnivcsw += p->nivcsw + p->cnivcsw;
-	sched_exit(p);
 	write_unlock_irq(&tasklist_lock);
 	spin_unlock(&p->proc_lock);
 	proc_pid_flush(proc_dentry);
kernel/sched.c +234 -597

1,233 lines not on this page · raw message

kernel/sysctl.c +16 -0
Index: linux-2.6.7-staircase/kernel/sysctl.c
===================================================================
@@ -636,6 +636,22 @@
 		.mode		= 0444,
 		.proc_handler	= &proc_dointvec,
 	},
+	{
+		.ctl_name	= KERN_INTERACTIVE,
+		.procname	= "interactive",
+		.data		= &interactive,
+		.maxlen		= sizeof (int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
+	{
+		.ctl_name	= KERN_COMPUTE,
+		.procname	= "compute",
+		.data		= &compute,
+		.maxlen		= sizeof (int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
 	{ .ctl_name = 0 }
 };
 
#1 lore raw
Quoted 8 lines · Con Kolivas

Changes since v7.4:

Two major bugs:
- Nanosecond to jiffy conversion meant it was possible to queue a task with no timeslice. Fixed.
- The preempt logic I added to 7.4 to allow preempted tasks to continue where they left off turned out to be a DoS recipe. Fixed.

Seems all right in regards to the issues with 7.4.

I do though get that xmms sort of 'hangs'. Its not hard, it just say in the 'play' state, but the graph do not move, and no sound. This is fairly intermittently. Not sure though if it is scheduler only, something recent in -bk, or the recent alsa patch Takashi Iwai
posted (using dmix btw). I will have a look and let you know.

Cheers,

Signature · 1 line
Martin Schlemmer