Skip to content
  • Gleb Smirnoff's avatar
    SMR protection for inpcbs · de2d4784
    Gleb Smirnoff authored
    With introduction of epoch(9) synchronization to network stack the
    inpcb database became protected by the network epoch together with
    static network data (interfaces, addresses, etc).  However, inpcb
    aren't static in nature, they are created and destroyed all the
    time, which creates some traffic on the epoch(9) garbage collector.
    
    Fairly new feature of uma(9) - Safe Memory Reclamation allows to
    safely free memory in page-sized batches, with virtually zero
    overhead compared to uma_zfree().  However, unlike epoch(9), it
    puts stricter requirement on the access to the protected memory,
    needing the critical(9) section to access it.  Details:
    
    - The database is already build on CK lists, thanks to epoch(9).
    - For write access nothing is changed.
    - For a lookup in the database SMR section is now required.
      Once the desired inpcb is found we need to transition from SMR
      section to r/w lock on the inpcb itself, with a check that inpcb
      isn't yet freed.  This requires some compexity, since SMR section
      itself is a critical(9) section.  The complexity is hidden from
      KPI users in inp_smr_lock().
    - For a inpcb list traversal (a pcblist sysctl, or broadcast
      notification) also a new KPI is provided, that hides internals of
      the database - inp_next(struct inp_iterator *).
    
    Reviewed by:		rrs
    Differential revision:	https://reviews.freebsd.org/D33022
    de2d4784