Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>, Tom Zanussi <zanussi@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v6 3/3] selftests/tracing: Add hist poll() support test
Date: Thu, 19 Dec 2024 11:04:34 -0500	[thread overview]
Message-ID: <20241219110434.3cb3f47c@gandalf.local.home> (raw)
In-Reply-To: <172907578159.470540.12276069200453397317.stgit@mhiramat.roam.corp.google.com>

On Wed, 16 Oct 2024 19:49:41 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> @@ -0,0 +1,74 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: event trigger - test poll wait on histogram
> +# requires: set_event events/sched/sched_process_free/trigger events/sched/sched_process_free/hist
> +# flags: instance
> +
> +POLL=${FTRACETEST_ROOT}/poll
> +
> +if [ ! -x ${POLL} ]; then
> +  echo "poll program is not compiled!"
> +  exit_unresolved
> +fi
> +
> +EVENT=events/sched/sched_process_free/
> +
> +# Check poll ops is supported. Before implementing poll on hist file, it
> +# returns soon with POLLIN | POLLOUT, but not POLLPRI.
> +
> +# This must wait >1 sec and return 1 (timeout).
> +set +e
> +${POLL} -I -t 1000 ${EVENT}/hist
> +ret=$?
> +set -e
> +if [ ${ret} != 1 ]; then
> +  echo "poll on hist file is not supported"
> +  exit_unsupported
> +fi
> +
> +# Test POLLIN
> +echo > trace
> +echo "hist:key=comm" > ${EVENT}/trigger
> +echo 1 > ${EVENT}/enable
> +
> +# This sleep command will exit after 2 seconds.
> +sleep 2 &
> +BGPID=$!
> +# if timeout happens, poll returns 1.
> +${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
> +
> +if ! grep -qw "sleep" trace; then
> +  echo "poll exits before event happens"

I ran this and it failed here. But it wasn't because the poll failed, it's
because the test is wrong. If something else exits during the test, then
the poll function will exit early.

What the check should do is simply read the hist file, get the hist count,
and make sure it's updated after the poll is run, or at least put a filter
on it:

  echo 'hist:keys=comm if comm =="sleep"' > /sys/kernel/tracing/events/sched/sched_process_free/trigger

Which would work as long as no other "sleep" exits during the test.

-- Steve

> +  exit_fail
> +fi
> +
> +# Test POLLPRI
> +echo > trace
> +echo 1 > tracing_on
> +
> +# This sleep command will exit after 2 seconds.
> +sleep 2 &
> +BGPID=$!
> +# if timeout happens, poll returns 1.
> +${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
> +
> +if ! grep -qw "sleep" trace; then
> +  echo "poll exits before event happens"
> +  exit_fail
> +fi
> +
> +exit_pass


  reply	other threads:[~2024-12-19 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 10:49 [PATCH v6 0/3] tracing: Support poll on event hist file Masami Hiramatsu (Google)
2024-10-16 10:49 ` [PATCH v6 1/3] tracing/hist: Add poll(POLLIN) support on " Masami Hiramatsu (Google)
2024-12-19 16:23   ` Steven Rostedt
2024-12-27  3:04     ` Masami Hiramatsu
2024-10-16 10:49 ` [PATCH v6 2/3] tracing/hist: Support POLLPRI event for poll on histogram Masami Hiramatsu (Google)
2024-12-19 16:25   ` Steven Rostedt
2024-10-16 10:49 ` [PATCH v6 3/3] selftests/tracing: Add hist poll() support test Masami Hiramatsu (Google)
2024-12-19 16:04   ` Steven Rostedt [this message]
2024-12-27  1:30     ` Masami Hiramatsu
2024-10-29  1:03 ` [PATCH v6 0/3] tracing: Support poll on event hist file Masami Hiramatsu

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=20241219110434.3cb3f47c@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=shuah@kernel.org \
    --cc=zanussi@kernel.org \
    /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