From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932264AbcDFLoY (ORCPT ); Wed, 6 Apr 2016 07:44:24 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:43693 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752751AbcDFLoN (ORCPT ); Wed, 6 Apr 2016 07:44:13 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="5324459" From: Zhao Lei To: "'Peter Zijlstra'" , "'Anton Blanchard'" CC: "'Ingo Molnar'" , "'Srikar Dronamraju'" , , , , , , , , , "'Stephen Rothwell'" , "'Michael Ellerman'" References: <20160404140312.GA28495@linux.vnet.ibm.com> <20160406065436.GB3078@gmail.com> <20160406203219.788ae7cf@kryten> <20160406110803.GI2906@worktop> In-Reply-To: <20160406110803.GI2906@worktop> Subject: RE: [tip:sched/core] sched/cpuacct: Split usage accounting into user_usage and sys_usage Date: Wed, 6 Apr 2016 19:43:53 +0800 Message-ID: <000001d18ff9$989475b0$c9bd6110$@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQJv7eQQvUiXwYUH3DrsRFUSXIIVxAIjY5GlAurW/AEBVS8BcwEtxKEaAT+vGVqd+Y+ikA== Content-Language: zh-cn X-yoursite-MailScanner-ID: 58E07408D260.ABFF3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhaolei@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Anton and Peter > -----Original Message----- > From: Peter Zijlstra [mailto:peterz@infradead.org] > Sent: Wednesday, April 06, 2016 7:08 PM > 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 > > 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. > Thanks for notice it. > 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? > Thanks, I'll confirm it in a Power7 VM from buildroot. (maybe need some hours or till tomorrow in a poor pc...) Btw, I reproduced this bug in above vm. Thanks Zhaolei >