mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/tracing: Fix flakiness in trigger-hist-poll.tc by waiting for task exit
@ 2026-07-21  0:20 Masami Hiramatsu (Google)
  2026-10-29 20:34 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-07-21  0:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: oe-lkp, lkp, linux-kernel, Shuah Khan, Masami Hiramatsu,
	linux-trace-kernel, oliver.sang

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Commit c5c413534d40 ("selftests/tracing: Have trigger-hist-poll.tc use
sched_process_exit") changed the target event from sched_process_free to
sched_process_exit to avoid timeouts under CONFIG_RCU_LAZY.

However, sched_process_exit fires inside do_exit() before the exiting task
completes teardown and before the parent shell reaps it. When poll unblocks
upon sched_process_exit, checking whether /proc/${BGPID} exists immediately
after poll returns causes a race condition between poll exiting and the
parent shell reaping the child process.

Fix this by waiting for the background sleep process (wait ${BGPID}) and
removing the fragile /proc/${BGPID} check. Checking whether the event was
logged in the trace buffer already verifies that poll did not exit before
the event occurred.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202607161651.ab0a5bf6-lkp@intel.com
Fixes: c5c413534d40 ("selftests/tracing: Have trigger-hist-poll.tc use sched_process_exit")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 .../ftrace/test.d/trigger/trigger-hist-poll.tc     |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
index 04eb8546fc07..d54d54f9ec77 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
@@ -38,11 +38,7 @@ BGPID=$!
 ${POLL} -I -t 4000 ${EVENT}/hist
 echo 0 > tracing_on
 
-if [ -d /proc/${BGPID} ]; then
-  echo "poll exits too soon"
-  kill -KILL ${BGPID} ||:
-  exit_fail
-fi
+wait ${BGPID} 2>/dev/null ||:
 
 if ! grep -qw "sleep" trace; then
   echo "poll exits before event happens"
@@ -60,11 +56,7 @@ BGPID=$!
 ${POLL} -P -t 4000 ${EVENT}/hist
 echo 0 > tracing_on
 
-if [ -d /proc/${BGPID} ]; then
-  echo "poll exits too soon"
-  kill -KILL ${BGPID} ||:
-  exit_fail
-fi
+wait ${BGPID} 2>/dev/null ||:
 
 if ! grep -qw "sleep" trace; then
   echo "poll exits before event happens"
@@ -72,3 +64,5 @@ if ! grep -qw "sleep" trace; then
 fi
 
 exit_pass
+
+


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/tracing: Fix flakiness in trigger-hist-poll.tc by waiting for task exit
  2026-07-21  0:20 [PATCH] selftests/tracing: Fix flakiness in trigger-hist-poll.tc by waiting for task exit Masami Hiramatsu (Google)
@ 2026-10-29 20:34 ` Steven Rostedt
  2026-10-30  0:52   ` Masami Hiramatsu (Google)
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2026-10-29 20:34 UTC (permalink / raw)
  To: Masami Hiramatsu (Google)
  Cc: oe-lkp, lkp, linux-kernel, Shuah Khan, linux-trace-kernel, oliver.sang

On Tue, 21 Jul 2026 09:20:36 +0900

I'm finally getting around to looking at this!

"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> index 04eb8546fc07..d54d54f9ec77 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> @@ -38,11 +38,7 @@ BGPID=$!
>  ${POLL} -I -t 4000 ${EVENT}/hist
>  echo 0 > tracing_on
>  
> -if [ -d /proc/${BGPID} ]; then
> -  echo "poll exits too soon"
> -  kill -KILL ${BGPID} ||:
> -  exit_fail
> -fi
> +wait ${BGPID} 2>/dev/null ||:
>  
>  if ! grep -qw "sleep" trace; then
>    echo "poll exits before event happens"
> @@ -60,11 +56,7 @@ BGPID=$!
>  ${POLL} -P -t 4000 ${EVENT}/hist
>  echo 0 > tracing_on
>  
> -if [ -d /proc/${BGPID} ]; then
> -  echo "poll exits too soon"
> -  kill -KILL ${BGPID} ||:
> -  exit_fail
> -fi
> +wait ${BGPID} 2>/dev/null ||:
>  
>  if ! grep -qw "sleep" trace; then
>    echo "poll exits before event happens"
> @@ -72,3 +64,5 @@ if ! grep -qw "sleep" trace; then
>  fi
>  
>  exit_pass
> +
> +

Hmm, any reason for the two added newlines here?

-- Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/tracing: Fix flakiness in trigger-hist-poll.tc by waiting for task exit
  2026-10-29 20:34 ` Steven Rostedt
@ 2026-10-30  0:52   ` Masami Hiramatsu (Google)
  0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-10-30  0:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: oe-lkp, lkp, linux-kernel, Shuah Khan, linux-trace-kernel, oliver.sang

On Thu, 29 Oct 2026 16:34:52 -0400, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 21 Jul 2026 09:20:36 +0900
> 
> I'm finally getting around to looking at this!
> 
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> > index 04eb8546fc07..d54d54f9ec77 100644
> > --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> > @@ -38,11 +38,7 @@ BGPID=$!
> >  ${POLL} -I -t 4000 ${EVENT}/hist
> >  echo 0 > tracing_on
> >  
> > -if [ -d /proc/${BGPID} ]; then
> > -  echo "poll exits too soon"
> > -  kill -KILL ${BGPID} ||:
> > -  exit_fail
> > -fi
> > +wait ${BGPID} 2>/dev/null ||:
> >  
> >  if ! grep -qw "sleep" trace; then
> >    echo "poll exits before event happens"
> > @@ -60,11 +56,7 @@ BGPID=$!
> >  ${POLL} -P -t 4000 ${EVENT}/hist
> >  echo 0 > tracing_on
> >  
> > -if [ -d /proc/${BGPID} ]; then
> > -  echo "poll exits too soon"
> > -  kill -KILL ${BGPID} ||:
> > -  exit_fail
> > -fi
> > +wait ${BGPID} 2>/dev/null ||:
> >  
> >  if ! grep -qw "sleep" trace; then
> >    echo "poll exits before event happens"
> > @@ -72,3 +64,5 @@ if ! grep -qw "sleep" trace; then
> >  fi
> >  
> >  exit_pass
> > +
> > +
> 
> Hmm, any reason for the two added newlines here?

Oops, no reason. Maybe typo on the editor...

Thanks,

> 
> -- Steve
>

-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-30  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-21  0:20 [PATCH] selftests/tracing: Fix flakiness in trigger-hist-poll.tc by waiting for task exit Masami Hiramatsu (Google)
2026-10-29 20:34 ` Steven Rostedt
2026-10-30  0:52   ` Masami Hiramatsu (Google)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®