selftests/resctrl: Don't use ctrlc_handler() outside signal handling
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 15 Dec 2023 15:04:49 +0000 (17:04 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 13 Feb 2024 20:56:43 +0000 (13:56 -0700)
perf_event_open_llc_miss() calls ctrlc_handler() to cleanup if
perf_event_open() returns an error. Those cleanups, however, are not
the responsibility of perf_event_open_llc_miss() and it thus interferes
unnecessarily with the usual cleanup pattern. Worse yet,
ctrlc_handler() calls exit() in the end preventing the ordinary cleanup
done in the calling function from executing.

ctrlc_handler() should only be used as a signal handler, not during
normal error handling.

Remove call to ctrlc_handler() from perf_event_open_llc_miss(). As
unmounting resctrlfs and test cleanup are already handled properly
by error rollbacks in the calling functions, no other changes are
necessary.

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/cache.c

index 1fa4b86e1459b1e807a562c8340d470cc18fddce..6d60a2f1b3aa9fc65cb98265e955fa68c1bb3884 100644 (file)
@@ -41,7 +41,6 @@ static int perf_event_open_llc_miss(pid_t pid, int cpu_no)
                                PERF_FLAG_FD_CLOEXEC);
        if (fd_lm == -1) {
                ksft_perror("Error opening leader");
-               ctrlc_handler(0, NULL, NULL);
                return -1;
        }