diff options
author | Glauber Costa <glommer@parallels.com> | 2011-11-28 11:45:18 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-12-06 03:06:40 -0500 |
commit | 44252e421ad81e711c5a9db158fad7f433f70665 (patch) | |
tree | b1a276337d8e7926d553795584cbf17ccf36bfeb /kernel | |
parent | 3292beb340c76884427faa1f5d6085719477d889 (diff) |
sched/accounting, cgroups: Reuse cgroup's parent pointer
We already have a pointer to the cgroup parent (whose data is more likely
to be in the cache than this, anyway), so there is no need to have this one
in cpuacct.
This patch makes the underlying cgroup be used instead.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Paul Tuner <pjt@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1322498719-2255-3-git-send-email-glommer@parallels.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched/core.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index dbbe35ff93fc..a727c4ea9a3e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -7849,7 +7849,6 @@ struct cpuacct { | |||
7849 | /* cpuusage holds pointer to a u64-type object on every cpu */ | 7849 | /* cpuusage holds pointer to a u64-type object on every cpu */ |
7850 | u64 __percpu *cpuusage; | 7850 | u64 __percpu *cpuusage; |
7851 | struct percpu_counter cpustat[CPUACCT_STAT_NSTATS]; | 7851 | struct percpu_counter cpustat[CPUACCT_STAT_NSTATS]; |
7852 | struct cpuacct *parent; | ||
7853 | }; | 7852 | }; |
7854 | 7853 | ||
7855 | struct cgroup_subsys cpuacct_subsys; | 7854 | struct cgroup_subsys cpuacct_subsys; |
@@ -7868,6 +7867,13 @@ static inline struct cpuacct *task_ca(struct task_struct *tsk) | |||
7868 | struct cpuacct, css); | 7867 | struct cpuacct, css); |
7869 | } | 7868 | } |
7870 | 7869 | ||
7870 | static inline struct cpuacct *parent_ca(struct cpuacct *ca) | ||
7871 | { | ||
7872 | if (!ca || !ca->css.cgroup->parent) | ||
7873 | return NULL; | ||
7874 | return cgroup_ca(ca->css.cgroup->parent); | ||
7875 | } | ||
7876 | |||
7871 | /* create a new cpu accounting group */ | 7877 | /* create a new cpu accounting group */ |
7872 | static struct cgroup_subsys_state *cpuacct_create( | 7878 | static struct cgroup_subsys_state *cpuacct_create( |
7873 | struct cgroup_subsys *ss, struct cgroup *cgrp) | 7879 | struct cgroup_subsys *ss, struct cgroup *cgrp) |
@@ -7886,9 +7892,6 @@ static struct cgroup_subsys_state *cpuacct_create( | |||
7886 | if (percpu_counter_init(&ca->cpustat[i], 0)) | 7892 | if (percpu_counter_init(&ca->cpustat[i], 0)) |
7887 | goto out_free_counters; | 7893 | goto out_free_counters; |
7888 | 7894 | ||
7889 | if (cgrp->parent) | ||
7890 | ca->parent = cgroup_ca(cgrp->parent); | ||
7891 | |||
7892 | return &ca->css; | 7895 | return &ca->css; |
7893 | 7896 | ||
7894 | out_free_counters: | 7897 | out_free_counters: |
@@ -8055,7 +8058,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime) | |||
8055 | 8058 | ||
8056 | ca = task_ca(tsk); | 8059 | ca = task_ca(tsk); |
8057 | 8060 | ||
8058 | for (; ca; ca = ca->parent) { | 8061 | for (; ca; ca = parent_ca(ca)) { |
8059 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); | 8062 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); |
8060 | *cpuusage += cputime; | 8063 | *cpuusage += cputime; |
8061 | } | 8064 | } |
@@ -8097,7 +8100,7 @@ void cpuacct_update_stats(struct task_struct *tsk, | |||
8097 | 8100 | ||
8098 | do { | 8101 | do { |
8099 | __percpu_counter_add(&ca->cpustat[idx], val, batch); | 8102 | __percpu_counter_add(&ca->cpustat[idx], val, batch); |
8100 | ca = ca->parent; | 8103 | ca = parent_ca(ca); |
8101 | } while (ca); | 8104 | } while (ca); |
8102 | rcu_read_unlock(); | 8105 | rcu_read_unlock(); |
8103 | } | 8106 | } |