Re: [PATCH 2/2] tracing/selftests: Add reading all instance files to instance test

From: Masami Hiramatsu (Google)

Date: Thu Oct 29 2026 - 21:24:45 EST


On Thu, 29 Oct 2026 16:28:51 -0400, Steven Rostedt <rostedt@xxxxxxxxxx> wrote:
> From: Steven Rostedt <rostedt@xxxxxxxxxxx>
>
> Commit f4a771cc684c7 ("tracing: Have show_event_filters/triggers files take
> trace array ref") fixed a bug where the show_event_filters and triggers
> did not take a trace array reference allowing an instance to be removed
> while active. This would have the reader of these files read data that was
> freed by the remove.
>
> Update the instance test to read all the files in the instance,
> instance/events, instance/events/sched and
> instance/events/sched/sched_switch directories (with the exception of not
> reading trace or trace_pipe). This would hopefully catch issues with files
> not taking references.
>
> Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

Looks good to me.

Reviewed-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

Thanks,


> ---
> .../ftrace/test.d/instances/instance-event.tc | 20 ++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
> index b0e9d3abbf2f..9374c20c6aaa 100644
> --- a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
> +++ b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
> @@ -44,6 +44,19 @@ instance_set() {
> done 2> /dev/null
> }
>
> +instance_cat() {
> + while :; do
> + find instances/foo -maxdepth 1 -type f ! \( -name trace -o -name trace_pipe \) -exec head {} \;
> + sleep 0.1
> + find instances/foo/events -maxdepth 1 -type f -exec cat {} \;
> + sleep 0.1
> + find instances/foo/events/sched -maxdepth 1 -type f -exec cat {} \;
> + sleep 0.1
> + find instances/foo/events/sched/sched_waking -maxdepth 1 -type f -exec cat {} \;
> + sleep 0.1
> + done 2> /dev/null
> +}
> +
> instance_set &
> p1=$!
> echo $p1
> @@ -52,15 +65,20 @@ instance_read &
> p2=$!
> echo $p2
>
> +instance_cat &
> +p3=$!
> +echo $p3
> +
> for i in `seq 10`; do
> instance_slam
> done
>
> +kill -1 $p3
> kill -1 $p2
> kill -1 $p1
>
> echo "Wait for processes to finish"
> -wait $p1 $p2
> +wait $p1 $p2 $p3
> echo "all processes finished, wait for cleanup"
> sleep 1
>
> --
> 2.53.0
>

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>