From: Michael Ellerman <mpe@ellerman.id.au>
To: Anton Blanchard <anton@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
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 <sfr@canb.auug.org.au>,
linuxppc-dev@lists.ozlabs.org
Subject: Ping? Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
Date: Mon, 11 Apr 2016 16:16:15 +1000 [thread overview]
Message-ID: <1460355375.3444.6.camel@ellerman.id.au> (raw)
In-Reply-To: <20160406215950.04bc3f0b@kryten>
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 <anton@samba.org>
> ---
>
> 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();
>
>
prev parent reply other threads:[~2016-04-11 6:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` Michael Ellerman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460355375.3444.6.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=anton@samba.org \
--cc=efault@gmx.de \
--cc=hpa@zytor.com \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sfr@canb.auug.org.au \
--cc=srikar@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=yangds.fnst@cn.fujitsu.com \
--cc=zhaolei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).