From: Steven Rostedt <rostedt@goodmis.org>
To: Samuel Moelius <sam.moelius@trailofbits.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org (open list:TRACING),
linux-trace-kernel@vger.kernel.org (open list:TRACING)
Subject: Re: [PATCH] tracing: reject invalid preemptirq_delay_test CPU affinity
Date: Tue, 9 Jun 2026 18:16:17 -0400 [thread overview]
Message-ID: <20260609181617.185f1e02@fedora> (raw)
In-Reply-To: <20260605004006.2041148-1-sam.moelius@trailofbits.com>
On Fri, 5 Jun 2026 00:40:06 +0000
Samuel Moelius <sam.moelius@trailofbits.com> wrote:
> preemptirq_delay_test accepts cpu_affinity as a module parameter and,
> when it is non-negative, writes that CPU directly into a temporary
> cpumask from the worker thread. Values outside nr_cpu_ids can set a
> bit outside the allocated cpumask before the test reports a normal
> affinity error.
>
> Validate the requested CPU before starting the worker thread, and
> return -EINVAL for invalid affinity requests.
>
> Assisted-by: Codex:gpt-5.5-cyber-preview
> Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
> ---
> kernel/trace/preemptirq_delay_test.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
> index acb0c971a408..0f017799754a 100644
> --- a/kernel/trace/preemptirq_delay_test.c
> +++ b/kernel/trace/preemptirq_delay_test.c
> @@ -14,6 +14,7 @@
> #include <linux/kthread.h>
> #include <linux/module.h>
> #include <linux/printk.h>
> +#include <linux/cpumask.h>
> #include <linux/string.h>
> #include <linux/sysfs.h>
> #include <linux/completion.h>
> @@ -152,6 +153,15 @@ static int preemptirq_run_test(void)
> struct task_struct *task;
> char task_name[50];
>
> + if (cpu_affinity > -1) {
> + unsigned int cpu = cpu_affinity;
> +
> + if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) {
> + pr_err("cpu_affinity:%d, invalid CPU\n", cpu_affinity);
> + return -EINVAL;
Just add the check to the preemptirq_delay_run() function where it
tests affinity. Who cares if it created the thread or not. It's just a
test.
-- Steve
> + }
> + }
> +
> init_completion(&done);
>
> snprintf(task_name, sizeof(task_name), "%s_test", test_mode);
prev parent reply other threads:[~2026-06-09 22:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 0:40 [PATCH] tracing: reject invalid preemptirq_delay_test CPU affinity Samuel Moelius
2026-06-09 22:16 ` 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=20260609181617.185f1e02@fedora \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=sam.moelius@trailofbits.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.