[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220914015147.3071025-6-tan.shaopeng@jp.fujitsu.com>
Date: Wed, 14 Sep 2022 10:51:46 +0900
From: Shaopeng Tan <tan.shaopeng@...fujitsu.com>
To: Fenghua Yu <fenghua.yu@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Shuah Khan <shuah@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
tan.shaopeng@...fujitsu.com
Subject: [PATCH 4/5] selftests/resctrl: Kill the child process before exiting the parent process if an exception occurs
After creating a child process with fork() in CAT test, if there is
an exception occurs, the parent process will be terminated immediately,
but the child process will not be killed and umount_resctrlfs() will not
be called.
When fork() is used in CMT/MBA/MBM tests.
If an exception occurs, before parent process exiting,
the child process is killed and umount_resctrlfs() is called.
Kill the child process before exiting the parent process
if an exception occurs in CAT test, like in CMT/MBA/MBM tests.
Signed-off-by: Shaopeng Tan <tan.shaopeng@...fujitsu.com>
---
tools/testing/selftests/resctrl/cat_test.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index d1134f66469f..f62da445acbb 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -186,11 +186,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
ret = cat_val(¶m);
if (ret)
- return ret;
+ goto out;
ret = check_results(¶m);
if (ret)
- return ret;
+ goto out;
if (bm_pid == 0) {
/* Tell parent that child is ready */
@@ -200,7 +200,8 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
sizeof(pipe_message)) {
close(pipefd[1]);
perror("# failed signaling parent process");
- return errno;
+ ret = errno;
+ goto out;
}
close(pipefd[1]);
@@ -218,11 +219,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
}
}
close(pipefd[0]);
- kill(bm_pid, SIGKILL);
}
- if (bm_pid)
- umount_resctrlfs();
+out:
+ kill(bm_pid, SIGKILL);
+ umount_resctrlfs();
- return 0;
+ return ret;
}
--
2.27.0
Powered by blists - more mailing lists