lkml.org 
[lkml]   [2022]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/5] selftests/resctrl: Kill the child process before exiting the parent process if an exception occurs
Date
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@jp.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(&param);
if (ret)
- return ret;
+ goto out;

ret = check_results(&param);
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
\
 
 \ /
  Last update: 2022-09-14 04:19    [W:0.129 / U:2.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site