Blame SOURCES/0002-tests-slbpacaflush-Use-online-cpus-only.patch

fc9b0e
From 865d160eff7e6c69968d0196272030f206dd3430 Mon Sep 17 00:00:00 2001
fc9b0e
Message-Id: <865d160eff7e6c69968d0196272030f206dd3430.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: Thu, 15 Aug 2019 13:08:29 +0530
fc9b0e
Subject: [RHEL7 PATCH 02/31] tests: slbpacaflush: Use online cpus only
fc9b0e
fc9b0e
This ensures that the two cpus between which the thread is
fc9b0e
migrated are online. For offline cpus, sched_setaffinity()
fc9b0e
will always fail.
fc9b0e
fc9b0e
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
fc9b0e
Signed-off-by: Eric B Munson <emunson@mgebm.net>
fc9b0e
Signed-off-by: Rafael Aquini <aquini@redhat.com>
fc9b0e
---
fc9b0e
 tests/slbpacaflush.c | 16 ++++++++++------
fc9b0e
 1 file changed, 10 insertions(+), 6 deletions(-)
fc9b0e
fc9b0e
diff --git a/tests/slbpacaflush.c b/tests/slbpacaflush.c
fc9b0e
index 8893c4d..765e069 100644
fc9b0e
--- a/tests/slbpacaflush.c
fc9b0e
+++ b/tests/slbpacaflush.c
fc9b0e
@@ -57,29 +57,32 @@ int main(int argc, char *argv[])
fc9b0e
 	int fd;
fc9b0e
 	void *p;
fc9b0e
 	volatile unsigned long *q;
fc9b0e
-	int err;
fc9b0e
+	int online_cpus[2], err;
fc9b0e
 	cpu_set_t cpu0, cpu1;
fc9b0e
 
fc9b0e
 	test_init(argc, argv);
fc9b0e
 
fc9b0e
 	hpage_size = check_hugepagesize();
fc9b0e
+	check_online_cpus(online_cpus, 2);
fc9b0e
 
fc9b0e
 	fd = hugetlbfs_unlinked_fd();
fc9b0e
 	if (fd < 0)
fc9b0e
 		FAIL("hugetlbfs_unlinked_fd()");
fc9b0e
 
fc9b0e
 	CPU_ZERO(&cpu0);
fc9b0e
-	CPU_SET(0, &cpu0);
fc9b0e
+	CPU_SET(online_cpus[0], &cpu0);
fc9b0e
 	CPU_ZERO(&cpu1);
fc9b0e
-	CPU_SET(1, &cpu1);
fc9b0e
+	CPU_SET(online_cpus[1], &cpu1);
fc9b0e
 
fc9b0e
 	err = sched_setaffinity(getpid(), CPU_SETSIZE/8, &cpu0);
fc9b0e
 	if (err != 0)
fc9b0e
-		CONFIG("sched_setaffinity(cpu0): %s", strerror(errno));
fc9b0e
+		CONFIG("sched_setaffinity(cpu%d): %s", online_cpus[0],
fc9b0e
+				strerror(errno));
fc9b0e
 
fc9b0e
 	err = sched_setaffinity(getpid(), CPU_SETSIZE/8, &cpu1);
fc9b0e
 	if (err != 0)
fc9b0e
-		CONFIG("sched_setaffinity(): %s", strerror(errno));
fc9b0e
+		CONFIG("sched_setaffinity(cpu%d): %s", online_cpus[1],
fc9b0e
+				strerror(errno));
fc9b0e
 
fc9b0e
 	p = mmap(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
fc9b0e
 	if (p == MAP_FAILED)
fc9b0e
@@ -87,7 +90,8 @@ int main(int argc, char *argv[])
fc9b0e
 
fc9b0e
 	err = sched_setaffinity(getpid(), CPU_SETSIZE/8, &cpu0);
fc9b0e
 	if (err != 0)
fc9b0e
-		CONFIG("sched_setaffinity(cpu0): %s", strerror(errno));
fc9b0e
+		CONFIG("sched_setaffinity(cpu%d): %s", online_cpus[0],
fc9b0e
+				strerror(errno));
fc9b0e
 
fc9b0e
 	q = (volatile unsigned long *)(p + getpagesize());
fc9b0e
 	*q = 0xdeadbeef;
fc9b0e
-- 
fc9b0e
1.8.3.1
fc9b0e