Page MenuHomeFreeBSD

tools/uma/smrstress: fix kthread exit
ClosedPublic

Authored by kib on Jul 30 2022, 7:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 4, 1:37 AM
Unknown Object (File)
Nov 14 2024, 3:50 PM
Unknown Object (File)
Nov 14 2024, 3:16 AM
Unknown Object (File)
Nov 6 2024, 4:14 AM
Unknown Object (File)
Oct 2 2024, 1:58 PM
Unknown Object (File)
Sep 23 2024, 11:51 AM
Unknown Object (File)
Aug 31 2024, 11:17 AM
Unknown Object (File)
Aug 12 2024, 12:34 PM
Subscribers

Details

Summary
By convention, kernel threads must call kthread_exit() instead of
blindly returning from the thread function.  We have some safety measure
in fork_exit(), which checks for the P_KPROC p_flag and does
kthread_exit() for kernel thread that forgot to do it itself.

But this workaround only works for kernel threads belonging to the
kernel process.  If a kernel thread is attached to the normal process
with live userspace, and does not call kthread_exit(), then the
workaround is not activated, and for amd64 at least, the return from the
thread function/fork_exit() results in the return to userspace with the
copy of frame from the thread that did kthread_add().

Practically for smrstress, this destroys the user stack of the still
active frame.

Fix it by adding kthread_exit() to the thread function.

Reported by:    pho

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jul 30 2022, 7:01 PM
kib added a reviewer: markj.
This revision is now accepted and ready to land.Jul 30 2022, 8:59 PM
This revision was automatically updated to reflect the committed changes.