diff mbox series

[v2,01/26] selftests/resctrl: Don't use ctrlc_handler() outside signal handling

Message ID 20231120111340.7805-2-ilpo.jarvinen@linux.intel.com (mailing list archive)
State New
Headers show
Series selftests/resctrl: CAT test improvements & generalized test framework | expand

Commit Message

Ilpo Järvinen Nov. 20, 2023, 11:13 a.m. UTC
perf_event_open_llc_miss() calls ctrlc_handler() to cleanup if
perf_event_open() returns an error. Those cleanups, however, are not
the responsability 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>
---
 tools/testing/selftests/resctrl/cache.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Reinette Chatre Nov. 28, 2023, 10:09 p.m. UTC | #1
Hi Ilpo,

On 11/20/2023 3:13 AM, Ilpo Järvinen wrote:
> perf_event_open_llc_miss() calls ctrlc_handler() to cleanup if
> perf_event_open() returns an error. Those cleanups, however, are not
> the responsability of perf_event_open_llc_miss() and it thus interferes

responsibility

> 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>

Reinette
diff mbox series

Patch

diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c
index bcbca356d56a..8aa6d67db978 100644
--- a/tools/testing/selftests/resctrl/cache.c
+++ b/tools/testing/selftests/resctrl/cache.c
@@ -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) {
 		perror("Error opening leader");
-		ctrlc_handler(0, NULL, NULL);
 		return -1;
 	}