* [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
@ 2016-04-13 8:17 Anton Blanchard
0 siblings, 0 replies; 7+ 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] 7+ messages in thread
* Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
2016-04-13 11:01 ` Michael Ellerman
@ 2016-04-13 11:21 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2016-04-13 11:21 UTC (permalink / raw)
To: Michael Ellerman
Cc: Srikar Dronamraju, Anton Blanchard, Peter Zijlstra, tglx, efault,
htejun, linux-kernel, tj, torvalds, zhaolei, yangds.fnst, hpa,
Stephen Rothwell, linuxppc-dev
* Michael Ellerman <mpe@ellerman.id.au> wrote:
> On Wed, 2016-04-13 at 09:43 +0200, Ingo Molnar wrote:
> > * Srikar Dronamraju <srikar@linux.vnet.ibm.com> wrote:
> >
> > > * Anton Blanchard <anton@samba.org> [2016-04-06 21:59:50]:
> > >
> > > > Looks good, and the patch below does fix the oops for me.
> > > >
> > > > Anton
> > > > --
> > > >
> > > > 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>
> > >
> > > Works for me too.
> > >
> > > Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> >
> > Could someone please re-send the fix, because it has not reached me nor lkml.
>
> It did hit LKML:
>
> http://lkml.kernel.org/r/20160406215950.04bc3f0b@kryten
>
> But that did have some verbiage at the top.
>
> Anton's also resent it directly To you.
So it was in my Spam folder, due to the following SPF softfail:
Received-SPF: softfail (google.com: domain of transitioning anton@samba.org does not designate 198.145.29.136 as permitted sender) client-ip=198.145.29.136;
have the patch now.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
2016-04-13 7:43 ` Ingo Molnar
@ 2016-04-13 11:01 ` Michael Ellerman
2016-04-13 11:21 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2016-04-13 11:01 UTC (permalink / raw)
To: Ingo Molnar, Srikar Dronamraju
Cc: Anton Blanchard, Peter Zijlstra, tglx, efault, htejun,
linux-kernel, tj, torvalds, zhaolei, yangds.fnst, hpa,
Stephen Rothwell, linuxppc-dev
On Wed, 2016-04-13 at 09:43 +0200, Ingo Molnar wrote:
> * Srikar Dronamraju <srikar@linux.vnet.ibm.com> wrote:
>
> > * Anton Blanchard <anton@samba.org> [2016-04-06 21:59:50]:
> >
> > > Looks good, and the patch below does fix the oops for me.
> > >
> > > Anton
> > > --
> > >
> > > 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>
> >
> > Works for me too.
> >
> > Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
>
> Could someone please re-send the fix, because it has not reached me nor lkml.
It did hit LKML:
http://lkml.kernel.org/r/20160406215950.04bc3f0b@kryten
But that did have some verbiage at the top.
Anton's also resent it directly To you.
cheers
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
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
1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2016-04-13 7:43 UTC (permalink / raw)
To: Srikar Dronamraju
Cc: Anton Blanchard, Peter Zijlstra, tglx, efault, htejun,
linux-kernel, tj, torvalds, zhaolei, yangds.fnst, hpa,
Stephen Rothwell, Michael Ellerman, linuxppc-dev
* Srikar Dronamraju <srikar@linux.vnet.ibm.com> wrote:
> * Anton Blanchard <anton@samba.org> [2016-04-06 21:59:50]:
>
> > Looks good, and the patch below does fix the oops for me.
> >
> > Anton
> > --
> >
> > 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>
>
> Works for me too.
>
> Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Could someone please re-send the fix, because it has not reached me nor lkml.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
2016-04-06 13:26 ` Srikar Dronamraju
@ 2016-04-06 17:05 ` Zhao Lei
2016-04-13 7:43 ` Ingo Molnar
1 sibling, 0 replies; 7+ messages in thread
From: Zhao Lei @ 2016-04-06 17:05 UTC (permalink / raw)
To: 'Srikar Dronamraju', 'Anton Blanchard'
Cc: 'Peter Zijlstra', 'Ingo Molnar',
tglx, efault, htejun, linux-kernel, tj, torvalds, yangds.fnst,
hpa, 'Stephen Rothwell', 'Michael Ellerman',
linuxppc-dev
> -----Original Message-----
> From: Srikar Dronamraju [mailto:srikar@linux.vnet.ibm.com]
> Sent: Wednesday, April 06, 2016 9:27 PM
> To: Anton Blanchard <anton@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>; Ingo Molnar <mingo@kernel.org>;
> 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>; Michael Ellerman <mpe@ellerman.id.au>;
> linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
>
> * Anton Blanchard <anton@samba.org> [2016-04-06 21:59:50]:
>
> > Looks good, and the patch below does fix the oops for me.
> >
> > Anton
> > --
> >
> > 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>
>
> Works for me too.
>
> Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
>
Thanks, all
I tested it in the vm(can not boot before fix):
[single cpu]
# for f in cpuacct.*; do echo "$f: "; cat $f; done
cpuacct.stat:
user 260
system 451
cpuacct.usage:
6923456654
cpuacct.usage_percpu:
6963446178
cpuacct.usage_percpu_sys:
2610934362
cpuacct.usage_percpu_user:
4451667140
cpuacct.usage_sys:
2612684054
cpuacct.usage_user:
4540275322
#
[2 cpu wih 8 maxcpus]
# for f in cpuacct.*; do echo "$f: "; cat $f; done
cpuacct.stat:
user 205
system 536
cpuacct.usage:
7293688020
cpuacct.usage_percpu:
3785674990 3551323200 0 0 0 0 0 0
cpuacct.usage_percpu_sys:
2227281124 1635060584 0 0 0 0 0 0
cpuacct.usage_percpu_user:
1567487176 1992278818 0 0 0 0 0 0
cpuacct.usage_sys:
3863445982
cpuacct.usage_user:
3643874038
#
# cat /proc/cpuinfo
processor : 0
cpu : POWER7 (raw), altivec supported
clock : 1000.000000MHz
revision : 2.3 (pvr 003f 0203)
processor : 1
cpu : POWER7 (raw), altivec supported
clock : 1000.000000MHz
revision : 2.3 (pvr 003f 0203)
timebase : 512000000
platform : pSeries
model : IBM pSeries (emulated by qemu)
machine : CHRP IBM pSeries (emulated by qemu)
#
Thanks
Zhaolei
> --
> Thanks and Regards
> Srikar Dronamraju
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
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
0 siblings, 2 replies; 7+ messages in thread
From: Srikar Dronamraju @ 2016-04-06 13:26 UTC (permalink / raw)
To: Anton Blanchard
Cc: Peter Zijlstra, Ingo Molnar, tglx, efault, htejun, linux-kernel,
tj, torvalds, zhaolei, yangds.fnst, hpa, Stephen Rothwell,
Michael Ellerman, linuxppc-dev
* Anton Blanchard <anton@samba.org> [2016-04-06 21:59:50]:
> Looks good, and the patch below does fix the oops for me.
>
> Anton
> --
>
> 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>
Works for me too.
Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
2016-04-06 11:08 ` Peter Zijlstra
@ 2016-04-06 11:59 ` Anton Blanchard
2016-04-06 13:26 ` Srikar Dronamraju
0 siblings, 1 reply; 7+ messages in thread
From: Anton Blanchard @ 2016-04-06 11:59 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Ingo Molnar, Srikar Dronamraju, tglx, efault, htejun,
linux-kernel, tj, torvalds, zhaolei, yangds.fnst, hpa,
Stephen Rothwell, Michael Ellerman, linuxppc-dev
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.
Anton
--
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();
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-04-13 11:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13 8:17 [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs() Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2016-03-22 8:37 [PATCH v4 4/4] cpuacct: split usage into user_usage and sys_usage Zhao Lei
2016-03-31 9:27 ` [tip:sched/core] sched/cpuacct: Split usage accounting " tip-bot for Dongsheng Yang
2016-04-04 14:03 ` Srikar Dronamraju
2016-04-06 6:54 ` Ingo Molnar
2016-04-06 10:32 ` Anton Blanchard
2016-04-06 11:08 ` Peter Zijlstra
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
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).