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, Dec 18, 10:38 PM
Unknown Object (File)
Wed, Dec 18, 10:36 PM
Unknown Object (File)
Wed, Dec 18, 11:23 AM
Unknown Object (File)
Sat, Nov 23, 9:57 PM
Unknown Object (File)
Nov 22 2024, 12:36 AM
Unknown Object (File)
Nov 12 2024, 1:21 PM
Unknown Object (File)
Nov 12 2024, 8:45 AM
Unknown Object (File)
Nov 6 2024, 6:38 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.