Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Feb 2014 12:13:12 +0000 (UTC)
From:      Peter Holm <pho@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r262479 - user/pho/stress2/testcases/swap
Message-ID:  <201402251213.s1PCDCgL091578@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pho
Date: Tue Feb 25 12:13:11 2014
New Revision: 262479
URL: http://svnweb.freebsd.org/changeset/base/262479

Log:
  Recalculate how much memory should be used for page stealing, specifically
  for hosts without a swap disk.
  
  Sponsored by:	EMC / Isilon storage division

Modified:
  user/pho/stress2/testcases/swap/swap.c

Modified: user/pho/stress2/testcases/swap/swap.c
==============================================================================
--- user/pho/stress2/testcases/swap/swap.c	Tue Feb 25 09:34:30 2014	(r262478)
+++ user/pho/stress2/testcases/swap/swap.c	Tue Feb 25 12:13:11 2014	(r262479)
@@ -37,9 +37,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/resource.h>
 #include <err.h>
 
-
 #include "stress.h"
 
+#if defined(__LP64__)
+#define MINLEFT (1792LL * 1024 * 1024)
+#else
+#define MINLEFT (1024LL * 1024 * 1024)
+#endif
+
 static unsigned long size;
 
 int
@@ -53,25 +58,33 @@ setup(int nb)
 	if (nb == 0) {
 		mem = usermem();
 		swapinfo = swap();
-		if (swapinfo > (int64_t)mem)
-			swapinfo = mem;
 
 		if (op->hog == 0)
-			pct = random_int(1, 10);
+			pct = random_int(80, 100);
 		
 		if (op->hog == 1)
-			pct = random_int(10, 20);
+			pct = random_int(100, 110);
 		
 		if (op->hog == 2)
-			pct = random_int(80, 90);
+			pct = random_int(110, 120);
 		
 		if (op->hog >= 3)
-			pct = random_int(100, 110);
+			pct = random_int(120, 130);
 
-		if (swapinfo == 0)
+		if (swapinfo == 0) {
+			if (mem <= MINLEFT)
+				_exit(1);
+			mem -= MINLEFT;
+			if (pct > 100)
+				pct = 100;
+			size = mem / 100 * pct;
+		} else {
 			size = mem / 100 * pct;
-		else
-			size = swapinfo / 100 * pct + mem;
+			if (size > mem + swapinfo / 4) {
+				size = mem + swapinfo / 4;
+				pct = size * 100 / mem;
+			}
+		}
 
 		size = size / op->incarnations;
 



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