[PATCH -tip] cpuacct: reduce one NULL check in fast-path

From: Li Zefan
Date: Wed Mar 11 2009 - 21:23:20 EST


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@xxxxxxxxxxxxxx>
---

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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/