Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Sep 2008 15:59:38 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/sys/vm vm_page.c
Message-ID:  <200809231559.m8NFxgXW049149@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
jhb         2008-09-23 15:59:38 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_7)
    sys/vm               vm_page.c 
  Log:
  SVN rev 183302 on 2008-09-23 15:59:38Z by jhb
  
  MFC: 179623
  Essentially, neither madvise(..., MADV_DONTNEED) nor madvise(..., MADV_FREE)
  work.  (Moreover, I don't believe that they have ever worked as intended.)
  The explanation is fairly simple.  Both MADV_DONTNEED and MADV_FREE perform
  vm_page_dontneed() on each page within the range given to madvise().  This
  function moves the page to the inactive queue.  Specifically, if the page is
  clean, it is moved to the head of the inactive queue where it is first in
  line for processing by the page daemon.  On the other hand, if it is dirty,
  it is placed at the tail.  Let's further examine the case in which the page
  is clean.  Recall that the page is at the head of the line for processing by
  the page daemon.  The expectation of vm_page_dontneed()'s author was that
  the page would be transferred from the inactive queue to the cache queue by
  the page daemon.  (Once the page is in the cache queue, it is, in effect,
  free, that is, it can be reallocated to a new vm object by vm_page_alloc()
  if it isn't reactivated quickly enough by a user of the old vm object.)  The
  trouble is that nowhere in the execution of either MADV_DONTNEED or
  MADV_FREE is either the machine-independent reference flag (PG_REFERENCED)
  or the reference bit in any page table entry (PTE) mapping the page cleared.
  Consequently, the immediate reaction of the page daemon is to reactivate the
  page because it is referenced.  In effect, the madvise() was for naught.
  The case in which the page was dirty is not too different.  Instead of being
  laundered, the page is reactivated.
  
  Note: The essential difference between MADV_DONTNEED and MADV_FREE is
  that MADV_FREE clears a page's dirty field.  So, MADV_FREE is always
  executing the clean case above.
  
  This revision changes vm_page_dontneed() to clear both the machine-
  independent reference flag (PG_REFERENCED) and the reference bit in all PTEs
  mapping the page.
  
  Approved by:    re (kib), alc
  
  Revision   Changes    Path
  1.357.2.4  +7 -0      src/sys/vm/vm_page.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809231559.m8NFxgXW049149>