Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2017 16:18:53 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323226 - head/sys/vm
Message-ID:  <201709061618.v86GIrTi032140@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Sep  6 16:18:53 2017
New Revision: 323226
URL: https://svnweb.freebsd.org/changeset/base/323226

Log:
  Do not leak empty swblk.
  
  In swp_pager_meta_build(), if the requested operation results in
  freeing the last swap pointer in the swblk, free the trie node.  Other
  swap pager code does not expect to find completely empty swblk.
  
  Reviewed by:	alc, markj
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/vm/swap_pager.c

Modified: head/sys/vm/swap_pager.c
==============================================================================
--- head/sys/vm/swap_pager.c	Wed Sep  6 16:18:06 2017	(r323225)
+++ head/sys/vm/swap_pager.c	Wed Sep  6 16:18:53 2017	(r323226)
@@ -1824,6 +1824,21 @@ allocated:
 		swp_pager_freeswapspace(sb->d[modpi], 1);
 	/* Enter block into metadata. */
 	sb->d[modpi] = swapblk;
+
+	/*
+	 * Free the swblk if we end up with the empty page run.
+	 */
+	if (swapblk == SWAPBLK_NONE) {
+		for (i = 0; i < SWAP_META_PAGES; i++) {
+			if (sb->d[i] != SWAPBLK_NONE)
+				break;
+		}
+		if (i == SWAP_META_PAGES) {
+			SWAP_PCTRIE_REMOVE(&object->un_pager.swp.swp_blks,
+			    rdpi);
+			uma_zfree(swblk_zone, sb);
+		}
+	}
 }
 
 /*



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