Skip to content

Commit 7a46c59

Browse files
Li ZefanIngo Molnar
authored andcommitted
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 <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Paul Menage <[email protected]> Cc: Balbir Singh <[email protected]> Cc: Bharata B Rao <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 65a37b2 commit 7a46c59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/sched.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9599,10 +9599,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
95999599
cpu = task_cpu(tsk);
96009600
ca = task_ca(tsk);
96019601

9602-
for (; ca; ca = ca->parent) {
9602+
do {
96039603
u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
96049604
*cpuusage += cputime;
9605-
}
9605+
ca = ca->parent;
9606+
} while (ca);
96069607
}
96079608

96089609
struct cgroup_subsys cpuacct_subsys = {

0 commit comments

Comments
 (0)