[PATCH 7/8] memhog: add option to disable transparent huge pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Transparent Hugepages confuse the page accounting in the
test suite. Add an option to memhog (-H) to disable them.
---
 memhog.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/memhog.c b/memhog.c
index 2bc4251..b22f097 100755
--- a/memhog.c
+++ b/memhog.c
@@ -20,6 +20,7 @@
 #include <sys/mman.h>
 #include <sys/fcntl.h>
 #include <string.h>
+#include <stdbool.h>
 #include "numa.h"
 #include "numaif.h"
 #include "util.h"
@@ -37,6 +38,7 @@ void usage(void)
 {
 	printf("memhog [-rNUM] size[kmg] [policy [nodeset]]\n");
 	printf("-rNUM repeat memset NUM times\n");
+	printf("-H disable transparent hugepages\n");
 	print_policies();
 	exit(1);
 }
@@ -66,6 +68,7 @@ int main(int ac, char **av)
 	int loose = 0;
 	int i;
 	int fd = -1;
+	bool disable_hugepage = false;
 
 	nodes = numa_allocate_nodemask();
 	gnodes = numa_allocate_nodemask();
@@ -80,6 +83,9 @@ int main(int ac, char **av)
 		case 'r':
 			repeat = atoi(av[1] + 2);
 			break;
+		case 'H':
+			disable_hugepage = true;
+			break;
 		default:	
 			usage();
 		}
@@ -113,6 +119,9 @@ int main(int ac, char **av)
 	
 	if (mbind(map, length, policy, nodes->maskp, nodes->size, 0) < 0)
 		terr("mbind");
+
+	if (disable_hugepage)
+		madvise(map, length, MADV_NOHUGEPAGE);
 	
 	gpolicy = -1;
 	if (get_mempolicy(&gpolicy, gnodes->maskp, gnodes->size, map, MPOL_F_ADDR) < 0)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux