diff options
author | Muchun Song <songmuchun@bytedance.com> | 2020-04-20 15:04:53 +0800 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-05-19 20:34:14 +0200 |
commit | dbe9337109c2705f08e6a00392f991eb2d2570a5 (patch) | |
tree | 7b5079a3ac04d5b5d3933b672e9ff93fef1a495d /kernel | |
parent | 04f5c362ec6d3ff0e14f1c05230b550da7f528a4 (diff) | |
download | linux-dbe9337109c2705f08e6a00392f991eb2d2570a5.tar.bz2 |
sched/cpuacct: Fix charge cpuacct.usage_sys
The user_mode(task_pt_regs(tsk)) always return true for
user thread, and false for kernel thread. So it means that
the cpuacct.usage_sys is the time that kernel thread uses
not the time that thread uses in the kernel mode. We can
try get_irq_regs() first, if it is NULL, then we can fall
back to task_pt_regs().
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200420070453.76815-1-songmuchun@bytedance.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched/cpuacct.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 6448b0438ffb..941c28cf9738 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -5,6 +5,7 @@ * Based on the work by Paul Menage (menage@google.com) and Balbir Singh * (balbir@in.ibm.com). */ +#include <asm/irq_regs.h> #include "sched.h" /* Time spent by the tasks of the CPU accounting group executing in ... */ @@ -339,7 +340,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime) { struct cpuacct *ca; int index = CPUACCT_STAT_SYSTEM; - struct pt_regs *regs = task_pt_regs(tsk); + struct pt_regs *regs = get_irq_regs() ? : task_pt_regs(tsk); if (regs && user_mode(regs)) index = CPUACCT_STAT_USER; |