libhugetlbfs/SOURCES/0003-tests-alloc-instantiate-race-Use-online-cpus-only.patch
2021-10-08 12:44:46 +00:00

71 lines
2.3 KiB
Diff

From 4ba9722027d9aeec173866b5ca12282268594f35 Mon Sep 17 00:00:00 2001
Message-Id: <4ba9722027d9aeec173866b5ca12282268594f35.1566225007.git.aquini@redhat.com>
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
From: Sandipan Das <sandipan@linux.ibm.com>
Date: Thu, 15 Aug 2019 13:08:30 +0530
Subject: [RHEL7 PATCH 03/31] tests: alloc-instantiate-race: Use online cpus
only
This ensures that the two processes or threads between which
the race condition is introduced are always running on online
cpus. For offline cpus, sched_setaffinity() will always fail.
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Eric B Munson <emunson@mgebm.net>
Signed-off-by: Rafael Aquini <aquini@redhat.com>
---
tests/alloc-instantiate-race.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/alloc-instantiate-race.c b/tests/alloc-instantiate-race.c
index 7f84e8a..f55e2f7 100644
--- a/tests/alloc-instantiate-race.c
+++ b/tests/alloc-instantiate-race.c
@@ -121,7 +121,9 @@ static void run_race(void *syncarea, int race_type)
int fd;
void *p;
int status1, status2;
- int ret;
+ int online_cpus[2], ret;
+
+ check_online_cpus(online_cpus, 2);
memset(syncarea, 0, sizeof(*trigger1) + sizeof(*trigger2));
trigger1 = syncarea;
@@ -143,13 +145,13 @@ static void run_race(void *syncarea, int race_type)
if (child1 < 0)
FAIL("fork(): %s", strerror(errno));
if (child1 == 0)
- proc_racer(p, 0, trigger1, trigger2);
+ proc_racer(p, online_cpus[0], trigger1, trigger2);
child2 = fork();
if (child2 < 0)
FAIL("fork(): %s", strerror(errno));
if (child2 == 0)
- proc_racer(p, 1, trigger2, trigger1);
+ proc_racer(p, online_cpus[1], trigger2, trigger1);
/* wait() calls */
ret = waitpid(child1, &status1, 0);
@@ -175,13 +177,13 @@ static void run_race(void *syncarea, int race_type)
} else {
struct racer_info ri1 = {
.p = p,
- .cpu = 0,
+ .cpu = online_cpus[0],
.mytrigger = trigger1,
.othertrigger = trigger2,
};
struct racer_info ri2 = {
.p = p,
- .cpu = 1,
+ .cpu = online_cpus[1],
.mytrigger = trigger2,
.othertrigger = trigger1,
};
--
1.8.3.1