- Fix raw data handling when perf events are used in bpf
- Rework how SIGTRAPs get delivered to events to address a bunch of problems with it. Add a selftest for that too -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEzv7L6UO9uDPlPSfHEsHwGGHeVUoFAmNVE9UACgkQEsHwGGHe VUpodRAAsn3s+xX02qfxRG0mYX/1nnOmnFnDhmUEPAZpDXjB6g3PFXAh26F9tw92 dLm8fbfp8W3tK7TQrGyOGWMnb7oj4gEoXAcQBXvsq2KOJMVwRHHKwCeSSJ89DLAW zZEl2nzgea2cGyZn2RZJvhmbm8YdFON3v++Vv34yovs1MMoCcD7FOPLLGWkD2gk5 6PK6lIlWEI/+vYKWhZdxgk6/PanBInXRUnbaBVj42US1XwfDLzPBEi9yyUUJQrht CQhfTpHn4Z5MC/hJTlFat4Jlaajql4JBcQ1SS5LW59M+6gdlBK4tL6zFt10zvU2m +kywOOIWiYLRRgFf6idGO45P5BuWOdmsXEaEg5KW7b6nJfGvgkd7WUYgCVOgtEY1 r4Mf4hAQUunDHGQ4e8eHk7XemFJsoBSweYCTQ2O0yr/QzO2M6QBi/BR9PzUajyH+ yShKEfrxXt4595BMH0nonSMpTKcE4Zxdj06LZSnGecEN8UUlx/n49uYwhFNdUkqM s6Wz6kSR76YRlKUmYnNzP1gkY6nJZ1nR6z7SjmMkioxf3VxhT9SY8K587r6hRUlr /NVA69iUhJy75VdttxZEmZzB03A7AjdudmZEisF0ImEmB1hxzYLHcDKJMTIj/r4/ f8OXCg5ACKhFlnx1SdBVRtA+6+5ab368Fs2rItJQ4dzdxRi6VVY= =DXG7 -----END PGP SIGNATURE----- Merge tag 'perf_urgent_for_v6.1_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull perf fixes from Borislav Petkov: - Fix raw data handling when perf events are used in bpf - Rework how SIGTRAPs get delivered to events to address a bunch of problems with it. Add a selftest for that too * tag 'perf_urgent_for_v6.1_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: bpf: Fix sample_flags for bpf_perf_event_output selftests/perf_events: Add a SIGTRAP stress test with disables perf: Fix missing SIGTRAPs
This commit is contained in:
commit
a703852408
5 changed files with 163 additions and 46 deletions
|
|
@ -62,6 +62,8 @@ static struct perf_event_attr make_event_attr(bool enabled, volatile void *addr,
|
|||
.remove_on_exec = 1, /* Required by sigtrap. */
|
||||
.sigtrap = 1, /* Request synchronous SIGTRAP on event. */
|
||||
.sig_data = TEST_SIG_DATA(addr, id),
|
||||
.exclude_kernel = 1, /* To allow */
|
||||
.exclude_hv = 1, /* running as !root */
|
||||
};
|
||||
return attr;
|
||||
}
|
||||
|
|
@ -93,9 +95,13 @@ static void *test_thread(void *arg)
|
|||
|
||||
__atomic_fetch_add(&ctx.tids_want_signal, tid, __ATOMIC_RELAXED);
|
||||
iter = ctx.iterate_on; /* read */
|
||||
for (i = 0; i < iter - 1; i++) {
|
||||
__atomic_fetch_add(&ctx.tids_want_signal, tid, __ATOMIC_RELAXED);
|
||||
ctx.iterate_on = iter; /* idempotent write */
|
||||
if (iter >= 0) {
|
||||
for (i = 0; i < iter - 1; i++) {
|
||||
__atomic_fetch_add(&ctx.tids_want_signal, tid, __ATOMIC_RELAXED);
|
||||
ctx.iterate_on = iter; /* idempotent write */
|
||||
}
|
||||
} else {
|
||||
while (ctx.iterate_on);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
@ -208,4 +214,27 @@ TEST_F(sigtrap_threads, signal_stress)
|
|||
EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on, 0));
|
||||
}
|
||||
|
||||
TEST_F(sigtrap_threads, signal_stress_with_disable)
|
||||
{
|
||||
const int target_count = NUM_THREADS * 3000;
|
||||
int i;
|
||||
|
||||
ctx.iterate_on = -1;
|
||||
|
||||
EXPECT_EQ(ioctl(self->fd, PERF_EVENT_IOC_ENABLE, 0), 0);
|
||||
pthread_barrier_wait(&self->barrier);
|
||||
while (__atomic_load_n(&ctx.signal_count, __ATOMIC_RELAXED) < target_count) {
|
||||
EXPECT_EQ(ioctl(self->fd, PERF_EVENT_IOC_DISABLE, 0), 0);
|
||||
EXPECT_EQ(ioctl(self->fd, PERF_EVENT_IOC_ENABLE, 0), 0);
|
||||
}
|
||||
ctx.iterate_on = 0;
|
||||
for (i = 0; i < NUM_THREADS; i++)
|
||||
ASSERT_EQ(pthread_join(self->threads[i], NULL), 0);
|
||||
EXPECT_EQ(ioctl(self->fd, PERF_EVENT_IOC_DISABLE, 0), 0);
|
||||
|
||||
EXPECT_EQ(ctx.first_siginfo.si_addr, &ctx.iterate_on);
|
||||
EXPECT_EQ(ctx.first_siginfo.si_perf_type, PERF_TYPE_BREAKPOINT);
|
||||
EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on, 0));
|
||||
}
|
||||
|
||||
TEST_HARNESS_MAIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue