Re: [PATCH] perf: Don't enable the perf_event without in PERF_ATTACH_CONTEXT status
From: Peter Zijlstra
Date: Tue Jul 15 2014 - 05:58:40 EST
On Tue, Jul 15, 2014 at 04:56:58PM +0800, Zhang, Yanmin wrote:
> On 2014/7/14 21:27, Peter Zijlstra wrote:
> >On Thu, Jul 03, 2014 at 11:36:38AM +0800, Chen LinX wrote:
> >>From: "Chen LinX" <linx.z.chen@xxxxxxxxx>
> >>when do cpu hotplug test and run below perf test together, pmu may access freed perf_event
> >>while true;
> >>perf record -a -g -f sleep 10
> >>rm perf.*
> >>the scenario is that when cpu offline firstly, the 'perf_cpu_notify' will disable event on the
> >>pmu and remove it from the context list. after cpu online, the perf app may enable the event
> >But it does not, right?
> Thanks for your kind comments.
> It does, actually.
> The major reason is application calls many syscall to start perf.
> 1) perf_event_open => perf_install_in_context;
> 2) perf_ioctl => perf_event_enable.
That still does not compute; but you're right, it does call
perf_evlist__enable() which ends up calling IOC_ENABLE when there is no
target (ie. things like perf -a), because we created things with
Similar for ->initial_delay cruft.
> >>Signed-off-by: Yanmin Zhang <yanmin.zhang@xxxxxxxxx>
> >>Signed-off-by: Chen LinX <linx.z.chen@xxxxxxxxx>
> >Wrong SoB-chain, Yanmin didn't author this patch did he, seeing how From
> >is you. And Yanmin didn't actually send me this patch either.
> Lin works with me in the same team. He is smart, but new in kernel upstream
> community. I debugged with him and he caught the root cause ahead of me.
Well, then add a Reviewed-by from you or so, the double sob doesn't make
> The patch is good.
No its not, its got an incomprehensible changelog, and its not at all
clear why the perf_event_enable() path that doesn't use
__perf_event_enable() is correct.
Description: PGP signature