Index: head/sys/kern/kern_ktrace.c =================================================================== --- head/sys/kern/kern_ktrace.c +++ head/sys/kern/kern_ktrace.c @@ -347,6 +347,9 @@ 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); } /* Index: head/sys/kern/subr_trap.c =================================================================== --- head/sys/kern/subr_trap.c +++ head/sys/kern/subr_trap.c @@ -130,9 +130,6 @@ PROC_UNLOCK(p); } #endif -#ifdef KTRACE - KTRUSERRET(td); -#endif /* * Charge system time if profiling. @@ -340,6 +337,10 @@ */ 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