If the INP lock is uncontested, avoid taking a reference and jumping
through the lock-switching hoops.
A few of the INP lookup operations that lock INPs after the lookup do
so using this mechanism (to maintain lock ordering):
- Lock lookup structure.
- Find INP.
- Acquire reference on INP.
- Drop lock on lookup structure.
- Acquire INP lock.
- Drop reference on INP.
This change provides a slightly shorter path for cases where the INP
lock is uncontested:
- Lock lookup structure.
- Find INP.
- Try to acquire the INP lock.
- 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.
This saves a few atomic operations when the INP lock is uncontested.
Discussed with: gallatin, rrs, rwatson
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D12911