schedstat: consolidate per-task cpu runtime stats
authorKen Chen <kenchen@google.com>
Wed, 17 Dec 2008 07:41:22 +0000 (23:41 -0800)
committerIngo Molnar <mingo@elte.hu>
Thu, 18 Dec 2008 12:54:01 +0000 (13:54 +0100)
Impact: simplify code

When we turn on CONFIG_SCHEDSTATS, per-task cpu runtime is accumulated
twice. Once in task->se.sum_exec_runtime and once in sched_info.cpu_time.
These two stats are exactly the same.

Given that task->se.sum_exec_runtime is always accumulated by the core
scheduler, sched_info can reuse that data instead of duplicate the accounting.

Signed-off-by: Ken Chen <kenchen@google.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
fs/proc/base.c
include/linux/sched.h
kernel/delayacct.c
kernel/sched.c
kernel/sched_stats.h

index d4677603c88920b45e14af3d91b71894b2c5b7b2..4d745bac768c2bceb81e8791ee4df5823af5304d 100644 (file)
@@ -347,7 +347,7 @@ static int proc_pid_wchan(struct task_struct *task, char *buffer)
 static int proc_pid_schedstat(struct task_struct *task, char *buffer)
 {
        return sprintf(buffer, "%llu %llu %lu\n",
-                       task->sched_info.cpu_time,
+                       task->se.sum_exec_runtime,
                        task->sched_info.run_delay,
                        task->sched_info.pcount);
 }
index 8cccd6dc5d66728ff0fd640cd7f760373b805d48..2d1e840ddd35aef088999ea64446481945976ff9 100644 (file)
@@ -670,8 +670,7 @@ struct reclaim_state;
 struct sched_info {
        /* cumulative counters */
        unsigned long pcount;         /* # of times run on this cpu */
-       unsigned long long cpu_time,  /* time spent on the cpu */
-                          run_delay; /* time spent waiting on a runqueue */
+       unsigned long long run_delay; /* time spent waiting on a runqueue */
 
        /* timestamps */
        unsigned long long last_arrival,/* when we last ran on a cpu */
index b3179dad71be87d1f0d17258f82286abce3d9c47..abb6e17505e289f7a4db6757d48995030bddf477 100644 (file)
@@ -127,7 +127,7 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
         */
        t1 = tsk->sched_info.pcount;
        t2 = tsk->sched_info.run_delay;
-       t3 = tsk->sched_info.cpu_time;
+       t3 = tsk->se.sum_exec_runtime;
 
        d->cpu_count += t1;
 
index f53e2b8ef52153f8c8f95d48e28cf1afc0589d9e..fd835fc320b8951320389fc2ec89467270824e61 100644 (file)
@@ -596,6 +596,8 @@ struct rq {
 #ifdef CONFIG_SCHEDSTATS
        /* latency stats */
        struct sched_info rq_sched_info;
+       unsigned long long rq_cpu_time;
+       /* could above be rq->cfs_rq.exec_clock + rq->rt_rq.rt_runtime ? */
 
        /* sys_sched_yield() stats */
        unsigned int yld_exp_empty;
index 7dbf72a2b02cf16f256af7655eb9b28c7f3ef856..3b01098164c8963b47ad04d27f68eb7b711a37dc 100644 (file)
@@ -31,7 +31,7 @@ static int show_schedstat(struct seq_file *seq, void *v)
                    rq->yld_act_empty, rq->yld_exp_empty, rq->yld_count,
                    rq->sched_switch, rq->sched_count, rq->sched_goidle,
                    rq->ttwu_count, rq->ttwu_local,
-                   rq->rq_sched_info.cpu_time,
+                   rq->rq_cpu_time,
                    rq->rq_sched_info.run_delay, rq->rq_sched_info.pcount);
 
                seq_printf(seq, "\n");
@@ -123,7 +123,7 @@ static inline void
 rq_sched_info_depart(struct rq *rq, unsigned long long delta)
 {
        if (rq)
-               rq->rq_sched_info.cpu_time += delta;
+               rq->rq_cpu_time += delta;
 }
 
 static inline void
@@ -236,7 +236,6 @@ static inline void sched_info_depart(struct task_struct *t)
        unsigned long long delta = task_rq(t)->clock -
                                        t->sched_info.last_arrival;
 
-       t->sched_info.cpu_time += delta;
        rq_sched_info_depart(task_rq(t), delta);
 
        if (t->state == TASK_RUNNING)