Skip to content
  • Warner Losh's avatar
    Move to a more robust and conservative alloation scheme for devctl messages · fd0a41d2
    Warner Losh authored
    Change the zone setup:
    - Allow slabs to be returned to the OS
    - Set the number of slots to the max devctl will queue before discarding
    - Reserve 2% of the max (capped at 100) for low memory allocations
    - Disable per-cpu caching since we don't need it and we avoid some pathologies
    
    Change the alloation strategiy a bit:
    - If a normal allocation fails, try to get the reserve
    - If a reserve allocation fails, re-use the oldest-queued entry for storage
    - If there's a weird race/failure and nothing on the queue to steal, return NULL
    
    This addresses two main issues in the old code:
    - If devd had died, and we're generating a lot of messages, we have an
      unbounded leak. This new scheme avoids the issue that lead to this.
    - The MPASS that was 'sure' the allocation couldn't have failed turned out
      to be wrong in some rare cases. The new code doesn't make this assumption.
    
    Since we reserve only 2% of the space, we go from about 1MB of
    allocation all the time to more like 50kB for the reserve.
    
    Reviewed by: markj@
    Differential Revision: https://reviews.freebsd.org/D26448
    fd0a41d2