linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Song Chen <chensong_2000@189.cn>,
	Joel Fernandes <joel@joelfernandes.org>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
	linux-rt-users@vger.kernel.org
Subject: Re: [PATCH] kernel: trace: preemptirq_delay_test: add cpu affinity
Date: Fri, 29 Jan 2021 17:22:20 -0500	[thread overview]
Message-ID: <20210129172220.5e9c87f4@gandalf.local.home> (raw)
In-Reply-To: <1611797713-20965-1-git-send-email-chensong_2000@189.cn>

Joel,

Can you ack this patch?

-- Steve


On Thu, 28 Jan 2021 09:35:13 +0800
Song Chen <chensong_2000@189.cn> wrote:

> The kernel thread executing test can run on any cpu, which might be
> different cpu latency tracer is running on, as a result, the
> big latency caused by preemptirq delay test can't be detected.
> 
> Therefore, the argument cpu_affinity is added to be passed to test,
> ensure it's running on the same cpu with latency tracer.
> 
> e.g.
> cyclictest -p 90 -m -c 0 -i 1000 -a 3
> modprobe preemptirq_delay_test test_mode=preempt delay=500 \
> burst_size=3 cpu_affinity=3
> 
> Signed-off-by: Song Chen <chensong_2000@189.cn>
> ---
>  kernel/trace/Kconfig                 |  4 ++++
>  kernel/trace/preemptirq_delay_test.c | 14 ++++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
> index c1a62ae..44dd5c0 100644
> --- a/kernel/trace/Kconfig
> +++ b/kernel/trace/Kconfig
> @@ -886,6 +886,10 @@ config PREEMPTIRQ_DELAY_TEST
>  	  irq-disabled critical sections for 500us:
>  	  modprobe preemptirq_delay_test test_mode=irq delay=500 burst_size=3
>  
> +	  What's more, if you want to attach the test on the cpu which the latency
> +	  tracer is running on, specify cpu_affinity=cpu_num at the end of the
> +	  command.
> +
>  	  If unsure, say N
>  
>  config SYNTH_EVENT_GEN_TEST
> diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
> index 312d1a0..8c4ffd0 100644
> --- a/kernel/trace/preemptirq_delay_test.c
> +++ b/kernel/trace/preemptirq_delay_test.c
> @@ -21,13 +21,16 @@
>  static ulong delay = 100;
>  static char test_mode[12] = "irq";
>  static uint burst_size = 1;
> +static int  cpu_affinity = -1;
>  
>  module_param_named(delay, delay, ulong, 0444);
>  module_param_string(test_mode, test_mode, 12, 0444);
>  module_param_named(burst_size, burst_size, uint, 0444);
> +module_param_named(cpu_affinity, cpu_affinity, int, 0444);
>  MODULE_PARM_DESC(delay, "Period in microseconds (100 us default)");
>  MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt, irq, or alternate (default irq)");
>  MODULE_PARM_DESC(burst_size, "The size of a burst (default 1)");
> +MODULE_PARM_DESC(cpu_affinity, "Cpu num test is running on");
>  
>  static struct completion done;
>  
> @@ -36,7 +39,9 @@ static struct completion done;
>  static void busy_wait(ulong time)
>  {
>  	u64 start, end;
> +
>  	start = trace_clock_local();
> +
>  	do {
>  		end = trace_clock_local();
>  		if (kthread_should_stop())
> @@ -47,6 +52,7 @@ static void busy_wait(ulong time)
>  static __always_inline void irqoff_test(void)
>  {
>  	unsigned long flags;
> +
>  	local_irq_save(flags);
>  	busy_wait(delay);
>  	local_irq_restore(flags);
> @@ -113,6 +119,14 @@ static int preemptirq_delay_run(void *data)
>  {
>  	int i;
>  	int s = MIN(burst_size, NR_TEST_FUNCS);
> +	struct cpumask cpu_mask;
> +
> +	if (cpu_affinity > -1) {
> +		cpumask_clear(&cpu_mask);
> +		cpumask_set_cpu(cpu_affinity, &cpu_mask);
> +		if (set_cpus_allowed_ptr(current, &cpu_mask))
> +			pr_err("cpu_affinity:%d, failed\n", cpu_affinity);
> +	}
>  
>  	for (i = 0; i < s; i++)
>  		(testfuncs[i])(i);


      reply	other threads:[~2021-01-29 22:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28  1:35 [PATCH] kernel: trace: preemptirq_delay_test: add cpu affinity Song Chen
2021-01-29 22:22 ` Steven Rostedt [this message]

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=20210129172220.5e9c87f4@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=chensong_2000@189.cn \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).