Skip to content

Commit

Permalink
sched, cpuacct: export percpu cpuacct cgroup stats
Browse files Browse the repository at this point in the history
This patch export per-cpu CPU cycle usage for a given cpuacct cgroup.
There is a need for a user space monitor daemon to track group CPU
usage on per-cpu base.  It is also useful for monitoring CFS load
balancer behavior by tracking per CPU group usage.

Signed-off-by: Ken Chen <[email protected]>
Reviewed-by: Li Zefan <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ken Chen authored and Ingo Molnar committed Dec 16, 2008
1 parent 720f549 commit e9515c3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -9342,12 +9342,32 @@ static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype,
return err;
}

static int cpuacct_percpu_seq_read(struct cgroup *cgroup, struct cftype *cft,
struct seq_file *m)
{
struct cpuacct *ca = cgroup_ca(cgroup);
u64 percpu;
int i;

for_each_present_cpu(i) {
percpu = cpuacct_cpuusage_read(ca, i);
seq_printf(m, "%llu ", (unsigned long long) percpu);
}
seq_printf(m, "\n");
return 0;
}

static struct cftype files[] = {
{
.name = "usage",
.read_u64 = cpuusage_read,
.write_u64 = cpuusage_write,
},
{
.name = "usage_percpu",
.read_seq_string = cpuacct_percpu_seq_read,
},

};

static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
Expand Down

0 comments on commit e9515c3

Please sign in to comment.