Skip to content

Commit 12aa258

Browse files
Muchun SongPeter Zijlstra
authored andcommitted
sched/cpuacct: Use __this_cpu_add() instead of this_cpu_ptr()
The cpuacct_charge() and cpuacct_account_field() are called with rq->lock held, and this means preemption(and IRQs) are indeed disabled, so it is safe to use __this_cpu_*() to allow for better code-generation. Signed-off-by: Muchun Song <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7d148be commit 12aa258

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/sched/cpuacct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
347347
rcu_read_lock();
348348

349349
for (ca = task_ca(tsk); ca; ca = parent_ca(ca))
350-
this_cpu_ptr(ca->cpuusage)->usages[index] += cputime;
350+
__this_cpu_add(ca->cpuusage->usages[index], cputime);
351351

352352
rcu_read_unlock();
353353
}
@@ -363,7 +363,7 @@ void cpuacct_account_field(struct task_struct *tsk, int index, u64 val)
363363

364364
rcu_read_lock();
365365
for (ca = task_ca(tsk); ca != &root_cpuacct; ca = parent_ca(ca))
366-
this_cpu_ptr(ca->cpustat)->cpustat[index] += val;
366+
__this_cpu_add(ca->cpustat->cpustat[index], val);
367367
rcu_read_unlock();
368368
}
369369

0 commit comments

Comments
 (0)