Page MenuHomeFreeBSD

lockmgr: shrink struct lock by 8 bytes on LP64

Authored by mjg on Feb 15 2021, 4:43 AM.



Currently the struct has a 4 byte padding stemming from 3 ints.

  1. prio comfortably fits in short, unfortunately there is no dedicated type for it and plumbing it throughout the codebase is not worth it right now, instead an assert is added which covers also flags for safety
  2. lk_exslpfail can in principle exceed u_short, but the count is already not considered reliable and it only ever gets modified straight to 0. In other words it can be incrementing with an upper bound of USHORT_MAX

With these in place struct lock shrinks from 48 to 40 bytes.

Diff Detail

R10 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 requested review of this revision.Feb 15 2021, 4:43 AM
mjg updated this revision to Diff 83908.
mjg created this revision.

When lk_exslpfail is saturated, shouldn't you always broadcast wakeup on the exclusive queue? It should be rare enough to not matter, but waking only one waiter there might cause hang IMO.

  • add missing saturation checks
kib added inline comments.

Is this line too long now?

This revision is now accepted and ready to land.Feb 15 2021, 11:23 AM

It is 84 if that's what you mean, but few lines below there is a 82 and in general the limit is rather soft at least in this file so I don't think this is a problem.

This revision was automatically updated to reflect the committed changes.