linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
@ 2016-04-13  8:17 Anton Blanchard
  0 siblings, 0 replies; 8+ messages in thread
From: Anton Blanchard @ 2016-04-13  8:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Srikar Dronamraju, tglx, efault,
	htejun, tj, torvalds, zhaolei, yangds.fnst, hpa, Stephen Rothwell,
	Michael Ellerman
  Cc: linuxppc-dev, linux-kernel

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@samba.org>
Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.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();
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-13 11:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <aa171da036b520b51c79549e9b3215d29473f19d.1458635566.git.zhaolei@cn.fujitsu.com>
     [not found] ` <tip-d740037fac7052e49450f6fa1454f1144a103b55@git.kernel.org>
     [not found]   ` <20160404140312.GA28495@linux.vnet.ibm.com>
     [not found]     ` <20160406065436.GB3078@gmail.com>
     [not found]       ` <20160406203219.788ae7cf@kryten>
     [not found]         ` <20160406110803.GI2906@worktop>
2016-04-06 11:59           ` [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs() Anton Blanchard
2016-04-06 13:26             ` Srikar Dronamraju
2016-04-06 17:05               ` Zhao Lei
2016-04-13  7:43               ` Ingo Molnar
2016-04-13 11:01                 ` Michael Ellerman
2016-04-13 11:21                   ` Ingo Molnar
2016-04-11  6:16             ` Ping? " Michael Ellerman
2016-04-13  8:17 Anton Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).