aboutsummaryrefslogtreecommitdiff
path: root/tools/uma
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-07-30 18:54:34 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-07-30 21:40:12 +0000
commit4690e20eed17a6e79a67a8d10874fdc67a1c4ccf (patch)
treef4a5a897bd1019aa1926ce9ff444f447394b5cb6 /tools/uma
parent4670f90846d49027bf23435a30895a74264f1e79 (diff)
downloadsrc-4690e20eed17a6e79a67a8d10874fdc67a1c4ccf.tar.gz
src-4690e20eed17a6e79a67a8d10874fdc67a1c4ccf.zip
tools/uma/smrstress: fix kthread exit
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 in the other thread, which was the caller of kthread_add(). Fix it by adding kthread_exit() to the thread function. Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35999
Diffstat (limited to 'tools/uma')
-rw-r--r--tools/uma/smrstress/smrstress.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/uma/smrstress/smrstress.c b/tools/uma/smrstress/smrstress.c
index 7e7ee4ea065c..2cf5f50ffae4 100644
--- a/tools/uma/smrstress/smrstress.c
+++ b/tools/uma/smrstress/smrstress.c
@@ -123,6 +123,7 @@ smrs_thread(void *arg)
else
smrs_read();
atomic_add_int(&smrs_completed, 1);
+ kthread_exit();
}
static void