Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751841AbcDKGQW (ORCPT ); Mon, 11 Apr 2016 02:16:22 -0400 Received: from ozlabs.org ([103.22.144.67]:32843 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718AbcDKGQV (ORCPT ); Mon, 11 Apr 2016 02:16:21 -0400 Message-ID: <1460355375.3444.6.camel@ellerman.id.au> Subject: Ping? Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs() From: Michael Ellerman To: Anton Blanchard , Peter Zijlstra , Ingo Molnar Cc: Srikar Dronamraju , tglx@linutronix.de, efault@gmx.de, htejun@gmail.com, linux-kernel@vger.kernel.org, tj@kernel.org, torvalds@linux-foundation.org, zhaolei@cn.fujitsu.com, yangds.fnst@cn.fujitsu.com, hpa@zytor.com, Stephen Rothwell , linuxppc-dev@lists.ozlabs.org Date: Mon, 11 Apr 2016 16:16:15 +1000 In-Reply-To: <20160406215950.04bc3f0b@kryten> References: <20160404140312.GA28495@linux.vnet.ibm.com> <20160406065436.GB3078@gmail.com> <20160406203219.788ae7cf@kryten> <20160406110803.GI2906@worktop> <20160406215950.04bc3f0b@kryten> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5-1ubuntu3.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1317 Lines: 52 Hi Peter/Ingo, On Wed, 2016-04-06 at 21:59 +1000, Anton Blanchard wrote: > Hi Peter, > > > Ah, so sometihng like: > > > > struct pt_regs *regs = task_pt_regs(); > > int index = CPUACCT_USAGE_SYSTEM; > > > > if (regs && user_mode(regs)) > > index = CPUACCT_USAGE_USER; > > > > should work, right? > > Looks good, and the patch below does fix the oops for me. Can we get this merged please? It's blocking all my boot tests. If anyone's bothered: Fixes: d740037fac70 ("sched/cpuacct: Split usage accounting into user_usage and sys_usage") cheers > task_pt_regs() can return NULL for kernel threads, so add a check. > This fixes an oops at boot on ppc64. > > Signed-off-by: Anton Blanchard > --- > > 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(); > >