Page MenuHomeFreeBSD

lockmgr: shrink struct lock by 8 bytes on LP64
ClosedPublic

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

Details

Summary

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

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjg requested review of this revision.Mon, Feb 15, 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.
sys/kern/kern_lock.c
357

Is this line too long now?

This revision is now accepted and ready to land.Mon, Feb 15, 11:23 AM
sys/kern/kern_lock.c
357

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.