Make public parts of schedstats
PATCH 25/28 Make public parts of schedstats
Make public parts of schedstats
Take the common functions of schedstats out, and privatise those that are scheduler design dependant.
Signed-off-by Con Kolivas <[email protected]>
include/linux/sched.h +1 -0
@@ -32,6 +32,7 @@#include <linux/pid.h> #include <linux/percpu.h> #include <linux/topology.h> +#include <linux/seq_file.h> struct exec_domain ;
include/linux/scheduler.h +3 -0
@@ -46,6 +46,9 @@ struct sched_drvvoid (*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 };/*
kernel/sched.c +4 -27
@@ -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 };
kernel/scheduler.c +37 -0
@@ -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