aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/sched.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 470480790f3f..6c4abfbd68e6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7211,15 +7211,43 @@ static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft)
7211 return (u64) tg->shares; 7211 return (u64) tg->shares;
7212} 7212}
7213 7213
7214static struct cftype cpu_shares = { 7214static u64 cpu_usage_read(struct cgroup *cgrp, struct cftype *cft)
7215 .name = "shares", 7215{
7216 .read_uint = cpu_shares_read_uint, 7216 struct task_group *tg = cgroup_tg(cgrp);
7217 .write_uint = cpu_shares_write_uint, 7217 unsigned long flags;
7218 u64 res = 0;
7219 int i;
7220
7221 for_each_possible_cpu(i) {
7222 /*
7223 * Lock to prevent races with updating 64-bit counters
7224 * on 32-bit arches.
7225 */
7226 spin_lock_irqsave(&cpu_rq(i)->lock, flags);
7227 res += tg->se[i]->sum_exec_runtime;
7228 spin_unlock_irqrestore(&cpu_rq(i)->lock, flags);
7229 }
7230 /* Convert from ns to ms */
7231 do_div(res, 1000000);
7232
7233 return res;
7234}
7235
7236static struct cftype cpu_files[] = {
7237 {
7238 .name = "shares",
7239 .read_uint = cpu_shares_read_uint,
7240 .write_uint = cpu_shares_write_uint,
7241 },
7242 {
7243 .name = "usage",
7244 .read_uint = cpu_usage_read,
7245 },
7218}; 7246};
7219 7247
7220static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont) 7248static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont)
7221{ 7249{
7222 return cgroup_add_file(cont, ss, &cpu_shares); 7250 return cgroup_add_files(cont, ss, cpu_files, ARRAY_SIZE(cpu_files));
7223} 7251}
7224 7252
7225struct cgroup_subsys cpu_cgroup_subsys = { 7253struct cgroup_subsys cpu_cgroup_subsys = {