Page MenuHomeFreeBSD

Streamline the operations when acquiring the lock on an INP after a lookup
ClosedPublic

Authored by jtl on Nov 2 2017, 2:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 29, 11:45 AM
Unknown Object (File)
Feb 3 2024, 9:04 AM
Unknown Object (File)
Dec 20 2023, 2:56 AM
Unknown Object (File)
Dec 5 2023, 11:08 AM
Unknown Object (File)
Oct 21 2023, 1:30 PM
Unknown Object (File)
Aug 4 2023, 8:09 AM
Unknown Object (File)
Jul 4 2023, 5:10 PM
Unknown Object (File)
Jun 28 2023, 11:16 PM

Details

Summary

A few of the INP lookup operations that lock INPs after the lookup do so using this mechanism (to maintain lock ordering):

  1. Lock lookup structure.
  2. Find INP.
  3. Acquire reference on INP.
  4. Drop lock on lookup structure.
  5. Acquire INP lock.
  6. Drop reference on INP.

This change provides a slightly shorter path for cases where the INP lock is uncontested:

  1. Lock lookup structure.
  2. Find INP.
  3. Try to acquire the INP lock.
  4. If successful, drop lock on lookup structure.

Of course, if the INP lock is contested, the functions will need to revert to the previous way of switching locks safely.

Test Plan

Tested at high scale with no ill effects.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15664
Build 15693: arc lint + arc unit

Event Timeline

rwatson requested changes to this revision.Nov 13 2017, 8:03 PM

I like this change, and have not yet spotted any problems with it. The one change I might make is to add a few assertions before the final return(inp) in each case to assert that the held lock matches the requested lock.

This revision now requires changes to proceed.Nov 13 2017, 8:03 PM

Add assertions suggested by @rwatson.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 21 2018, 3:55 PM
This revision was automatically updated to reflect the committed changes.