RE: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()

From: Zhao Lei
Date: Wed Apr 06 2016 - 13:06:09 EST




> -----Original Message-----
> From: Srikar Dronamraju [mailto:srikar@xxxxxxxxxxxxxxxxxx]
> Sent: Wednesday, April 06, 2016 9:27 PM
> To: Anton Blanchard <anton@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>; Ingo Molnar <mingo@xxxxxxxxxx>;
> tglx@xxxxxxxxxxxxx; efault@xxxxxx; htejun@xxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx; tj@xxxxxxxxxx; torvalds@xxxxxxxxxxxxxxxxxxxx;
> zhaolei@xxxxxxxxxxxxxx; yangds.fnst@xxxxxxxxxxxxxx; hpa@xxxxxxxxx; Stephen
> Rothwell <sfr@xxxxxxxxxxxxxxxx>; Michael Ellerman <mpe@xxxxxxxxxxxxxx>;
> linuxppc-dev@xxxxxxxxxxxxxxxx
> Subject: Re: [PATCH] sched/cpuacct: Check for NULL when using task_pt_regs()
>
> * Anton Blanchard <anton@xxxxxxxxx> [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@xxxxxxxxx>
>
> Works for me too.
>
> Reported-and-Tested-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxxxxxxx>
>
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
>