From: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
To: Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Shuah Khan <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
tan.shaopeng@jp.fujitsu.com
Subject: [PATCH v9 4/6] selftests/resctrl: Cleanup properly when an error occurs in CAT test
Date: Thu, 13 Apr 2023 16:22:57 +0900 [thread overview]
Message-ID: <20230413072259.2089348-5-tan.shaopeng@jp.fujitsu.com> (raw)
In-Reply-To: <20230413072259.2089348-1-tan.shaopeng@jp.fujitsu.com>
After creating a child process with fork() in CAT test, if an error
occurs when parent process runs cat_val() or check_results(), the child
process will not be killed and also resctrlfs is not unmounted. Also if
an error occurs when child process runs cat_val() or check_results(),
the parent process will wait for the pipe message from the child process
which will never be sent by the child process and the parent process
cannot proceed to unmount resctrlfs.
Synchronize the exits between the parent and child. An error could
occur whether in parent process or child process. The parent process
always kills the child process and runs umount_resctrlfs(). The
child process always waits to be killed by the parent process.
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
tools/testing/selftests/resctrl/cat_test.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index 38c10a8c1814..0880575840f9 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -186,23 +186,20 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
remove(param.filename);
ret = cat_val(¶m);
- if (ret)
- return ret;
-
- ret = check_results(¶m);
- if (ret)
- return ret;
+ if (ret == 0)
+ ret = check_results(¶m);
if (bm_pid == 0) {
/* Tell parent that child is ready */
close(pipefd[0]);
pipe_message = 1;
if (write(pipefd[1], &pipe_message, sizeof(pipe_message)) <
- sizeof(pipe_message)) {
- close(pipefd[1]);
+ sizeof(pipe_message))
+ /*
+ * Just print the error message.
+ * Let while(1) run and wait for itself to be killed.
+ */
perror("# failed signaling parent process");
- return errno;
- }
close(pipefd[1]);
while (1)
@@ -226,5 +223,5 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
if (bm_pid)
umount_resctrlfs();
- return 0;
+ return ret;
}
--
2.27.0
next prev parent reply other threads:[~2023-04-13 7:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 7:22 [PATCH v9 0/6] Some improvements of resctrl selftest Shaopeng Tan
2023-04-13 7:22 ` [PATCH v9 1/6] selftests/resctrl: Fix set up schemata with 100% allocation on first run in MBM test Shaopeng Tan
2023-04-14 12:31 ` Ilpo Järvinen
2023-04-14 15:24 ` Reinette Chatre
2023-04-13 7:22 ` [PATCH v9 2/6] selftests/resctrl: Return MBA check result and make it to output message Shaopeng Tan
2023-04-13 7:22 ` [PATCH v9 3/6] selftests/resctrl: Flush stdout file buffer before executing fork() Shaopeng Tan
2023-04-13 7:22 ` Shaopeng Tan [this message]
2023-04-13 7:22 ` [PATCH v9 5/6] selftests/resctrl: Commonize the signal handler register/unregister for all tests Shaopeng Tan
2023-04-13 7:22 ` [PATCH v9 6/6] selftests/resctrl: Remove duplicate codes that clear each test result file Shaopeng Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230413072259.2089348-5-tan.shaopeng@jp.fujitsu.com \
--to=tan.shaopeng@jp.fujitsu.com \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox