From: tip-bot for Glauber Costa <glommer@parallels.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
a.p.zijlstra@chello.nl, lizf@cn.fujitsu.com,
glommer@parallels.com, pjt@google.com, tglx@linutronix.de,
kamezawa.hiroyu@jp.fujitsu.com, mingo@elte.hu
Subject: [tip:sched/core] sched/accounting, cgroups: Reuse cgroup's parent pointer
Date: Tue, 6 Dec 2011 01:57:17 -0800 [thread overview]
Message-ID: <tip-44252e421ad81e711c5a9db158fad7f433f70665@git.kernel.org> (raw)
In-Reply-To: <1322498719-2255-3-git-send-email-glommer@parallels.com>
Commit-ID: 44252e421ad81e711c5a9db158fad7f433f70665
Gitweb: http://git.kernel.org/tip/44252e421ad81e711c5a9db158fad7f433f70665
Author: Glauber Costa <glommer@parallels.com>
AuthorDate: Mon, 28 Nov 2011 14:45:18 -0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 6 Dec 2011 09:06:40 +0100
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>
---
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 dbbe35f..a727c4e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7849,7 +7849,6 @@ struct cpuacct {
/* cpuusage holds pointer to a u64-type object on every cpu */
u64 __percpu *cpuusage;
struct percpu_counter cpustat[CPUACCT_STAT_NSTATS];
- struct cpuacct *parent;
};
struct cgroup_subsys cpuacct_subsys;
@@ -7868,6 +7867,13 @@ static inline struct cpuacct *task_ca(struct task_struct *tsk)
struct cpuacct, css);
}
+static inline struct cpuacct *parent_ca(struct cpuacct *ca)
+{
+ if (!ca || !ca->css.cgroup->parent)
+ return NULL;
+ return cgroup_ca(ca->css.cgroup->parent);
+}
+
/* create a new cpu accounting group */
static struct cgroup_subsys_state *cpuacct_create(
struct cgroup_subsys *ss, struct cgroup *cgrp)
@@ -7886,9 +7892,6 @@ static struct cgroup_subsys_state *cpuacct_create(
if (percpu_counter_init(&ca->cpustat[i], 0))
goto out_free_counters;
- if (cgrp->parent)
- ca->parent = cgroup_ca(cgrp->parent);
-
return &ca->css;
out_free_counters:
@@ -8055,7 +8058,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
ca = task_ca(tsk);
- for (; ca; ca = ca->parent) {
+ for (; ca; ca = parent_ca(ca)) {
u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
*cpuusage += cputime;
}
@@ -8097,7 +8100,7 @@ void cpuacct_update_stats(struct task_struct *tsk,
do {
__percpu_counter_add(&ca->cpustat[idx], val, batch);
- ca = ca->parent;
+ ca = parent_ca(ca);
} while (ca);
rcu_read_unlock();
}
next prev parent reply other threads:[~2011-12-06 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 16:45 [PATCH v2 0/3] cpuacct cgroup refactoring Glauber Costa
2011-11-28 16:45 ` [PATCH v2 1/3] Change cpustat fields to an array Glauber Costa
2011-12-06 9:56 ` [tip:sched/core] sched/accounting: " tip-bot for Glauber Costa
2011-11-28 16:45 ` [PATCH v2 2/3] Reuse cgroup's parent pointer Glauber Costa
2011-12-06 9:57 ` tip-bot for Glauber Costa [this message]
2011-11-28 16:45 ` [PATCH v2 3/3] cpuacct.stat: re-use scheduler statistics for the root cgroup Glauber Costa
2011-12-06 20:21 ` [tip:sched/core] sched/accounting: Re-use " tip-bot for Glauber Costa
2011-12-01 10:56 ` [PATCH v2 0/3] cpuacct cgroup refactoring Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-44252e421ad81e711c5a9db158fad7f433f70665@git.kernel.org \
--to=glommer@parallels.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome