]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r331309:
authorjtl <jtl@FreeBSD.org>
Fri, 20 Apr 2018 14:47:02 +0000 (14:47 +0000)
committerjtl <jtl@FreeBSD.org>
Fri, 20 Apr 2018 14:47:02 +0000 (14:47 +0000)
commitc8becd360b596e12c5127301aa5890d424b204d5
treeba2b2da7339ad0ffba1c58d6b243daad5eaaffb2
parent5098b0e414172b2ed3ee9d0db33ca3ddcb72ac8c
MFC r331309:
  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):

  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.

  This saves a few atomic operations when the INP lock is uncontested.

Sponsored by: Netflix, Inc.
sys/netinet/in_pcb.c
sys/netinet6/in6_pcb.c