From: Dave Chinner <david@fromorbit.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Christoph Hellwig <hch@infradead.org>,
Eric Sandeen <sandeen@sandeen.net>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 2/2] xfs: Nuke XFS_ERROR macro
Date: Thu, 17 Apr 2014 10:39:56 +1000 [thread overview]
Message-ID: <20140417003956.GS15995@dastard> (raw)
In-Reply-To: <20140416194444.50176f0f@gandalf.local.home>
On Wed, Apr 16, 2014 at 07:44:44PM -0400, Steven Rostedt wrote:
> On Thu, 17 Apr 2014 08:08:08 +1000
> Dave Chinner <david@fromorbit.com> wrote:
>
>
> > > Here's the "best" I've come up with so far...
> > >
> > > # for FUNCTION in `grep "t xfs_" /proc/kallsyms | awk '{print $3}'`; do echo "r:ret_$FUNCTION $FUNCTION \$retval" >> /sys/kernel/debug/tracing/kprobe_events; done
>
> BTW, it's usually better to do:
>
> grep 't xfs_' /proc/kallsyms | awk '{print $3}' ; while read FUNCTION; do ....
grep -i 't xfs' .....
> > > # for ENABLE in /sys/kernel/debug/tracing/events/kprobes/ret_xfs_*/enable; do echo 1 > $ENABLE; done
> > >
> > > run a test that fails:
> > >
> > > # dd if=/dev/zero of=newfile bs=513 oflag=direct
> > > dd: writing `newfile': Invalid argument
> > >
> > > # for ENABLE in /sys/kernel/debug/tracing/events/kprobes/ret_xfs_*/enable; do echo 0 > $ENABLE; done
> > >
> > > # cat /sys/kernel/debug/tracing/trace
> > > <snip>
> > > <...>-63791 [000] d... 705435.568913: ret_xfs_vn_mknod: (xfs_vn_create+0x13/0x20 [xfs] <- xfs_vn_mknod) arg1=0
> > > <...>-63791 [000] d... 705435.568913: ret_xfs_vn_create: (vfs_create+0xdb/0x100 <- xfs_vn_create) arg1=0
> > > <...>-63791 [000] d... 705435.568918: ret_xfs_file_open: (do_dentry_open+0x24e/0x2e0 <- xfs_file_open) arg1=0
> > > <...>-63791 [000] d... 705435.568934: ret_xfs_file_dio_aio_write: (xfs_file_aio_write+0x147/0x150 [xfs] <- xfs_file_dio_aio_write) arg1=ffffffffffffffea
> > >
> > > Hey look, it's "-22" in hex! ;)
> > >
> > > so it's possible, but bleah.
> >
> > Steve, we want to be able to trap specific return codes from
> > functions. Say, for example, the first function that returns
> > EINVAL/-EINVAL in XFS under a given workload.
> >
> > What's the most efficient way to do that with ftrace?
> >
> > And can that be set up as a trigger so we can use it to dump a
> > snapshot of the last N events into the trace buffer or do other
> > interesting things with that event?
>
> Well, after you do the above, you could also do a while loop to all
> those events and update the filter:
>
> echo 'arg1 > 0xffffffffffffff00' > /debug/tracing/events/kprobes/filter
>
> Which would trace only those functions that had an error code (assuming
> the error code is less than 256). You could also use the trigger files:
>
> echo 'traceoff if arg1 > 0xffffffffffffff00' > /debug/tracing/events/kprobes/*/trigger
>
> The above wont actually work as is, you would need to do another while
> loop of trigger files and set them each individually.
so, basically a script that does:
#!/bin/bash
TRACEDIR=/sys/kernel/debug/tracing
grep -i 't xfs_' /proc/kallsyms | awk '{print $3}' ; while read F; do
echo "r:ret_$F $F \$retval" >> $TRACEDIR/kprobe_events
done
for E in $TRACEDIR/events/kprobes/ret_xfs_*/enable; do
echo 1 > $E
done;
echo 'arg1 > 0xffffffffffffff00' > $TRACEDIR/events/kprobes/filter
for T in $TRACEDIR/events/kprobes/ret_xfs_*/trigger; do
echo 'traceoff if arg1 > 0xffffffffffffff00' > $T
done
And that gives:
# dd if=/dev/zero of=/mnt/scratch/newfile bs=513 oflag=direct
dd: error writing ¿/mnt/scratch/newfile¿: Invalid argument
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000259882 s, 0.0 kB/s
root@test4:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 1/1 #P:16
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
<...>-8073 [006] d... 145740.460546: ret_xfs_file_dio_aio_write: (xfs_file_aio_write+0x170/0x180 <- xfs_file_dio_aio_write) arg1=0xffffffffffffffea
Which is precisely the detection that XFS_ERROR would have given us.
Ok, so I guess we can now add whatever need need to that trigger...
Basically, pass in teh XFs function names you want to trace, the
sets up teh events, whatever trigger beahviour you want, and
we're off to the races...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-04-17 0:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 17:40 [PATCH 0/2] xfs: clean up return handling Eric Sandeen
2014-04-16 17:44 ` [PATCH 1/2] xfs: return is not a function Eric Sandeen
2014-04-21 6:58 ` Christoph Hellwig
2014-04-16 17:48 ` [PATCH 2/2] xfs: Nuke XFS_ERROR macro Eric Sandeen
2014-04-16 17:51 ` Christoph Hellwig
2014-04-16 17:55 ` Eric Sandeen
2014-04-16 19:11 ` Eric Sandeen
2014-04-16 22:08 ` Dave Chinner
2014-04-16 23:44 ` Steven Rostedt
2014-04-17 0:39 ` Dave Chinner [this message]
2014-04-17 0:49 ` Dave Chinner
2014-04-21 6:57 ` Christoph Hellwig
2014-04-21 23:43 ` Dave Chinner
2014-04-16 22:28 ` Dave Chinner
2014-04-22 21:38 ` 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=20140417003956.GS15995@dastard \
--to=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.sgi.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