move thread switch tracing from mi_switch to sched_switch
authoravg <avg@FreeBSD.org>
Thu, 23 Mar 2017 08:57:04 +0000 (08:57 +0000)
committeravg <avg@FreeBSD.org>
Thu, 23 Mar 2017 08:57:04 +0000 (08:57 +0000)
commit83025f4a689b721ca160af3adfbede5aa81d85cf
treed89167980d4a2663eab66faa2d11bc6c8e33632d
parent2d2d982c104bae649f5274e1456e12d171b94a47
move thread switch tracing from mi_switch to sched_switch

This is done so that the thread state changes during the switch
are not confused with the thread state changes reported when the thread
spins on a lock.

Here is an example, three consecutive entries for the same thread (from top to
bottom):

  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"sleep", attributes: prio:84, wmesg:"-", lockname:"(null)"
  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"spinning", attributes: lockname:"sched lock 1"
  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"running", attributes: none

The above trace could leave an impression that the final state of
the thread was "running".
After this change the sleep state will be reported after the "spinning"
and "running" states reported for the sched lock.

Reviewed by: jhb, markj
MFC after: 1 week
Sponsored by: Panzura
Differential Revision: https://reviews.freebsd.org/D9961
sys/kern/kern_synch.c
sys/kern/sched_4bsd.c
sys/kern/sched_ule.c
sys/sys/proc.h