linux/tools/testing/selftests/powerpc/pmu/ebb
Athira Rajeev ef17515a8e selftests/powerpc/pmu/ebb: fix lost_exception_test hang with sched yield change
commit 79104becf4 ("sched/fair: Forfeit vruntime on yield") changed
yield_task_fair() to only bump the deadline when the entity is eligible
(vruntime <= avg_vruntime). When the entity is ineligible the yield
becomes a complete no-op from scheduling perspective.

lost_exception_test calls sched_yield() 100,000 times per iteration to
race the EBB exception delivery with a context switch to the eat_cpu
companion process. After enough iterations the test process's vruntime
races ahead of avg_vruntime (each eligible yield bumps vruntime to
deadline, then advances deadline by one slice). Once ineligible,
yield_task_fair() does nothing: so the scheduler won't pick the
eat_cpu child. No context switch occurs, the PMAO race is never
triggered, and ebb_count stays at 0 forever causing the test to
hang until timeout.

Fix by replacing sched_yield() with nanosleep(0, 1ns). nanosleep() goes
through hrtimer_nanosleep() -> do_nanosleep(), which puts the task into
TASK_INTERRUPTIBLE and removes it from the run queue entirely. This
guarantees the scheduler picks the eat_cpu child, restoring the
context-switch guarantee the test requires. The 1ns duration is enough
to engage the hrtimer path while keeping the sleep effectively
instantaneous; the same race window between PMU overflow and context
switch is preserved.

Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260903074036.63309-1-atrajeev@linux.ibm.com
2026-09-10 08:58:40 +05:30
..
.gitignore selftests/powerpc: Add missing files to .gitignores 2022-06-29 19:37:04 +10:00
back_to_back_ebbs_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
busy_loop.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
close_clears_pmcc_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
cpu_event_pinned_vs_ebb_test.c selftests/powerpc: Allow bind_to_cpu() to automatically pick CPU 2023-04-20 13:21:45 +10:00
cpu_event_vs_ebb_test.c selftests/powerpc: Allow bind_to_cpu() to automatically pick CPU 2023-04-20 13:21:45 +10:00
cycles_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
cycles_with_freeze_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
cycles_with_mmcr2_test.c selftests/powerpc: Avoid GCC 12 uninitialised variable warning 2022-08-01 22:21:18 +10:00
ebb_handler.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
ebb_on_child_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
ebb_on_willing_child_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
ebb_vs_cpu_event_test.c selftests/powerpc: Allow bind_to_cpu() to automatically pick CPU 2023-04-20 13:21:45 +10:00
ebb.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
ebb.h selftests/powerpc: Remove the repeated declaration 2021-06-15 17:12:27 +10:00
event_attributes_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
fork_cleanup_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
instruction_count_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
lost_exception_test.c selftests/powerpc/pmu/ebb: fix lost_exception_test hang with sched yield change 2026-09-10 08:58:40 +05:30
Makefile selftests/powerpc: Add flags.mk to support pmu buildable 2024-04-29 23:53:01 +10:00
multi_counter_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
multi_ebb_procs_test.c selftests/powerpc: Allow bind_to_cpu() to automatically pick CPU 2023-04-20 13:21:45 +10:00
no_handler_test.c selftests/powerpc: Fix "no_handler" EBB selftest 2021-06-17 00:09:11 +10:00
pmae_handling_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
pmc56_overflow_test.c selftests/powerpc: Purge extra count_pmc() calls of ebb selftests 2020-07-08 22:09:31 +10:00
reg_access_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
regs_access_pmccext_test.c selftests/powerpc: EBB selftest for MMCR0 control for PMU SPRs in ISA v3.1 2021-06-17 00:09:11 +10:00
task_event_pinned_vs_ebb_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
task_event_vs_ebb_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
trace.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 191 2019-05-30 11:29:21 -07:00
trace.h powerpc/mm: Replace zero-length array with flexible-array 2020-05-15 11:58:54 +10:00