Take the common functions of schedstats out, and privatise those that are scheduler design dependant. Signed-off-by: Con Kolivas Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/sched.h =================================================================== --- linux-2.6.10-rc1-mm2-plugsched1.orig/include/linux/sched.h 2004-10-30 00:20:11.034827926 +1000 +++ linux-2.6.10-rc1-mm2-plugsched1/include/linux/sched.h 2004-10-30 00:20:12.649569607 +1000 @@ -32,6 +32,7 @@ #include #include #include +#include struct exec_domain; Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/scheduler.h =================================================================== --- linux-2.6.10-rc1-mm2-plugsched1.orig/include/linux/scheduler.h 2004-10-30 00:19:31.771109110 +1000 +++ linux-2.6.10-rc1-mm2-plugsched1/include/linux/scheduler.h 2004-10-30 00:20:12.649569607 +1000 @@ -46,6 +46,9 @@ struct sched_drv void (*wait_task_inactive)(task_t *); void (*cpu_attach_domain)(struct sched_domain *, int); #endif +#ifdef CONFIG_SCHEDSTATS + int (*show_schedstat)(struct seq_file *, void *); +#endif }; /* Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c =================================================================== --- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/sched.c 2004-10-30 00:20:11.036827607 +1000 +++ linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c 2004-10-30 00:20:12.651569288 +1000 @@ -348,7 +348,7 @@ static inline void task_rq_unlock(runque */ #define SCHEDSTAT_VERSION 10 -static int show_schedstat(struct seq_file *seq, void *v) +static int ingo_show_schedstat(struct seq_file *seq, void *v) { int cpu; enum idle_type itype; @@ -407,32 +407,6 @@ static int show_schedstat(struct seq_fil return 0; } -static int schedstat_open(struct inode *inode, struct file *file) -{ - unsigned int size = PAGE_SIZE * (1 + num_online_cpus() / 32); - char *buf = kmalloc(size, GFP_KERNEL); - struct seq_file *m; - int res; - - if (!buf) - return -ENOMEM; - res = single_open(file, show_schedstat, NULL); - if (!res) { - m = file->private_data; - m->buf = buf; - m->size = size; - } else - kfree(buf); - return res; -} - -struct file_operations proc_schedstat_operations = { - .open = schedstat_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - # define schedstat_inc(rq, field) rq->field++; # define schedstat_add(rq, field, amt) rq->field += amt; #else /* !CONFIG_SCHEDSTATS */ @@ -4149,4 +4123,7 @@ struct sched_drv ingo_sched_drv = { .sched_idle_next = ingo_sched_idle_next, #endif #endif +#ifdef CONFIG_SCHEDSTATS + .show_schedstat = ingo_show_schedstat, +#endif }; Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c =================================================================== --- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/scheduler.c 2004-10-30 00:20:11.037827447 +1000 +++ linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c 2004-10-30 00:20:12.652569128 +1000 @@ -928,6 +928,36 @@ void __devinit init_sched_build_groups(s } #endif +#ifdef CONFIG_SCHEDSTATS +int show_schedstat(struct seq_file *seq, void *v); + +static int schedstat_open(struct inode *inode, struct file *file) +{ + unsigned int size = PAGE_SIZE * (1 + num_online_cpus() / 32); + char *buf = kmalloc(size, GFP_KERNEL); + struct seq_file *m; + int res; + + if (!buf) + return -ENOMEM; + res = single_open(file, show_schedstat, NULL); + if (!res) { + m = file->private_data; + m->buf = buf; + m->size = size; + } else + kfree(buf); + return res; +} + +struct file_operations proc_schedstat_operations = { + .open = schedstat_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +#endif + extern struct sched_drv ingo_sched_drv; struct sched_drv *scheduler = @@ -1136,3 +1166,10 @@ asmlinkage void schedule_tail(task_t *ta { scheduler->tail(task); } + +#ifdef CONFIG_SCHEDSTATS +int show_schedstat(struct seq_file *seq, void *v) +{ + return scheduler->show_schedstat(seq, v); +} +#endif