Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Sep 2015 04:47:09 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r288296 - stable/10/sys/vm
Message-ID:  <201509270447.t8R4l9lg079132@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sun Sep 27 04:47:08 2015
New Revision: 288296
URL: https://svnweb.freebsd.org/changeset/base/288296

Log:
  MFC r288025
    Correct a non-fatal error in vm_pageout_worker().  vm_pageout_worker()
    should not assume that vm_pages_needed will remain set while it sleeps.
    Other threads can clear vm_pages_needed by performing a sufficient
    number of vm_page_free() calls, e.g., process termination.  The effect
    of this error was that vm_pageout_worker() would free and/or launder
    pages when, in fact, there was no shortage of free pages.
  
    Rewrite a nearby comment to describe all of the possible cases and not
    just the most common case.  The problem being that the comment made
    the most common case seem like the only case.

Modified:
  stable/10/sys/vm/vm_pageout.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/vm_pageout.c
==============================================================================
--- stable/10/sys/vm/vm_pageout.c	Sun Sep 27 04:40:54 2015	(r288295)
+++ stable/10/sys/vm/vm_pageout.c	Sun Sep 27 04:47:08 2015	(r288296)
@@ -1651,9 +1651,15 @@ vm_pageout_worker(void *arg)
 		}
 		if (vm_pages_needed) {
 			/*
-			 * Still not done, take a second pass without waiting
-			 * (unlimited dirty cleaning), otherwise sleep a bit
-			 * and try again.
+			 * We're still not done.  Either vm_pages_needed was
+			 * set by another thread during the previous scan
+			 * (typically, this happens during a level 0 scan) or
+			 * vm_pages_needed was already set and the scan failed
+			 * to free enough pages.  If we haven't yet performed
+			 * a level >= 2 scan (unlimited dirty cleaning), then
+			 * upgrade the level and scan again now.  Otherwise,
+			 * sleep a bit and try again later.  While sleeping,
+			 * vm_pages_needed can be cleared.
 			 */
 			if (domain->vmd_pass > 1)
 				msleep(&vm_pages_needed,
@@ -1664,15 +1670,14 @@ vm_pageout_worker(void *arg)
 			 * Good enough, sleep until required to refresh
 			 * stats.
 			 */
-			domain->vmd_pass = 0;
 			msleep(&vm_pages_needed, &vm_page_queue_free_mtx,
 			    PVM, "psleep", hz);
-
 		}
 		if (vm_pages_needed) {
 			cnt.v_pdwakeups++;
 			domain->vmd_pass++;
-		}
+		} else
+			domain->vmd_pass = 0;
 		mtx_unlock(&vm_page_queue_free_mtx);
 		vm_pageout_scan(domain, domain->vmd_pass);
 	}



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