Page MenuHomeFreeBSD

lockmgr: shrink struct lock by 8 bytes on LP64
ClosedPublic

Authored by mjg on Feb 15 2021, 4:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 6:38 AM
Unknown Object (File)
Fri, Nov 1, 9:39 PM
Unknown Object (File)
Mon, Oct 28, 11:49 PM
Unknown Object (File)
Mon, Oct 28, 2:33 AM
Unknown Object (File)
Sat, Oct 19, 8:49 PM
Unknown Object (File)
Mon, Oct 14, 2:42 PM
Unknown Object (File)
Oct 1 2024, 1:24 PM
Unknown Object (File)
Oct 1 2024, 5:28 AM
Subscribers
None

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
rG FreeBSD src repository
Lint
Lint Not Applicable
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.
sys/kern/kern_lock.c
357

Is this line too long now?

This revision is now accepted and ready to land.Feb 15 2021, 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.