diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index ba133b52afb3..19c9e17ce1e8 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -430,7 +430,11 @@ mi_switch(int flags, struct thread *newtd) PCPU_SET(switchticks, ticks); CTR4(KTR_PROC, "mi_switch: old thread %ld (td_sched %p, pid %ld, %s)", td->td_tid, td_get_sched(td), td->td_proc->p_pid, td->td_name); - SDT_PROBE0(sched, , , preempt); +#ifdef KDTRACE_HOOKS + if ((flags & SW_PREEMPT) != 0 || ((flags & SW_INVOL) != 0 && + (flags & SW_TYPE_MASK) == SWT_NEEDRESCHED)) + SDT_PROBE0(sched, , , preempt); +#endif sched_switch(td, newtd, flags); CTR4(KTR_PROC, "mi_switch: new thread %ld (td_sched %p, pid %ld, %s)", td->td_tid, td_get_sched(td), td->td_proc->p_pid, td->td_name);