[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20160413181738.5936e98a@kryten>
Date: Wed, 13 Apr 2016 18:17:38 +1000
From: Anton Blanchard <anton@...ba.org>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
tglx@...utronix.de, efault@....de, htejun@...il.com, tj@...nel.org,
torvalds@...ux-foundation.org, zhaolei@...fujitsu.com,
yangds.fnst@...fujitsu.com, hpa@...or.com,
Stephen Rothwell <sfr@...b.auug.org.au>,
Michael Ellerman <mpe@...erman.id.au>
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
task_pt_regs() can return NULL for kernel threads, so add a check.
This fixes an oops at boot on ppc64.
Fixes: d740037fac70 ("sched/cpuacct: Split usage accounting into user_usage and sys_usage")
Signed-off-by: Anton Blanchard <anton@...ba.org>
Reported-and-Tested-by: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
---
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index df947e0..41f85c4 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -316,12 +316,11 @@ static struct cftype files[] = {
void cpuacct_charge(struct task_struct *tsk, u64 cputime)
{
struct cpuacct *ca;
- int index;
+ int index = CPUACCT_USAGE_SYSTEM;
+ struct pt_regs *regs = task_pt_regs(tsk);
- if (user_mode(task_pt_regs(tsk)))
+ if (regs && user_mode(regs))
index = CPUACCT_USAGE_USER;
- else
- index = CPUACCT_USAGE_SYSTEM;
rcu_read_lock();
Powered by blists - more mailing lists