public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Qu Wenruo <wqu@suse.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH v2] fstests: add basic ftrace support
Date: Fri, 4 Jun 2021 12:35:47 +1000	[thread overview]
Message-ID: <20210604023547.GA2068689@dread.disaster.area> (raw)
In-Reply-To: <20210603062113.133326-1-wqu@suse.com>

On Thu, Jun 03, 2021 at 02:21:13PM +0800, Qu Wenruo wrote:
> Sometimes developers want trace dump for certain test cases.
> 
> Normally I just add "trace-cmd" calls in "check", but it would be much
> better to let fstests to support ftrace dumping.
> 
> This patchset will add basic ftrace dumping support by:
> 
> - Clear all buffers before running each test
> - Start tracing before running each test
> - End tracing after test finished
> - Copy the trace to "$seqres.trace" if needed
>   The condition is either:
>   * $KEEP_TRACE environment is set to "yes"
>   * The test case failed
> 
> Currently we only support the main ftrace buffer, but all supporting
> functions have support for ftrace instances, for later expansion.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> Changelog:
> v2:
> - Add explanation in "common/config" for how to use it
> - Make variables local
> - Don't create the instance when clearing buffers
> ---
>  check         | 12 +++++++-
>  common/config |  8 +++++
>  common/ftrace | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  common/rc     |  1 +
>  4 files changed, 103 insertions(+), 1 deletion(-)
>  create mode 100644 common/ftrace
> 
> diff --git a/check b/check
> index ba192042..0a09dcf9 100755
> --- a/check
> +++ b/check
> @@ -801,7 +801,7 @@ function run_section()
>  		fi
>  
>  		# really going to try and run this one
> -		rm -f $seqres.out.bad
> +		rm -f $seqres.out.bad $seqres.trace
>  
>  		# check if we really should run it
>  		_expunge_test $seqnum
> @@ -839,6 +839,10 @@ function run_section()
>  		# to be reported for each test
>  		(echo 1 > $DEBUGFS_MNT/clear_warn_once) > /dev/null 2>&1
>  
> +		# Clear previous trace and start new trace
> +		_clear_trace_buffers
> +		_start_trace

So how does one enable all 500+ xfs tracepoints for this? Or just
some subset? i.e. how do we pass it a list of events like we do
trace-cmd?  IOWs, for this to be actually useful as a replacement
for trace-cmd, it has to be able to replace invocations like this:

# trace-cmd record -e xfs_i*lock* -e xfs_buf* -e printk -e iomap* ....

which is how I use trace-cmd 99.9% of the time I'm debugging fstests
using tracepoints.

Next: some tests will generate gigabytes of trace data on XFS. I'm
not joking here - I regularly am looking for single traces in an
output file that contains tens of millions of events in it. Having
fstests run with tracing enabled is going to rapidly cause ENOSPC
problems on test machines, and that's going to cause test harness
issues...

Hence I don't think that unilaterally turning on tracing is a good
idea. I think it should only run if we set a value in the config
section for the test run. This allows a user to define two identical
test sections except one has "ENABLE_TRACE=true" in it and the other
doesn't. Hence they can run:

# check -s xfs -g auto

to get a normal, non-traced run done. Then, for all the failures
reported, run:

# check -s xfs_trace <trace specification> <failed tests>

and get those tests run with tracing enabled instead of running

# trace-cmd record <trace specification> check -s xfs <failed tests>

Finally, I also don't want fstests perturbing whatever tracing I'm
doing externally to fstests, so being having it enable tracing only
when I want it to enable tracing is somewhat important...

> +#                   NOTE: to dump ftrace buffer one needs to enable ftrace
> +#                   events or add custom trace_printk() into the fs code.
> +#                   And since fstest will clear buffer before running one
> +#                   test case, existing trace-cmd can be interrupted.

trace_printk is only a small part of the tracing I use with
trace-cmd. If we can't configure trace event output through this
interface, then it's really not a replacement for using trace-cmd...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2021-06-04  2:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  6:21 [PATCH v2] fstests: add basic ftrace support Qu Wenruo
2021-06-04  2:35 ` Dave Chinner [this message]
2021-06-04  2:45   ` Qu Wenruo
2021-06-04 16:30     ` Darrick J. Wong
2021-06-04 22:44     ` Dave Chinner

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=20210604023547.GA2068689@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox