Page MenuHomeFreeBSD

move thread switch tracing from mi_switch to sched_switch
ClosedPublic

Authored by avg on Mar 11 2017, 4:09 PM.
Tags
None
Referenced Files
F105728731: D9961.diff
Thu, Dec 19, 7:10 PM
Unknown Object (File)
Tue, Nov 26, 4:59 PM
Unknown Object (File)
Oct 16 2024, 3:17 AM
Unknown Object (File)
Oct 16 2024, 3:17 AM
Unknown Object (File)
Oct 16 2024, 3:16 AM
Unknown Object (File)
Oct 16 2024, 2:52 AM
Unknown Object (File)
Oct 2 2024, 7:45 PM
Unknown Object (File)
Sep 28 2024, 4:26 PM
Subscribers

Details

Summary

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.

Diff Detail

Event Timeline

This revision is now accepted and ready to land.Mar 11 2017, 8:01 PM

Another thought that has just occurred to me.
Do the running/spinning traces in the lock code really belong KTR_SCHED?
I think that spinning is the same as running from the scheduler's perspective, so I am not sure if those state switches are significant for the scheduler analysis.
Maybe they should be moved to KTR_LOCK ?

In D9961#206228, @avg wrote:

Another thought that has just occurred to me.
Do the running/spinning traces in the lock code really belong KTR_SCHED?
I think that spinning is the same as running from the scheduler's perspective, so I am not sure if those state switches are significant for the scheduler analysis.
Maybe they should be moved to KTR_LOCK ?

I find it useful when looking at traces with schedgraph. Spinning threads are technically running, but they are not making progress and they consume a scheduler-managed resource as they spin. So it's worth making the distinction IMO - I'd vote for keeping it.

In D9961#206378, @markj wrote:
In D9961#206228, @avg wrote:

Another thought that has just occurred to me.
Do the running/spinning traces in the lock code really belong KTR_SCHED?
I think that spinning is the same as running from the scheduler's perspective, so I am not sure if those state switches are significant for the scheduler analysis.
Maybe they should be moved to KTR_LOCK ?

I find it useful when looking at traces with schedgraph. Spinning threads are technically running, but they are not making progress and they consume a scheduler-managed resource as they spin. So it's worth making the distinction IMO - I'd vote for keeping it.

Agreed. They were added solely for use with schedgraph.

This revision was automatically updated to reflect the committed changes.