From: Li Zefan Date: Thu, 12 Mar 2009 01:23:01 +0000 (+0800) Subject: cpuacct: reduce one NULL check in fast-path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7a46c594bf7f1f2eeb1e12d4b857d5f581957a92;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Peter Zijlstra Cc: Paul Menage Cc: Balbir Singh Cc: Bharata B Rao LKML-Reference: <49B863F5.2060400@cn.fujitsu.com> Signed-off-by: Ingo Molnar --- diff --git a/kernel/sched.c b/kernel/sched.c index 0a76d0b6f215..61e63562f273 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 = {