Re: [RFC][PATCH 12/12] perf: Collapse and fix event_function_call() users

From: Sasha Levin
Date: Wed Feb 17 2016 - 17:40:15 EST


On 01/11/2016 11:25 AM, Peter Zijlstra wrote:
> There is one common bug left in all the event_function_call() users,
> between loading ctx->task and getting to the remote_function(),
> ctx->task can already have been changed.
>
> Therefore we need to double check and retry if ctx->task != current.
>
> Insert another trampoline specific to event_function_call() that
> checks for this and further validates state. This also allows getting
> rid of the active/inactive functions.
>
>
> Note: Stephane, can you please look at __perf_event_enable()?
>
> Cc: Stephane Eranian <eranian@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Hey Peter,

I seem to be hitting a warning added by this patch:

[ 258.890172] WARNING: CPU: 5 PID: 14801 at kernel/events/core.c:226 event_function+0x3a7/0x550()
[ 258.891356] Modules linked in:[ 258.892440] CPU: 5 PID: 14801 Comm: syz-executor Not tainted 4.5.0-rc4-next-20160217-sasha-00024-g888c008-dirty #2976
[ 258.893818] 1ffff1006c57bf07 ffff880362bdf8c0 ffffffffa43d511d ffffffff00000005
[ 258.895071] fffffbfff60265b8 0000000041b58ab3 ffffffffafb1d490 ffffffffa43d4f85
[ 258.896127] ffffffffa25984c0 0000000000000038 0000000000000282 ffff880362bdf898
[ 258.897182] Call Trace:
[ 258.897559] [<ffffffffa43d511d>] dump_stack+0x198/0x21b
[ 258.898258] [<ffffffffa43d4f85>] ? arch_local_irq_restore+0x5f/0x5f
[ 258.899099] [<ffffffffa25984c0>] ? is_module_text_address+0x20/0x20
[ 258.899934] [<ffffffffa23a6851>] warn_slowpath_common+0xe1/0x160
[ 258.900723] [<ffffffffa268cf07>] ? event_function+0x3a7/0x550
[ 258.901473] [<ffffffffa23a6a99>] warn_slowpath_null+0x29/0x30
[ 258.902186] [<ffffffffa268cf07>] event_function+0x3a7/0x550
[ 258.902913] [<ffffffffa268cb60>] ? perf_event_read_event+0x3c0/0x3c0
[ 258.906328] [<ffffffffa267d7a0>] ? free_ctx+0x70/0x70
[ 258.907633] [<ffffffffa267d8ea>] remote_function+0x14a/0x200
[ 258.908776] [<ffffffffa2582cb8>] generic_exec_single+0x2e8/0x5a0
[ 258.913186] [<ffffffffa258314d>] smp_call_function_single+0x1dd/0x350
[ 258.917536] [<ffffffffa267bc83>] task_function_call+0x123/0x160
[ 258.938733] [<ffffffffa267dbdb>] event_function_call+0x23b/0x440
[ 258.949427] [<ffffffffa267df7f>] _perf_event_enable+0xbf/0x100
[ 258.952368] [<ffffffffa267e04c>] _perf_event_refresh+0x8c/0xd0
[ 258.953776] [<ffffffffa26aa49f>] perf_ioctl+0x2af/0x870
[ 258.963056] [<ffffffffa28fcc60>] do_vfs_ioctl+0x1b0/0x1250
[ 258.975817] [<ffffffffa28fdd8f>] SyS_ioctl+0x8f/0xc0
[ 258.976277] [<ffffffffad5c96c0>] entry_SYSCALL_64_fastpath+0x23/0xc1


Thanks,
Sasha