cvs commit: src/sys/sys malloc.h src/sys/kern kern_malloc.c src/sys/vm vm_contig.c vm_page.h

Brian Feldman green at FreeBSD.org
Sun Jul 18 23:21:27 PDT 2004


green       2004-07-19 06:21:27 UTC

  FreeBSD src repository

  Modified files:
    sys/sys              malloc.h 
    sys/kern             kern_malloc.c 
    sys/vm               vm_contig.c vm_page.h 
  Log:
  Reimplement contigmalloc(9) with an algorithm which stands a greatly-
  improved chance of working despite pressure from running programs.
  Instead of trying to throw a bunch of pages out to swap and hope for
  the best, only a range that can potentially fulfill contigmalloc(9)'s
  request will have its contents paged out (potentially, not forcibly)
  at a time.
  
  The new contigmalloc operation still operates in three passes, but it
  could potentially be tuned to more or less.  The first pass only looks
  at pages in the cache and free pages, so they would be thrown out
  without having to block.  If this is not enough, the subsequent passes
  page out any unwired memory.  To combat memory pressure refragmenting
  the section of memory being laundered, each page is removed from the
  systems' free memory queue once it has been freed so that blocking
  later doesn't cause the memory laundered so far to get reallocated.
  
  The page-out operations are now blocking, as it would make little sense
  to try to push out a page, then get its status immediately afterward
  to remove it from the available free pages queue, if it's unlikely to
  have been freed.  Another change is that if KVA allocation fails, the
  allocated memory segment will be freed and not leaked.
  
  There is a sysctl/tunable, defaulting to on, which causes the old
  contigmalloc() algorithm to be used.  Nonetheless, I have been using
  vm.old_contigmalloc=0 for over a month.  It is safe to switch at
  run-time to see the difference it makes.
  
  A new interface has been used which does not require mapping the
  allocated pages into KVA: vm_page.h functions vm_page_alloc_contig()
  and vm_page_release_contig().  These are what vm.old_contigmalloc=0
  uses internally, so the sysctl/tunable does not affect their operation.
  
  When using the contigmalloc(9) and contigfree(9) interfaces, memory
  is now tracked with malloc(9) stats.  Several functions have been
  exported from kern_malloc.c to allow other subsystems to use these
  statistics, as well.  This invalidates the BUGS section of the
  contigmalloc(9) manpage.
  
  Revision  Changes    Path
  1.135     +48 -28    src/sys/kern/kern_malloc.c
  1.77      +2 -0      src/sys/sys/malloc.h
  1.36      +270 -36   src/sys/vm/vm_contig.c
  1.132     +3 -0      src/sys/vm/vm_page.h


More information about the cvs-src mailing list