lkml.org 
[lkml]   [2011]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/10] per-cgroup boot time
Date
Record the time in which the cgroup was created. This can be
used to provide a more accurate boottime information in
cpuacct.proc.stat.

Signed-off-by: Glauber Costa <glommer@parallels.com>
---
kernel/sched.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 5a8181e..a2554b7 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -279,6 +279,7 @@ struct task_group {
struct autogroup *autogroup;
#endif
struct kernel_stat __percpu *cpustat;
+ struct timespec start_time;
};

/* task_group_lock serializes the addition/removal of task groups */
@@ -8127,6 +8128,7 @@ void __init sched_init(void)
INIT_LIST_HEAD(&root_task_group.siblings);
autogroup_init(&init_task);

+ root_task_group.start_time = (struct timespec){0, 0};
root_task_group.cpustat = alloc_percpu(struct kernel_stat);
/* Failing that early an allocation means we're screwed anyway */
BUG_ON(!root_task_group.cpustat);
@@ -8598,6 +8600,8 @@ struct task_group *sched_create_group(struct task_group *parent)
kstat->cpustat[IOWAIT_BASE] = root_kstat->cpustat[IOWAIT];
}

+ get_monotonic_boottime(&tg->start_time);
+
spin_lock_irqsave(&task_group_lock, flags);
list_add_rcu(&tg->list, &task_groups);

@@ -9182,6 +9186,9 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
irq = softirq = steal = 0;
guest = guest_nice = 0;
getboottime(&boottime);
+#ifdef CONFIG_CGROUP_SCHED
+ boottime = timespec_add(boottime, tg->start_time);
+#endif
jif = boottime.tv_sec;

for_each_possible_cpu(i) {
--
1.7.6


\
 
 \ /
  Last update: 2011-10-02 21:25    [W:0.211 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site