Blame SOURCES/0031-tests-noresv-preserve-resv-page-Fix-failure-in-case-.patch

fc9b0e
From e9482399d7eee7199a4a31fe943c940f52a245ba Mon Sep 17 00:00:00 2001
fc9b0e
Message-Id: <e9482399d7eee7199a4a31fe943c940f52a245ba.1566225007.git.aquini@redhat.com>
fc9b0e
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
From: Sandipan Das <sandipan@linux.ibm.com>
fc9b0e
Date: Mon, 19 Aug 2019 14:48:38 +0530
fc9b0e
Subject: [RHEL7 PATCH 31/31] tests: noresv-preserve-resv-page: Fix failure in
fc9b0e
 case of overcommit
fc9b0e
fc9b0e
This adds an additional check to see if the mapping created
fc9b0e
with MAP_NORESERVE does not raise a SIGBUS upon being written
fc9b0e
to because nr_overcommit_pages is set to a non-zero value and
fc9b0e
surplus pages gets provisioned. In this case, the test should
fc9b0e
pass.
fc9b0e
fc9b0e
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
fc9b0e
Signed-off-by: Eric B Munson <eric@munsonfam.org>
fc9b0e
Signed-off-by: Rafael Aquini <aquini@redhat.com>
fc9b0e
---
fc9b0e
 tests/noresv-preserve-resv-page.c | 8 ++++++++
fc9b0e
 1 file changed, 8 insertions(+)
fc9b0e
fc9b0e
diff --git a/tests/noresv-preserve-resv-page.c b/tests/noresv-preserve-resv-page.c
fc9b0e
index b7b8043..b93bf36 100644
fc9b0e
--- a/tests/noresv-preserve-resv-page.c
fc9b0e
+++ b/tests/noresv-preserve-resv-page.c
fc9b0e
@@ -66,6 +66,7 @@ int main(int argc, char *argv[])
fc9b0e
 {
fc9b0e
 	long hpage_size;
fc9b0e
 	int nr_hugepages;
fc9b0e
+	int surp_hugepages;
fc9b0e
 	int fd1, fd2, err;
fc9b0e
 	char *p, *q;
fc9b0e
 	struct sigaction sa = {
fc9b0e
@@ -104,6 +105,13 @@ int main(int argc, char *argv[])
fc9b0e
 
fc9b0e
 	verbose_printf("Write to %p to steal reserved page\n", q);
fc9b0e
 
fc9b0e
+	surp_hugepages = get_huge_page_counter(hpage_size, HUGEPAGES_SURP);
fc9b0e
 	test_write(q);
fc9b0e
+
fc9b0e
+	/* Provisioning succeeded because of overcommit */
fc9b0e
+	if (get_huge_page_counter(hpage_size, HUGEPAGES_SURP) ==
fc9b0e
+	    surp_hugepages + 1)
fc9b0e
+		PASS();
fc9b0e
+
fc9b0e
 	FAIL("Steal reserved page");
fc9b0e
 }
fc9b0e
-- 
fc9b0e
1.8.3.1
fc9b0e