diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 89c3318a485f..8728801acdf7 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -347,6 +347,9 @@ ktr_enqueuerequest(struct thread *td, struct ktr_request *req) mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); + thread_lock(td); + td->td_flags |= TDF_ASTPENDING; + thread_unlock(td); } /* diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 3c7e54e3b195..0c7e43c40ea2 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -130,9 +130,6 @@ userret(struct thread *td, struct trapframe *frame) PROC_UNLOCK(p); } #endif -#ifdef KTRACE - KTRUSERRET(td); -#endif /* * Charge system time if profiling. @@ -341,6 +338,10 @@ ast(struct trapframe *framep) if (td->td_pflags & TDP_SIGFASTPENDING) sigfastblock_setpend(td, false); +#ifdef KTRACE + KTRUSERRET(td); +#endif + /* * We need to check to see if we have to exit or wait due to a * single threading requirement or some other STOP condition.