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)
Feb 17 2024, 3:10 AM
Unknown Object (File)
Dec 20 2023, 4:04 AM
Unknown Object (File)
Dec 12 2023, 7:34 AM
Unknown Object (File)
Nov 6 2023, 4:20 AM
Unknown Object (File)
Nov 4 2023, 5:32 PM
Unknown Object (File)
Oct 14 2023, 8:06 PM
Unknown Object (File)
Oct 5 2023, 3:16 AM
Unknown Object (File)
Sep 11 2023, 1:25 PM
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.