All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@gmail.com>
Subject: Re: Tracing block devices (was: Re: [Qemu-devel] Static tracepoint control via trace-event)
Date: Tue, 19 Oct 2010 15:44:07 +0100	[thread overview]
Message-ID: <20101019144407.GC11309@stefan-thinkpad.transitives.com> (raw)
In-Reply-To: <20101019142951.GB32682@amd.home.annexia.org>

On Tue, Oct 19, 2010 at 03:29:51PM +0100, Richard W.M. Jones wrote:
> On Tue, Oct 19, 2010 at 03:59:36PM +0200, Jan Kiszka wrote:
> > Once we have "-trace events=...", defining the list of active
> > tracepoints before starting qemu will be trivial (e.g. via a config
> > file). Of course, this requires that all tracepoints are built-in...
> 
> Sorry that I've not been following this very closely, but does this
> sort of thing allow tracing reads and writes to block devices?  Am I
> right in thinking that if a tracepoint existed in the right place, one
> could get a log file from that which could be post-processed in
> another tool?
> 
> cf:
> http://rwmj.wordpress.com/2010/10/05/visualizing-reads-writes-and-alignment/#content

Definitely, here is the commit that added bdrv_aio_writev/bdrv_aio_readv
tracing.  bdrv_aio_multiwrite has been traced for a while.

http://patchwork.ozlabs.org/patch/66843/

As an example, I use the following script to find all write requests
that touch a given region.  This is very useful for debugging image
corruptions given a trace file:

The usage is:

find_overlapping_io.py <bs> <sector_num> <nb_sectors>

where bs is the block driver state pointer, sector_num is the starting
sector address, and nb_sectors is the number of sectors.

#!/usr/bin/env python
import sys

def trace_filter(fobj, event, keys):
    for line in fobj:
        fields = line.strip().split()
        if fields[0] != event:
            continue

        attrs = dict([(k, v) for k, v in (x.split('=') for x in fields[2:])])
        match = True
        for k, v in keys.iteritems():
            if k not in attrs:
                match = False
                break
            if attrs[k] != v:
                match = False
                break

        if match:
            yield attrs

def intersection(a_sector_num, a_nb_sectors, b_sector_num, b_nb_sectors):
    return not (a_sector_num + a_nb_sectors <= b_sector_num or \
                b_sector_num + b_nb_sectors <= a_sector_num)

bs, sector_num, nb_sectors = sys.argv[1:]
sector_num = int(sector_num, 0)
nb_sectors = int(nb_sectors, 0)

for req in trace_filter(sys.stdin, 'bdrv_aio_writev', {'bs': bs}):
    if intersection(sector_num, nb_sectors, int(req['sector_num'], 0), int(req['nb_sectors'], 0)):
        print req

Stefan

  parent reply	other threads:[~2010-10-19 14:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 13:08 [Qemu-devel] Static tracepoint control via trace-event Jan Kiszka
2010-10-19 13:30 ` [Qemu-devel] " Stefan Hajnoczi
2010-10-19 13:46   ` Jan Kiszka
2010-10-19 14:03     ` Stefan Hajnoczi
2010-10-19 14:12     ` Daniel P. Berrange
2010-10-19 14:30       ` Jan Kiszka
2010-10-19 13:36 ` [Qemu-devel] " Daniel P. Berrange
2010-10-19 13:52   ` Stefan Hajnoczi
2010-10-19 13:59     ` Jan Kiszka
2010-10-19 14:29       ` Tracing block devices (was: Re: [Qemu-devel] Static tracepoint control via trace-event) Richard W.M. Jones
2010-10-19 14:38         ` [Qemu-devel] Re: Tracing block devices Jan Kiszka
2010-10-19 14:44         ` Stefan Hajnoczi [this message]
2010-10-21  5:20         ` Tracing block devices (was: Re: [Qemu-devel] Static tracepoint control via trace-event) Christoph Hellwig
2010-10-21  7:38           ` Richard W.M. Jones
2010-10-21  9:04           ` Stefan Hajnoczi
2010-10-21  8:51         ` Daniel P. Berrange

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=20101019144407.GC11309@stefan-thinkpad.transitives.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=stefanha@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.