From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56718 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8DQC-0002Px-FD for qemu-devel@nongnu.org; Tue, 19 Oct 2010 10:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8DQA-0000LB-MV for qemu-devel@nongnu.org; Tue, 19 Oct 2010 10:44:11 -0400 Received: from mtagate1.de.ibm.com ([195.212.17.161]:35101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8DQA-0000Kn-EH for qemu-devel@nongnu.org; Tue, 19 Oct 2010 10:44:10 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.1/8.13.1) with ESMTP id o9JEi8oF019384 for ; Tue, 19 Oct 2010 14:44:08 GMT Received: from d12av03.megacenter.de.ibm.com (d12av03.megacenter.de.ibm.com [9.149.165.213]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9JEi8Jq4104408 for ; Tue, 19 Oct 2010 16:44:08 +0200 Received: from d12av03.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o9JEi8ic029421 for ; Tue, 19 Oct 2010 16:44:08 +0200 Date: Tue, 19 Oct 2010 15:44:07 +0100 From: Stefan Hajnoczi Subject: Re: Tracing block devices (was: Re: [Qemu-devel] Static tracepoint control via trace-event) Message-ID: <20101019144407.GC11309@stefan-thinkpad.transitives.com> References: <4CBD9838.6040004@siemens.com> <20101019133659.GH23535@redhat.com> <4CBDA448.1040108@siemens.com> <20101019142951.GB32682@amd.home.annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101019142951.GB32682@amd.home.annexia.org> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: Jan Kiszka , qemu-devel , Stefan Hajnoczi 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 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