All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: hu.shengming@zte.com.cn
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: ​[RFC PATCH 2/4] ftrace: Centralize task filter state updates
Date: Sun, 30 Aug 2026 11:24:34 +0000	[thread overview]
Message-ID: <20260830112434.F32E71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830191029780ubpoH6QdASK9mvsfhLTcA@zte.com.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but unregister_trace_sched_switch does not wait for in-flight probes to complete before ftrace_ignore_pid is reset, permanently disabling tracing for a CPU.
--

commit 03992a852b272ad537b862229061fb0d87062720
Author: Shengming Hu <hu.shengming@zte.com.cn>

[RFC PATCH 2/4] ftrace: Centralize task filter state updates

This commit moves probe registration and cache refresh logic into a centralized 
helper ftrace_task_filters_changed() to prepare for task comm filtering. It 
updates shared state when a filter changes and refreshes cached results for 
running tasks when PID filters are cleared.

> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 825d4474876cc..05775047837d2 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c

[ ... ]

> @@ -8677,11 +8687,31 @@ void ftrace_pid_follow_fork(struct trace_array *tr, bool enable)
>  	}
>  }
>  
> +static void ftrace_task_filters_changed(struct trace_array *tr,
> +					bool was_enabled)
> +{
> +	bool enabled = ftrace_task_filters_active(tr);
> +	int cpu;
> +
> +	if (!was_enabled && enabled)
> +		register_trace_sched_switch(ftrace_filter_task_sched_switch_probe, tr);
> +	else if (was_enabled && !enabled) {
> +		unregister_trace_sched_switch(ftrace_filter_task_sched_switch_probe, tr);
> +		for_each_possible_cpu(cpu)
> +			per_cpu_ptr(tr->array_buffer.data, cpu)->ftrace_ignore_pid =
> +				FTRACE_PID_TRACE;
> +		return;
> +	}

[Severity: High]
This is a pre-existing issue, but does unregister_trace_sched_switch wait for 
in-flight probes to complete before ftrace_ignore_pid is reset in the loop 
here?

If a concurrent sched_switch probe evaluates the old PID list and decides to 
ignore a task, while another CPU clears the filters, unregisters the probe, 
and resets ftrace_ignore_pid, we might have a race condition. If the in-flight 
probe writes FTRACE_PID_IGNORE after this reset loop completes, the state 
becomes corrupted and could permanently disable tracing for a CPU.

Can we safely reset ftrace_ignore_pid here without an RCU synchronization 
barrier first?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830190743637MhXoixrAPc1rfm-G8eIcg@zte.com.cn?part=2

  reply	other threads:[~2026-08-30 11:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 11:07 [RFC PATCH 0/4] ftrace: Add task comm filtering for function tracing hu.shengming
2026-08-30 11:09 ` [RFC PATCH 1/4] ftrace: Generalize function task filter names hu.shengming
2026-08-30 11:10 ` ​[RFC PATCH 2/4] ftrace: Centralize task filter state updates hu.shengming
2026-08-30 11:24   ` sashiko-bot [this message]
2026-08-30 11:12 ` [RFC PATCH 3/4] ftrace: Add exact task comm filtering hu.shengming
2026-08-30 11:12 ` [RFC PATCH 4/4] Documentation/ftrace: Document function comm filters hu.shengming
2026-08-30 15:27   ` Randy Dunlap
2026-08-31 10:52     ` hu.shengming
2026-08-31  1:20 ` [RFC PATCH 0/4] ftrace: Add task comm filtering for function tracing Masami Hiramatsu
2026-08-31 10:41   ` hu.shengming
2026-08-31 13:49 ` Steven Rostedt
2026-09-03  1:03   ` hu.shengming

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=20260830112434.F32E71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=hu.shengming@zte.com.cn \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.