Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>,
	 Reinette Chatre <reinette.chatre@intel.com>,
	Shuah Khan <shuah@kernel.org>,
	 LKML <linux-kernel@vger.kernel.org>,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 2/3] selftests/resctrl: Simplify cleanup in ctrl-c handler
Date: Thu, 22 Feb 2024 12:13:50 +0200 (EET)	[thread overview]
Message-ID: <064e7069-9ed7-b7b2-b0e9-3e730cca39ff@linux.intel.com> (raw)
In-Reply-To: <c472e478-eaf1-0003-cf2d-c861e620fce2@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

On Thu, 22 Feb 2024, Ilpo Järvinen wrote:

> On Thu, 22 Feb 2024, Maciej Wieczor-Retman wrote:
> 
> > Ctrl-c handler isn't aware of what test is currently running. Because of
> > that it executes all cleanups even if they aren't necessary. Since the
> > ctrl-c handler uses the sa_sigaction system no parameters can be passed
> > to it as function arguments.
> > 
> > Add a global variable to make ctrl-c handler aware of the currently run
> > test and only execute the correct cleanup callback.
> > 
> > Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> > ---

> > diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> > index 5a49f07a6c85..d572815436f3 100644
> > --- a/tools/testing/selftests/resctrl/resctrl_val.c
> > +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> > @@ -62,6 +62,7 @@ struct imc_counter_config {
> >  static char mbm_total_path[1024];
> >  static int imcs;
> >  static struct imc_counter_config imc_counters_config[MAX_IMCS][2];
> > +const struct resctrl_test *current_test;
> 
> static const struct
> 
> >  void membw_initialize_perf_event_attr(int i, int j)
> >  {
> > @@ -472,7 +473,7 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr)
> >  	if (bm_pid)
> >  		kill(bm_pid, SIGKILL);
> >  	umount_resctrlfs();
> > -	tests_cleanup();
> > +	current_test->cleanup();
> 
> These calls should have if (current_test->cleanup()) guard. Isn't the 

Err, if (current_test->cleanup) is what I meant.

> non-contiguous already test w/o the cleanup function?
> 
> Other than those two, this looked okay.

-- 
 i.

  reply	other threads:[~2024-02-22 10:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 10:04 [PATCH v2 0/3] selftests/resctrl: Simplify test cleanup functions Maciej Wieczor-Retman
2024-02-22 10:04 ` [PATCH v2 1/3] selftests/resctrl: Add cleanup function to test framework Maciej Wieczor-Retman
2024-02-22 10:04 ` [PATCH v2 2/3] selftests/resctrl: Simplify cleanup in ctrl-c handler Maciej Wieczor-Retman
2024-02-22 10:12   ` Ilpo Järvinen
2024-02-22 10:13     ` Ilpo Järvinen [this message]
2024-02-22 10:51     ` Maciej Wieczor-Retman
2024-02-22 10:04 ` [PATCH v2 3/3] selftests/resctrl: Move cleanups out of individual tests Maciej Wieczor-Retman

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=064e7069-9ed7-b7b2-b0e9-3e730cca39ff@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --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