kernel - Reduce slab allocator fragmentation
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 11 Aug 2015 02:08:00 +0000 (19:08 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 11 Aug 2015 02:57:22 +0000 (19:57 -0700)
commitc1b910532b21d32735a55bbee2b6ed98a9f9f8b4
tree4ec031f323f3ec51c34b799bdba40e1c3af9600a
parentb750642b06ad9228f7a14ffefb7dd047dcf2b94e
kernel - Reduce slab allocator fragmentation

* Restores the intent of the original z_Next test removed by the last
  commit and adjusts the related code comments.  This allows fully free
  zones at the head to be moved to the free list as long as other slabs
  are present for the chunking.

* Switch the zone management from LIST to TAILQ so we can manipulate the
  tail of the list.

* Define the head of a zone list as being more 'mature' zones, potentially
  freeable by any code which tends to cycle allocations.  The tail of the
  zone list is less mature and subject to reuse more quickly.

  - The allocator allocates from the tail (least mature).

  - Fully free zones are moved to the head (most mature).

  - First free of a fully allocated zone relists the zone at the head
    (the zone is considered mature).

  - Additional frees do not move the zone.

* TODO - We could also possibly shift the zone within the list based on
  NFree vs the NFree of adjacent zones, in order to heuristically allocate
  from the least-free zones and give the most-free zones a better chance
  to become fully free.

Reported-by: Adrian Drzewiecki <z@drze.net>
sys/kern/init_main.c
sys/kern/kern_slaballoc.c
sys/sys/slaballoc.h
sys/sys/systm.h
test/debug/zallocinfo.c