Re: [RFC][PATCH 07/12] perf: Simplify/fix perf_event_enable() event scheduling

From: James Morse
Date: Tue Mar 08 2016 - 05:06:01 EST


Hi Peter!

On 11/01/16 16:25, Peter Zijlstra wrote:
> Like enable_on_exec, perf_event_enable() event scheduling has problems
> respecting the context hierarchy when trying to schedule events (for
> example, it will try and add a pinned event without first removing
> existing flexible events).
>
> So simplify it by using the new ctx_resched() call which will DTRT.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

I'm seeing 'failures' for the ltp test perf_event_open02[0] with v4.5-rcs.
git bisect points to this patch[1].

I suspect the test is over-reliant on the behaviour of the removed code.

This has been seen on arm64 and x86_64[2].


Thanks,

James


[0]
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c

[1] Bisect log
----------------------------------------
git bisect start
# good: [afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc] Linux 4.4
git bisect good afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc
# bad: [18558cae0272f8fd9647e69d3fec1565a7949865] Linux 4.5-rc4
git bisect bad 18558cae0272f8fd9647e69d3fec1565a7949865
# good: [875fc4f5ddf35605581f9a5900c14afef48611f2] Merge branch 'akpm' (patches
from Andrew)
git bisect good 875fc4f5ddf35605581f9a5900c14afef48611f2
# good: [9f273c24ec5f4a6f785bb83e931b3808a07b459e] MAINTAINERS: add/fix git URLs
for various subsystems
git bisect good 9f273c24ec5f4a6f785bb83e931b3808a07b459e
# good: [2c9b3ebd5913c2d1371b749a8057ac32972b410d] Merge tag 'mmc-v4.5-rc1' of
git://git.linaro.org/people/ulf.hansson/mmc
git bisect good 2c9b3ebd5913c2d1371b749a8057ac32972b410d
# bad: [54e3f3e30245abb0d47e3bc53a1b3c75434616f1] Merge tag 'tty-4.5-rc2' of
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
git bisect bad 54e3f3e30245abb0d47e3bc53a1b3c75434616f1
# good: [e1c10879ed59436cde537b723545430b04d4dec0] Merge tag
'platform-drivers-x86-v4.5-2' of
git://git.infradead.org/users/dvhart/linux-platform-drivers-x86
git bisect good e1c10879ed59436cde537b723545430b04d4dec0
# good: [f51d4d7826d64dee2c421267c7bd44c4d52805c5] Merge tag
'hwmon-for-linus-v4.5-rc2' of
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
git bisect good f51d4d7826d64dee2c421267c7bd44c4d52805c5
# good: [bbfb239a106d41d793f58befdaf5c806e34ea97e] Merge branch
'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect good bbfb239a106d41d793f58befdaf5c806e34ea97e
# bad: [7ab85d4a85160ea2ffc96b1255443cbc83be180f] Merge branch
'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect bad 7ab85d4a85160ea2ffc96b1255443cbc83be180f
# bad: [45c815f06b80031659c63d7b93e580015d6024dd] perf: Synchronously free aux
pages in case of allocation failure
git bisect bad 45c815f06b80031659c63d7b93e580015d6024dd
# good: [70a0165752944e0be0b1de4a9020473079962c18] perf: Fix cgroup scheduling
in perf_enable_on_exec()
git bisect good 70a0165752944e0be0b1de4a9020473079962c18
# bad: [63e30d3e52d4d85854ce6c761ffc6ab55209a630] perf: Make ctx->is_active and
cpuctx->task_ctx consistent
git bisect bad 63e30d3e52d4d85854ce6c761ffc6ab55209a630
# good: [8833d0e286c12fd4456089a7a553faf4921e4b08] perf: Use task_ctx_sched_out()
git bisect good 8833d0e286c12fd4456089a7a553faf4921e4b08
# bad: [25432ae96a9889774a05bf5f0f6fd8dbcdec5e72] perf: Optimize
perf_sched_events() usage
git bisect bad 25432ae96a9889774a05bf5f0f6fd8dbcdec5e72
# bad: [aee7dbc45f8aa976913de9b352fa6da816f1f3cd] perf: Simplify/fix
perf_event_enable() event scheduling
git bisect bad aee7dbc45f8aa976913de9b352fa6da816f1f3cd
# first bad commit: [aee7dbc45f8aa976913de9b352fa6da816f1f3cd] perf:
Simplify/fix perf_event_enable() event scheduling
----------------------------------------


[2]
----------------------------------------
x86_64, v4.2
nanook@trouble-every-day:~$ ./perf_event_open02 -v
at iteration:0 value:3001278671 time_enabled:378865967 time_running:378865967
at iteration:1 value:3001294516 time_enabled:379206798 time_running:379206798
at iteration:2 value:3001304264 time_enabled:379741658 time_running:379741658
at iteration:3 value:2247456463 time_enabled:381782350 time_running:285882994
perf_event_open02 0 TINFO : overall task clock: 382444297
perf_event_open02 0 TINFO : hw sum: 9004576323, task clock sum: 1146042829
hw counters: 1276985606 1284698955 1291658694 1294253771 1293189575 1285360592
1278429130
task clock counters: 162510606 163544930 164439727 164730880 164600624 163538072
162677990
perf_event_open02 0 TINFO : ratio: 3.00
perf_event_open02 1 TPASS : test passed
----------------------------------------
x86_64, v4.5-rc5:
nanook@trouble-every-day:~$ ./perf_event_open02 -v
at iteration:0 value:3001332678 time_enabled:379409484 time_running:379408991
perf_event_open02 0 TINFO : overall task clock: 381025905
perf_event_open02 0 TINFO : hw sum: 9004621962, task clock sum: 1142038427
hw counters: 2249100352 2254366204 2252915996 2248239410
task clock counters: 285302769 285853299 285787328 285095031
perf_event_open02 0 TINFO : ratio: 3.00
perf_event_open02 1 TFAIL : perf_event_open02.c:333: test failed (ratio
was greater than )
----------------------------------------