FAILED: patch "[PATCH] selftests/resctrl: Extend signal handler coverage to unmount" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 3aff5146445582454c35900f3c0c972987cdd595
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023112321-epic-pamphlet-c600@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
3aff51464455 ("selftests/resctrl: Extend signal handler coverage to unmount on receiving signal") e33cb5702a9f ("selftests/resctrl: Make benchmark command const and build it with pointers") b1a901e078c4 ("selftests/resctrl: Simplify span lifetime")47e36f16c784 ("selftests/resctrl: Remove bw_report and bm_type from main()") 4a28c7665c2a ("selftests/resctrl: Ensure the benchmark commands fits to its array")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3aff5146445582454c35900f3c0c972987cdd595 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= <[email protected]>
Date: Mon, 2 Oct 2023 12:48:08 +0300
Subject: [PATCH] selftests/resctrl: Extend signal handler coverage to unmount
on receiving signal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Unmounting resctrl FS has been moved into the per test functions in resctrl_tests.c by commit caddc0fbe495 ("selftests/resctrl: Move resctrl FS mount/umount to higher level"). In case a signal (SIGINT, SIGTERM, or SIGHUP) is received, the running selftest is aborted by ctrlc_handler() which then unmounts resctrl fs before exiting. The current section between signal_handler_register() and signal_handler_unregister(), however, does not cover the entire duration when resctrl FS is mounted.
Move signal_handler_register() and signal_handler_unregister() calls from per test files into resctrl_tests.c to properly unmount resctrl fs. In order to not add signal_handler_register()/unregister() n times, create helpers test_prepare() and test_cleanup().
Do not call ksft_exit_fail_msg() in test_prepare() but only in the per test function to keep the control flow cleaner without adding calls to exit() deep into the call chain.
Adjust child process kill() call in ctrlc_handler() to only be invoked if the child was already forked.
tools/testing/selftests/resctrl/cat_test.c +0 -8
@@ -167,12 +167,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)strcpy (param.filename,RESULT_FILE_NAME1 ); param.num_of_runs =0 ; param.cpu_no = sibling_cpu_no; - }else { - ret =signal_handler_register (); -if (ret) { -kill (bm_pid,SIGKILL ); - goto out; - } }remove (param.filename);
@@ -209,10 +203,8 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) }close (pipefd[0 ]);kill (bm_pid,SIGKILL ); -signal_handler_unregister (); } -out:cat_test_cleanup ();return ret;
tools/testing/selftests/resctrl/resctrl_tests.c +45 -24
141 lines not on this page · raw message
tools/testing/selftests/resctrl/resctrl_val.c +10 -12
@@ -468,7 +468,9 @@ pid_t bm_pid, ppid;void ctrlc_handler (int signum,siginfo_t *info,void *ptr) { -kill (bm_pid,SIGKILL ); +/* Only kill child after bm_pid is set after fork() */ +if (bm_pid) +kill (bm_pid,SIGKILL );umount_resctrlfs ();tests_cleanup ();ksft_print_msg ("Ending\n\n" );
@@ -485,6 +487,8 @@ int signal_handler_register(void)struct sigaction sigact = {};int ret =0 ; + bm_pid =0 ; + sigact.sa_sigaction = ctrlc_handler;sigemptyset (&sigact.sa_mask); sigact.sa_flags =SA_SIGINFO ;
@@ -706,10 +710,6 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *parksft_print_msg ("Benchmark PID: %d\n" , bm_pid); - ret =signal_handler_register (); -if (ret) - goto out; -/* * The cast removes constness but nothing mutates benchmark_cmd within * the context of this process. At the receiving process, it becomes
@@ -721,19 +721,19 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par/* Taskset benchmark to specified cpu */ ret =taskset_benchmark (bm_pid, param->cpu_no);if (ret) - goto unregister; + goto out;/* Write benchmark to specified control&monitoring grp in resctrl FS */ ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp, resctrl_val);if (ret) - goto unregister; + goto out;if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { ret =initialize_mem_bw_imc ();if (ret) - goto unregister; + goto out;initialize_mem_bw_resctrl (param->ctrlgrp, param->mongrp, param->cpu_no, resctrl_val);
@@ -748,7 +748,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par sizeof(pipe_message)) {perror ("# failed reading message from child process" );close (pipefd[0 ]); - goto unregister; + goto out; } }close (pipefd[0 ]);
@@ -757,7 +757,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *parif (sigqueue (bm_pid,SIGUSR1 , value) ==-1 ) {perror ("# sigqueue SIGUSR1 to child" ); ret = errno; - goto unregister; + goto out; }/* Give benchmark enough time to fully run */
@@ -786,8 +786,6 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par } } -unregister: -signal_handler_unregister (); out:kill (bm_pid,SIGKILL );