Skip to contentSkip to conversation

cpuacct: per-cgroup utime/stime statistics - v7

PATCH In review Bharata B Rao 1 participant 2 messages Mar 31, 2009 – Apr 1, 2009 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuacct: per-cgroup utime/stime statistics - v7

Hi,

Here is the next version of the cpuacct statistics patch to obtain per-cgroup system and user times. This version changes the names from stime to system and utime to user.

Ingo, Could you please take this in now ?

Regards,
Bharata.

cpuacct: Add system and user time statistics

Add per-cgroup cpuacct controller statistics like the system and user time consumed by the group of tasks.

Changelog:

v7
- Changed the name of the statistic from utime to user and from stime to system so that in future we could easily add other statistics like irq, softirq, steal times etc easily.

v6
- Fixed a bug in the error path of cpuacct_create() (pointed by Li Zefan).

v5
- In cpuacct_stats_show(), use cputime64_to_clock_t() since we are operating on a 64bit variable here.

v4
- Remove comments in cpuacct_update_stats() which explained why rcu_read_lock() was needed (as per Peter Zijlstra's review comments).
- Don't say that percpu_counter_read() is broken in Documentation/cpuacct.txt as per KAMEZAWA Hiroyuki's review comments.

v3
- Fix a small race in the cpuacct hierarchy walk.

v2
- stime and utime now exported in clock_t units instead of msecs.
- Addressed the code review comments from Balbir and Li Zefan.
- Moved to -tip tree.

v1
- Moved the stime/utime accounting to cpuacct controller.

Earlier versions
- http://lkml.org/lkml/2009/2/25/129

---
 Documentation/cgroups/cpuacct.txt |   18 +++++++
 kernel/sched.c                    |   87 +++++++++++++++++++++++++++++++++++---
 2 files changed, 99 insertions(+), 6 deletions(-)
Documentation/cgroups/cpuacct.txt +18 -0
@@ -30,3 +30,21 @@ The above steps create a new group g1 an
 process (bash) into it. CPU time consumed by this bash and its children
 can be obtained from g1/cpuacct.usage and the same is accumulated in
 /cgroups/cpuacct.usage also.
+
+cpuacct.stat file lists a few statistics which further divide the
+CPU time obtained by the cgroup into user and system times. Currently
+the following statistics are supported:
+
+user: Time spent by tasks of the cgroup in user mode.
+system: Time spent by tasks of the cgroup in kernel mode.
+
+user and system are in USER_HZ unit.
+
+cpuacct controller uses percpu_counter interface to collect user and
+system times. This has two side effects:
+
+- It is theoretically possible to see wrong values for user and system times.
+  This is because percpu_counter_read() on 32bit systems isn't safe
+  against concurrent writes.
+- It is possible to see slightly outdated values for user and system times
+  due to the batch processing nature of percpu_counter.
kernel/sched.c +81 -6

155 lines not on this page · raw message

#1 lore raw

[tip:sched/urgent] cpuacct: add per-cgroup utime/stime statistics

Commit-ID:  ef12fefabf94b6a902ad3abd3eb124b00560c445
Gitweb:     http://git.kernel.org/tip/ef12fefabf94b6a902ad3abd3eb124b00560c445
Author:     Bharata B Rao <[email protected]>
AuthorDate: Tue, 31 Mar 2009 10:02:22 +0530
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 1 Apr 2009 16:49:38 +0200

cpuacct: add per-cgroup utime/stime statistics

Add per-cgroup cpuacct controller statistics like the system and user time consumed by the group of tasks.

Changelog:

v7
- Changed the name of the statistic from utime to user and from stime to system so that in future we could easily add other statistics like irq, softirq, steal times etc easily.

v6
- Fixed a bug in the error path of cpuacct_create() (pointed by Li Zefan).

v5
- In cpuacct_stats_show(), use cputime64_to_clock_t() since we are operating on a 64bit variable here.

v4
- Remove comments in cpuacct_update_stats() which explained why rcu_read_lock() was needed (as per Peter Zijlstra's review comments).
- Don't say that percpu_counter_read() is broken in Documentation/cpuacct.txt as per KAMEZAWA Hiroyuki's review comments.

v3
- Fix a small race in the cpuacct hierarchy walk.

v2
- stime and utime now exported in clock_t units instead of msecs.
- Addressed the code review comments from Balbir and Li Zefan.
- Moved to -tip tree.

v1
- Moved the stime/utime accounting to cpuacct controller.

Earlier versions
- http://lkml.org/lkml/2009/2/25/129

LKML-Reference: <[email protected]>

---
 Documentation/cgroups/cpuacct.txt |   18 ++++++++
 kernel/sched.c                    |   87 ++++++++++++++++++++++++++++++++++---
 2 files changed, 99 insertions(+), 6 deletions(-)
Documentation/cgroups/cpuacct.txt +18 -0
index bb775fb..8b93094 100644
@@ -30,3 +30,21 @@ The above steps create a new group g1 and move the current shell
 process (bash) into it. CPU time consumed by this bash and its children
 can be obtained from g1/cpuacct.usage and the same is accumulated in
 /cgroups/cpuacct.usage also.
+
+cpuacct.stat file lists a few statistics which further divide the
+CPU time obtained by the cgroup into user and system times. Currently
+the following statistics are supported:
+
+user: Time spent by tasks of the cgroup in user mode.
+system: Time spent by tasks of the cgroup in kernel mode.
+
+user and system are in USER_HZ unit.
+
+cpuacct controller uses percpu_counter interface to collect user and
+system times. This has two side effects:
+
+- It is theoretically possible to see wrong values for user and system times.
+  This is because percpu_counter_read() on 32bit systems isn't safe
+  against concurrent writes.
+- It is possible to see slightly outdated values for user and system times
+  due to the batch processing nature of percpu_counter.
kernel/sched.c +81 -6

155 lines not on this page · raw message