* [PATCH] cpuacct: reduce one NULL check in fast-path
@ 2009-03-11 2:15 Li Zefan
2009-03-11 9:47 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: Li Zefan @ 2009-03-11 2:15 UTC (permalink / raw)
To: Ingo Molnar
Cc: Peter Zijlstra, Paul Menage, Balbir Singh, Bharata B Rao, LKML
In cpuacct_charge(), task_ca() will never return NULL, so change
for(...) to do{}while(...) to save one NULL check.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/sched.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 9bb6d24..bc8a91e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9768,10 +9768,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
cpu = task_cpu(tsk);
ca = task_ca(tsk);
- for (; ca; ca = ca->parent) {
+ do {
u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
*cpuusage += cputime;
- }
+ ca = ca->parent;
+ } while (ca);
}
struct cgroup_subsys cpuacct_subsys = {
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] cpuacct: reduce one NULL check in fast-path
2009-03-11 2:15 [PATCH] cpuacct: reduce one NULL check in fast-path Li Zefan
@ 2009-03-11 9:47 ` Ingo Molnar
2009-03-12 1:23 ` [PATCH -tip] " Li Zefan
0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-03-11 9:47 UTC (permalink / raw)
To: Li Zefan; +Cc: Peter Zijlstra, Paul Menage, Balbir Singh, Bharata B Rao, LKML
* Li Zefan <lizf@cn.fujitsu.com> wrote:
> In cpuacct_charge(), task_ca() will never return NULL, so change
> for(...) to do{}while(...) to save one NULL check.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> kernel/sched.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 9bb6d24..bc8a91e 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -9768,10 +9768,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
> cpu = task_cpu(tsk);
> ca = task_ca(tsk);
>
> - for (; ca; ca = ca->parent) {
> + do {
> u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
> *cpuusage += cputime;
> - }
> + ca = ca->parent;
> + } while (ca);
This patch does not apply cleanly to the latest scheduler tree:
http://people.redhat.com/mingo/tip.git/README
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH -tip] cpuacct: reduce one NULL check in fast-path
2009-03-11 9:47 ` Ingo Molnar
@ 2009-03-12 1:23 ` Li Zefan
2009-03-13 4:03 ` [tip:core/percpu] " Li Zefan
0 siblings, 1 reply; 4+ messages in thread
From: Li Zefan @ 2009-03-12 1:23 UTC (permalink / raw)
To: Ingo Molnar
Cc: Peter Zijlstra, Paul Menage, Balbir Singh, Bharata B Rao, LKML
In cpuacct_charge(), task_ca() will never return NULL, so change
for(...) to do{}while(...) to save one NULL check.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
rebased on tip tree
---
kernel/sched.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index d40964b..c167f38 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9867,10 +9867,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
cpu = task_cpu(tsk);
ca = task_ca(tsk);
- for (; ca; ca = ca->parent) {
+ do {
u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
*cpuusage += cputime;
- }
+ ca = ca->parent;
+ } while (ca);
}
struct cgroup_subsys cpuacct_subsys = {
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [tip:core/percpu] cpuacct: reduce one NULL check in fast-path
2009-03-12 1:23 ` [PATCH -tip] " Li Zefan
@ 2009-03-13 4:03 ` Li Zefan
0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2009-03-13 4:03 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, a.p.zijlstra, lizf, menage, balbir,
bharata, tglx, mingo
Commit-ID: 7a46c594bf7f1f2eeb1e12d4b857d5f581957a92
Gitweb: http://git.kernel.org/tip/7a46c594bf7f1f2eeb1e12d4b857d5f581957a92
Author: Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 12 Mar 2009 09:23:01 +0800
Commit: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 13 Mar 2009 04:54:58 +0100
cpuacct: reduce one NULL check in fast-path
Impact: micro-optimization
In cpuacct_charge(), task_ca() will never return NULL, so change
for(...) to do { } while(...) to save one NULL check.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Menage <menage@google.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
LKML-Reference: <49B863F5.2060400@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 0a76d0b..61e6356 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9599,10 +9599,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
cpu = task_cpu(tsk);
ca = task_ca(tsk);
- for (; ca; ca = ca->parent) {
+ do {
u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
*cpuusage += cputime;
- }
+ ca = ca->parent;
+ } while (ca);
}
struct cgroup_subsys cpuacct_subsys = {
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-13 4:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-11 2:15 [PATCH] cpuacct: reduce one NULL check in fast-path Li Zefan
2009-03-11 9:47 ` Ingo Molnar
2009-03-12 1:23 ` [PATCH -tip] " Li Zefan
2009-03-13 4:03 ` [tip:core/percpu] " Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox