cvs commit: src/sys/vm uma_core.c uma_int.h

Bosko Milekic bmilekic at FreeBSD.org
Thu Jul 29 08:25:43 PDT 2004


bmilekic    2004-07-29 15:25:40 UTC

  FreeBSD src repository

  Modified files:
    sys/vm               uma_core.c uma_int.h 
  Log:
  Rework the way slab header storage space is calculated in UMA.
  
  - zone_large_init() stays pretty much the same.
  - zone_small_init() will try to stash the slab header in the slab page
    being allocated if the amount of calculated wasted space is less
    than UMA_MAX_WASTE (for both the UMA_ZONE_REFCNT case and regular
    case).  If the amount of wasted space is >= UMA_MAX_WASTE, then
    UMA_ZONE_OFFPAGE will be set and the slab header will be allocated
    separately for better use of space.
  - uma_startup() calculates the maximum ipers required in offpage slabs
    (so that the offpage slab header zone(s) can be sized accordingly).
    The algorithm used to calculate this replaces the old calculation
    (which only happened to work coincidentally).  We now iterate over
    possible object sizes, starting from the smallest one, until we
    determine that wastedspace calculated in zone_small_init() might
    end up being greater than UMA_MAX_WASTE, at which point we use the
    found object size to compute the maximum possible ipers.  The
    reason this works is because:
        - wastedspace versus objectsize is a see-saw function with
          local minima all equal to zero and local maxima growing
          directly proportioned to objectsize.  This implies that
          for objects up to or equal a certain objectsize, the see-saw
          remains entirely below UMA_MAX_WASTE, so for those objectsizes
          it is impossible to ever go OFFPAGE for slab headers.
        - ipers (items-per-slab) versus objectsize is an inversely
          proportional function which falls off very quickly (very large
          for small objectsizes).
        - To determine the maximum ipers we'll ever need from OFFPAGE
          slab headers we first find the largest objectsize for which
          we are guaranteed to not go offpage for and use it to compute
          ipers (as though we were offpage).  Since the only objectsizes
          allowed to go offpage are bigger than the found objectsize,
          and since ipers vs objectsize is inversely proportional (and
          monotonically decreasing), then we are guaranteed that the
          ipers computed is always >= what we will ever need in offpage
          slab headers.
  - Define UMA_FRITM_SZ and UMA_FRITMREF_SZ to be the actual (possibly
    padded) size of each freelist index so that offset calculations are
    fixed.
  
  This might fix weird data corruption problems and certainly allows
  ARM to now boot to at least single-user (via simulator).
  
  Tested on i386 UP by me.
  Tested on sparc64 SMP by fenner.
  Tested on ARM simulator to single-user by cognet.
  
  Revision  Changes    Path
  1.103     +166 -52   src/sys/vm/uma_core.c
  1.25      +10 -0     src/sys/vm/uma_int.h


More information about the cvs-src mailing list