Blame SOURCES/0003-tests-alloc-instantiate-race-Use-online-cpus-only.patch

fc9b0e
From 4ba9722027d9aeec173866b5ca12282268594f35 Mon Sep 17 00:00:00 2001
fc9b0e
Message-Id: <4ba9722027d9aeec173866b5ca12282268594f35.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:30 +0530
fc9b0e
Subject: [RHEL7 PATCH 03/31] tests: alloc-instantiate-race: Use online cpus
fc9b0e
 only
fc9b0e
fc9b0e
This ensures that the two processes or threads between which
fc9b0e
the race condition is introduced are always running on online
fc9b0e
cpus. For offline cpus, sched_setaffinity() 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/alloc-instantiate-race.c | 12 +++++++-----
fc9b0e
 1 file changed, 7 insertions(+), 5 deletions(-)
fc9b0e
fc9b0e
diff --git a/tests/alloc-instantiate-race.c b/tests/alloc-instantiate-race.c
fc9b0e
index 7f84e8a..f55e2f7 100644
fc9b0e
--- a/tests/alloc-instantiate-race.c
fc9b0e
+++ b/tests/alloc-instantiate-race.c
fc9b0e
@@ -121,7 +121,9 @@ static void run_race(void *syncarea, int race_type)
fc9b0e
 	int fd;
fc9b0e
 	void *p;
fc9b0e
 	int status1, status2;
fc9b0e
-	int ret;
fc9b0e
+	int online_cpus[2], ret;
fc9b0e
+
fc9b0e
+	check_online_cpus(online_cpus, 2);
fc9b0e
 
fc9b0e
 	memset(syncarea, 0, sizeof(*trigger1) + sizeof(*trigger2));
fc9b0e
 	trigger1 = syncarea;
fc9b0e
@@ -143,13 +145,13 @@ static void run_race(void *syncarea, int race_type)
fc9b0e
 		if (child1 < 0)
fc9b0e
 			FAIL("fork(): %s", strerror(errno));
fc9b0e
 		if (child1 == 0)
fc9b0e
-			proc_racer(p, 0, trigger1, trigger2);
fc9b0e
+			proc_racer(p, online_cpus[0], trigger1, trigger2);
fc9b0e
 
fc9b0e
 		child2 = fork();
fc9b0e
 		if (child2 < 0)
fc9b0e
 			FAIL("fork(): %s", strerror(errno));
fc9b0e
 		if (child2 == 0)
fc9b0e
-			proc_racer(p, 1, trigger2, trigger1);
fc9b0e
+			proc_racer(p, online_cpus[1], trigger2, trigger1);
fc9b0e
 
fc9b0e
 		/* wait() calls */
fc9b0e
 		ret = waitpid(child1, &status1, 0);
fc9b0e
@@ -175,13 +177,13 @@ static void run_race(void *syncarea, int race_type)
fc9b0e
 	} else {
fc9b0e
 		struct racer_info ri1 = {
fc9b0e
 			.p = p,
fc9b0e
-			.cpu = 0,
fc9b0e
+			.cpu = online_cpus[0],
fc9b0e
 			.mytrigger = trigger1,
fc9b0e
 			.othertrigger = trigger2,
fc9b0e
 		};
fc9b0e
 		struct racer_info ri2 = {
fc9b0e
 			.p = p,
fc9b0e
-			.cpu = 1,
fc9b0e
+			.cpu = online_cpus[1],
fc9b0e
 			.mytrigger = trigger2,
fc9b0e
 			.othertrigger = trigger1,
fc9b0e
 		};
fc9b0e
-- 
fc9b0e
1.8.3.1
fc9b0e