From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: Cliff Wickman <cpi@sgi.com>
Cc: Kornilios Kourtis <kkourt@cslab.ece.ntua.gr>,
	Brice Goglin <Brice.Goglin@inria.fr>, <linux-numa@vger.kernel.org>,
	<eric.whitney@hp.com>
Date:	Tue, 28 Apr 2009 12:36:56 -0400
Subject: [PATCH 6/8] numactl/numademo - eliminate page allocation overhead from memtest measurements

PATCH 6/08 numactl - Eliminate page allocation from memtest() measurements

Against:  numactl-2.0.3-rc2

The first loop [of LOOPS] in memtest() actually incurs the
page allocation overhead.  This results in an artificially
low minimum bandwidth, making the reported bandwidth appear to
be more variable than it really is.

Make an extra, un-measured pass through test buffer in
memtest() to allocate memory.  Don't report throughput
for page allocation phase.  If page allocation overhead
is of interest, a separate test could be added.  Or, we
could make this behavior [measure allocation loop],
optional.  

 numademo.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: numactl-dev/numademo.c
===================================================================
--- numactl-dev.orig/numademo.c
+++ numactl-dev/numademo.c
@@ -165,7 +165,11 @@ void memtest(char *name, unsigned char *
 	max = 0; 
 	min = ~0UL; 
 	sum = 0;
-	for (i = 0; i < LOOPS; i++) { 
+
+	/*
+	 * Note:  0th pass allocates the pages, don't measure
+	 */
+	for (i = 0; i < LOOPS+1; i++) {
 		clearcache(mem, msize);
 		switch (thistest) { 
 		case PTRCHASE:
@@ -240,6 +244,9 @@ void memtest(char *name, unsigned char *
 			break;
 		} 
 
+		if (!i)
+			continue;  /* don't count allocation pass */
+
 		timersub(&end, &start, &res);
 		r = timerfold(&res); 
 		if (r > max) max = r;
