tools/sched_ext: scx_userland: fix restart and stats thread lifecycle bugs
authorDavid Carlier <devnexen@gmail.com>
Thu, 12 Feb 2026 20:35:19 +0000 (20:35 +0000)
committerTejun Heo <tj@kernel.org>
Thu, 12 Feb 2026 21:17:35 +0000 (11:17 -1000)
commit048714d9df73a724d3f84b587f1110963e32f9b3
treec8ad50f35d66bef9b8cf26445a108eebfa68d532
parent988369d236e46e6bc68d2616fbc008aa6b06a454
tools/sched_ext: scx_userland: fix restart and stats thread lifecycle bugs

Fix three issues in scx_userland's restart path:

- exit_req is not reset on restart, causing sched_main_loop() to exit
  immediately without doing any scheduling work.

- stats_printer thread handle is local to spawn_stats_thread(), making
  it impossible to join from main(). Promote it to file scope.

- The stats thread continues reading skel->bss after the skeleton is
  destroyed on restart, causing a use-after-free. Join the stats thread
  before destroying the skeleton to ensure it has exited.

Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/sched_ext/scx_userland.c