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)
Oct 4 2024, 12:01 PM
Unknown Object (File)
Oct 1 2024, 10:24 AM
Unknown Object (File)
Sep 27 2024, 5:59 AM
Unknown Object (File)
Sep 20 2024, 7:33 AM
Unknown Object (File)
Sep 18 2024, 7:50 PM
Unknown Object (File)
Aug 31 2024, 12:59 PM
Unknown Object (File)
Aug 17 2024, 12:14 PM
Unknown Object (File)
Aug 16 2024, 3:26 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 Not Applicable
Unit
Tests Not Applicable

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.