Page MenuHomeFreeBSD

Reduce umtx-related work on exec and exit

Authored by mjg on May 4 2019, 10:38 PM.



Vast majority of the time there is no need to do anything. The patch below avoids relocking proc and locking umtx + thread lock in the common case.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjg created this revision.May 4 2019, 10:38 PM
kib added inline comments.May 5 2019, 10:06 AM
4422 ↗(On Diff #57055)

So your problem is this PROC_UNLOCK() ?

I think it can be done much simpler. Since the process is single-threaded, its thread list must be stable there and you can avoid acquiring the PROC_LOCK() in umtx_exec_hook at all.

Of course the proper comment is due.

mjg updated this revision to Diff 57143.May 7 2019, 7:56 PM
  • remove proc locking in the first place
mjg added inline comments.May 7 2019, 7:57 PM
4422 ↗(On Diff #57055)

I'm after avoidable locks in general. umtx shows up as a minor global lock in the grand scheme of things, I don't see what's the problem plugging it.

kib accepted this revision.May 8 2019, 8:16 AM
kib added inline comments.
1871 ↗(On Diff #57143)

Why not write this part as

  if (td->td_lend_user_pri == prio ||
   td->td_user_pri == min(prio, td->td_base_user_pri) ||
   td->td_priority < td->td_user_pri)
This revision is now accepted and ready to land.May 8 2019, 8:16 AM
mjg added inline comments.May 8 2019, 4:27 PM
1871 ↗(On Diff #57143)

I wanted to keep this easier to modify should extra code be needed in the future.

This revision was automatically updated to reflect the committed changes.