From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751827AbcDFLIu (ORCPT ); Wed, 6 Apr 2016 07:08:50 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:46514 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750788AbcDFLIt (ORCPT ); Wed, 6 Apr 2016 07:08:49 -0400 Date: Wed, 6 Apr 2016 13:08:03 +0200 From: Peter Zijlstra To: Anton Blanchard Cc: Ingo Molnar , 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 , Michael Ellerman Subject: Re: [tip:sched/core] sched/cpuacct: Split usage accounting into user_usage and sys_usage Message-ID: <20160406110803.GI2906@worktop> References: <20160404140312.GA28495@linux.vnet.ibm.com> <20160406065436.GB3078@gmail.com> <20160406203219.788ae7cf@kryten> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160406203219.788ae7cf@kryten> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 06, 2016 at 08:32:19PM +1000, Anton Blanchard wrote: > Hi, > > > > > void cpuacct_charge(struct task_struct *tsk, u64 cputime) > > > > { > > > > struct cpuacct *ca; > > > > + int index; > > > > + > > > > + if (user_mode(task_pt_regs(tsk))) > > > > + index = CPUACCT_USAGE_USER; > > > > + else > > > > + index = CPUACCT_USAGE_SYSTEM; > > This is oopsing because PowerPC task_pt_regs() returns NULL for > kernel threads. 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?