From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495033100744993.5391773592893; Wed, 17 May 2017 07:58:20 -0700 (PDT) Received: from localhost ([::1]:49405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0P3-0006mK-1K for importer@patchew.org; Wed, 17 May 2017 10:58:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0J8-0001iz-Jn for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J5-0004eh-QH for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:10 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J5-0004eI-Gy for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:07 -0400 Received: by mail-wr0-x22d.google.com with SMTP id l9so12460518wre.1 for ; Wed, 17 May 2017 07:52:07 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t30sm2385254wrc.24.2017.05.17.07.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 906273E0655; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rcMB9rObBzfaiH0juvPXMmfOxfhZ44tiN81BcEBHgnw=; b=T3rfBvALSU32R2qZxHmU7oACQHK7obgnVz5TGcoKL2p9FXokKie5Yuy/iNJ7s5jHdl MMf0t1q1f7dFabtQep62kHY/hnPH0XeuLRNsFUQLK1X2PyT2GnfduuiQuyengcERX70h D0F+j7v1g0cN5wQKEUp/v4FY5dcr8+GE0sYM8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rcMB9rObBzfaiH0juvPXMmfOxfhZ44tiN81BcEBHgnw=; b=EeB33oAuKEBD2DkaH5ps1WJMIFq8ifS61+YpcMGVwm0z65JsPrBv6T5tvkbW5d+V+R 7dhKVNJf3bricbV6xUwSlf/B1rbXiduiM+7qlc+7PFIeOF68w6vD85JD3zosE2pcxryY cPgLSL/UgkDWMvzKH/XlChrgOhjZFfci16pllpcm1Mwa/cmubSxCSfp/Wtn/FaWhLHuf rK50U7N4LHPAZSomfirg2EM2+Msdq7s6F1pGO5pfrEgiBhaJKIE8NbF4vuNN8RIk2aGc F81lGHhjtrn/42E5553Z5Dv+GS4jYyRBOtsPtpyvLeJDq3XB3SA7ZQR15zzEDTD9IxHn +wmg== X-Gm-Message-State: AODbwcC6t72hvRpWDq16mUydkFR4P6bYGVnsm45ctEczcAz15QXcZrYS Hu0KfvK+oZM6I3Er X-Received: by 10.223.172.149 with SMTP id o21mr2470391wrc.181.1495032726207; Wed, 17 May 2017 07:52:06 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:54 +0100 Message-Id: <20170517145259.28979-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PATCH v2 1/6] scripts/replay-dump.py: replay log dumper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This script is a debugging tool for looking through the contents of a replay log file. It is incomplete but should fail gracefully at events it doesn't understand. It currently understands two different log formats as the audio record/replay support was merged during since MTTCG. It was written to help debug what has caused the BQL changes to break replay support. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- scripts/replay-dump.py | 272 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 272 insertions(+) create mode 100755 scripts/replay-dump.py diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py new file mode 100755 index 0000000000..fdd178aba0 --- /dev/null +++ b/scripts/replay-dump.py @@ -0,0 +1,272 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Dump the contents of a recorded execution stream +# +# Copyright (c) 2017 Alex Benn=C3=A9e +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . + +import argparse +import struct +from collections import namedtuple + +# This mirrors some of the global replay state which some of the +# stream loading refers to. Some decoders may read the next event so +# we need handle that case. Calling reuse_event will ensure the next +# event is read from the cache rather than advancing the file. + +class ReplayState(object): + def __init__(self): + self.event =3D -1 + self.event_count =3D 0 + self.already_read =3D False + self.current_checkpoint =3D 0 + self.checkpoint =3D 0 + + def set_event(self, ev): + self.event =3D ev + self.event_count +=3D 1 + + def get_event(self): + self.already_read =3D False + return self.event + + def reuse_event(self, ev): + self.event =3D ev + self.already_read =3D True + + def set_checkpoint(self): + self.checkpoint =3D self.event - self.checkpoint_start + + def get_checkpoint(self): + return self.checkpoint + +replay_state =3D ReplayState() + +# Simple read functions that mirror replay-internal.c +# The file-stream is big-endian and manually written out a byte at a time. + +def read_byte(fin): + "Read a single byte" + return struct.unpack('>B', fin.read(1))[0] + +def read_event(fin): + "Read a single byte event, but save some state" + if replay_state.already_read: + return replay_state.get_event() + else: + replay_state.set_event(read_byte(fin)) + return replay_state.event + +def read_word(fin): + "Read a 16 bit word" + return struct.unpack('>H', fin.read(2))[0] + +def read_dword(fin): + "Read a 32 bit word" + return struct.unpack('>I', fin.read(4))[0] + +def read_qword(fin): + "Read a 64 bit word" + return struct.unpack('>Q', fin.read(8))[0] + +# Generic decoder structure +Decoder =3D namedtuple("Decoder", "eid name fn") + +def call_decode(table, index, dumpfile): + "Search decode table for next step" + decoder =3D next((d for d in table if d.eid =3D=3D index), None) + if not decoder: + print "Could not decode index: %d" % (index) + print "Entry is: %s" % (decoder) + print "Decode Table is:\n%s" % (table) + return False + else: + return decoder.fn(decoder.eid, decoder.name, dumpfile) + +# Print event +def print_event(eid, name, string=3DNone, event_count=3DNone): + "Print event with count" + if not event_count: + event_count =3D replay_state.event_count + + if string: + print "%d:%s(%d) %s" % (event_count, name, eid, string) + else: + print "%d:%s(%d)" % (event_count, name, eid) + + +# Decoders for each event type + +def decode_unimp(eid, name, _unused_dumpfile): + "Unimplimented decoder, will trigger exit" + print "%s not handled - will now stop" % (name) + return False + +# Checkpoint decoder +def swallow_async_qword(eid, name, dumpfile): + "Swallow a qword of data without looking at it" + step_id =3D read_qword(dumpfile) + print " %s(%d) @ %d" % (name, eid, step_id) + return True + +async_decode_table =3D [ Decoder(0, "REPLAY_ASYNC_EVENT_BH", swallow_async= _qword), + Decoder(1, "REPLAY_ASYNC_INPUT", decode_unimp), + Decoder(2, "REPLAY_ASYNC_INPUT_SYNC", decode_unimp), + Decoder(3, "REPLAY_ASYNC_CHAR_READ", decode_unimp), + Decoder(4, "REPLAY_ASYNC_EVENT_BLOCK", decode_unimp= ), + Decoder(5, "REPLAY_ASYNC_EVENT_NET", decode_unimp), +] +# See replay_read_events/replay_read_event +def decode_async(eid, name, dumpfile): + """Decode an ASYNC event""" + + print_event(eid, name) + + async_event_kind =3D read_byte(dumpfile) + async_event_checkpoint =3D read_byte(dumpfile) + + if async_event_checkpoint !=3D replay_state.current_checkpoint: + print " mismatch between checkpoint %d and async data %d" % ( + replay_state.current_checkpoint, async_event_checkpoint) + return True + + return call_decode(async_decode_table, async_event_kind, dumpfile) + + +def decode_instruction(eid, name, dumpfile): + ins_diff =3D read_dword(dumpfile) + print_event(eid, name, "0x%x" % (ins_diff)) + return True + +def decode_audio_out(eid, name, dumpfile): + audio_data =3D read_dword(dumpfile) + print_event(eid, name, "%d" % (audio_data)) + return True + +def decode_checkpoint(eid, name, dumpfile): + """Decode a checkpoint. + + Checkpoints contain a series of async events with their own specific d= ata. + """ + replay_state.set_checkpoint() + # save event count as we peek ahead + event_number =3D replay_state.event_count + next_event =3D read_event(dumpfile) + + # if the next event is EVENT_ASYNC there are a bunch of + # async events to read, otherwise we are done + if next_event !=3D 3: + print_event(eid, name, "no additional data", event_number) + else: + print_event(eid, name, "more data follows", event_number) + + replay_state.reuse_event(next_event) + return True + +def decode_checkpoint_init(eid, name, dumpfile): + print_event(eid, name) + return True + +def decode_interrupt(eid, name, dumpfile): + print_event(eid, name) + return True + +def decode_clock(eid, name, dumpfile): + clock_data =3D read_qword(dumpfile) + print_event(eid, name, "0x%x" % (clock_data)) + return True + + +# pre-MTTCG merge +v5_event_table =3D [Decoder(0, "EVENT_INSTRUCTION", decode_instruction), + Decoder(1, "EVENT_INTERRUPT", decode_interrupt), + Decoder(2, "EVENT_EXCEPTION", decode_unimp), + Decoder(3, "EVENT_ASYNC", decode_async), + Decoder(4, "EVENT_SHUTDOWN", decode_unimp), + Decoder(5, "EVENT_CHAR_WRITE", decode_unimp), + Decoder(6, "EVENT_CHAR_READ_ALL", decode_unimp), + Decoder(7, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp), + Decoder(8, "EVENT_CLOCK_HOST", decode_clock), + Decoder(9, "EVENT_CLOCK_VIRTUAL_RT", decode_clock), + Decoder(10, "EVENT_CP_CLOCK_WARP_START", decode_checkpoi= nt), + Decoder(11, "EVENT_CP_CLOCK_WARP_ACCOUNT", decode_checkp= oint), + Decoder(12, "EVENT_CP_RESET_REQUESTED", decode_checkpoin= t), + Decoder(13, "EVENT_CP_SUSPEND_REQUESTED", decode_checkpo= int), + Decoder(14, "EVENT_CP_CLOCK_VIRTUAL", decode_checkpoint), + Decoder(15, "EVENT_CP_CLOCK_HOST", decode_checkpoint), + Decoder(16, "EVENT_CP_CLOCK_VIRTUAL_RT", decode_checkpoi= nt), + Decoder(17, "EVENT_CP_INIT", decode_checkpoint_init), + Decoder(18, "EVENT_CP_RESET", decode_checkpoint), +] + +# post-MTTCG merge, AUDIO support added +v6_event_table =3D [Decoder(0, "EVENT_INSTRUCTION", decode_instruction), + Decoder(1, "EVENT_INTERRUPT", decode_interrupt), + Decoder(2, "EVENT_EXCEPTION", decode_unimp), + Decoder(3, "EVENT_ASYNC", decode_async), + Decoder(4, "EVENT_SHUTDOWN", decode_unimp), + Decoder(5, "EVENT_CHAR_WRITE", decode_unimp), + Decoder(6, "EVENT_CHAR_READ_ALL", decode_unimp), + Decoder(7, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp), + Decoder(8, "EVENT_AUDIO_OUT", decode_audio_out), + Decoder(9, "EVENT_AUDIO_IN", decode_unimp), + Decoder(10, "EVENT_CLOCK_HOST", decode_clock), + Decoder(11, "EVENT_CLOCK_VIRTUAL_RT", decode_clock), + Decoder(12, "EVENT_CP_CLOCK_WARP_START", decode_checkpoi= nt), + Decoder(13, "EVENT_CP_CLOCK_WARP_ACCOUNT", decode_checkp= oint), + Decoder(14, "EVENT_CP_RESET_REQUESTED", decode_checkpoin= t), + Decoder(15, "EVENT_CP_SUSPEND_REQUESTED", decode_checkpo= int), + Decoder(16, "EVENT_CP_CLOCK_VIRTUAL", decode_checkpoint), + Decoder(17, "EVENT_CP_CLOCK_HOST", decode_checkpoint), + Decoder(18, "EVENT_CP_CLOCK_VIRTUAL_RT", decode_checkpoi= nt), + Decoder(19, "EVENT_CP_INIT", decode_checkpoint_init), + Decoder(20, "EVENT_CP_RESET", decode_checkpoint), +] + +def parse_arguments(): + "Grab arguments for script" + parser =3D argparse.ArgumentParser() + parser.add_argument("-f", "--file", help=3D'record/replay dump to read= from', + required=3DTrue) + return parser.parse_args() + +def decode_file(filename): + "Decode a record/replay dump" + dumpfile =3D open(filename, "rb") + + # read and throwaway the header + version =3D read_dword(dumpfile) + junk =3D read_qword(dumpfile) + + print "HEADER: version 0x%x" % (version) + if version =3D=3D 0xe02006: + event_decode_table =3D v6_event_table + replay_state.checkpoint_start =3D 12 + else: + event_decode_table =3D v5_event_table + replay_state.checkpoint_start =3D 10 + + try: + decode_ok =3D True + while decode_ok: + event =3D read_event(dumpfile) + decode_ok =3D call_decode(event_decode_table, event, dumpfile) + finally: + dumpfile.close() + +if __name__ =3D=3D "__main__": + args =3D parse_arguments() + decode_file(args.file) --=20 2.11.0 From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495032851464785.1201824195496; Wed, 17 May 2017 07:54:11 -0700 (PDT) Received: from localhost ([::1]:49379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0L3-0002z2-0J for importer@patchew.org; Wed, 17 May 2017 10:54:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0J8-0001iy-Je for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J6-0004ew-HB for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:10 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:37469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J6-0004ec-B9 for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:08 -0400 Received: by mail-wm0-x22e.google.com with SMTP id d127so19125370wmf.0 for ; Wed, 17 May 2017 07:52:08 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c37sm2247425wra.16.2017.05.17.07.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A1E7E3E0662; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f9S/5vQAaqH5p1VznmOtF2yJj3YXgg3ABa33JNSOsG0=; b=HXNECJWpeJnSrNwCgu7Qydu+TyymrNCiFlpJQaEoXLOWsXkiosVuooALkTlrh26ZxH 4tjyEqxFtQf+38vilQndvel1k1Y7qBFMLsEOxnCox8IeYjIvdS5/OM61eiJVfX2mFCWN g0K+2O58UJ+cC6MF6RHdw7stynA5vAVatKKNY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f9S/5vQAaqH5p1VznmOtF2yJj3YXgg3ABa33JNSOsG0=; b=kZSvOhVwIZhZTylBNyODLSGxVKwBfWsmhQjNgytu2NAd4sSxTX6O0lqG2N7FNdIJ/G V+eyIvbCqXMe2El+RHzKAMeCjWbDOWzMdC6dotPnAvWeNqyoTCEpoKhcgxgAfHI0N+HY 4g5fdHWG5UpSrXiJ38Bp9gkLia4BzBdj6ykAEa/IYKL4ArqN4lRjFaN4Pil3H/MGVoy6 iWTyCEkjqeV5mbgneSm1Yya0LgTqzH0RFgL+uTgJqgU84CTkxlt3dqjHKKHyxH75uNp5 jUB+5r1nKOqv/bhJh4dZadGjxRvecLL88AcalFgH8Igp+2JZZE7VXGvEsspO5kfAaLyD nsag== X-Gm-Message-State: AODbwcB5gn9QrHgzhHzMem6cqOjw3VKdwLG56e+yKpKY3XjeYk0U7KAR 9Bxnlzx5kjv8WU6T X-Received: by 10.28.207.207 with SMTP id f198mr11939199wmg.85.1495032727150; Wed, 17 May 2017 07:52:07 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:55 +0100 Message-Id: <20170517145259.28979-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PATCH v2 2/6] scripts/qemu-gdb/timers.py: new helper to dump timer state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This introduces the qemu-gdb command "qemu timers" which will dump the state of the main timers in the system. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/timers.py | 54 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/timers.py diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index b3f8e04f77..3e7adb87dc 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -26,7 +26,7 @@ import os, sys =20 sys.path.append(os.path.dirname(__file__)) =20 -from qemugdb import aio, mtree, coroutine +from qemugdb import aio, mtree, coroutine, timers =20 class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -38,6 +38,7 @@ QemuCommand() coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() +timers.TimersCommand() =20 coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py new file mode 100644 index 0000000000..be71a001e3 --- /dev/null +++ b/scripts/qemugdb/timers.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# GDB debugging support +# +# Copyright 2017 Linaro Ltd +# +# Author: Alex Benn=C3=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. + +# 'qemu timers' -- display the current timerlists + +import gdb + +class TimersCommand(gdb.Command): + '''Display the current QEMU timers''' + + def __init__(self): + 'Register the class as a gdb command' + gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + def dump_timers(self, timer): + "Follow a timer and recursively dump each one in the list." + # timer should be of type QemuTimer + gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % ( + timer['expire_time'], + timer['scale'], + timer['cb'], + timer['opaque'])) + + if int(timer['next']) > 0: + self.dump_timers(timer['next']) + + + def process_timerlist(self, tlist, ttype): + gdb.write("Processing %s timers\n" % (ttype)) + gdb.write(" clock %s is enabled:%s, last:%s\n" % ( + tlist['clock']['type'], + tlist['clock']['enabled'], + tlist['clock']['last'])) + if int(tlist['active_timers']) > 0: + self.dump_timers(tlist['active_timers']) + + + def invoke(self, arg, from_tty): + 'Run the command' + main_timers =3D gdb.parse_and_eval("main_loop_tlg") + + # This will break if QEMUClockType in timer.h is redfined + self.process_timerlist(main_timers['tl'][0], "Realtime") + self.process_timerlist(main_timers['tl'][1], "Virtual") + self.process_timerlist(main_timers['tl'][2], "Host") + self.process_timerlist(main_timers['tl'][3], "Virtual RT") --=20 2.11.0 From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495032851895908.3727659030797; Wed, 17 May 2017 07:54:11 -0700 (PDT) Received: from localhost ([::1]:49380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0L4-0002zz-DX for importer@patchew.org; Wed, 17 May 2017 10:54:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0J8-0001jL-Ma for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J7-0004fA-Hv for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:10 -0400 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:36111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J7-0004f2-Bb for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:09 -0400 Received: by mail-wm0-x22f.google.com with SMTP id 70so13261416wmq.1 for ; Wed, 17 May 2017 07:52:09 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b201sm18156845wme.2.2017.05.17.07.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B37663E0873; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vTYtpBDRzxzM+fZ0Ec4/8/8UNwCxlePzzhuR8PHRSx8=; b=WAbWTAWHxa+uOVbHGMS2soTKy/wPkgKcm1g5x44lk4PjsUPM7yzSXXyIRAG9HfDbtG bsouFGs1gMoByi3nXo9sb8mstsswHfGVOo3zwLiyViA67pycsca0gbdYxnNEH+hDDavT VkZTjxOFkGiqaCAs61nXkyv1hZ8iRxj0EEZqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vTYtpBDRzxzM+fZ0Ec4/8/8UNwCxlePzzhuR8PHRSx8=; b=EC9+u9mIKCI8dwMBObrX2cVgSdSIKCbVa7fsHwJKix9Kh1FExtXEloLGPcDDSvBg23 hYidFhBpH1Zunvb+3qdfazhBXbXITJUgY09y+4Nvy/N3CK9bPPA44kPdlIej3MRewH8S ztrJrmJVU+NaTugDlmb83/7/tlhNAvBQX8wkH2Qjm0Puh1hb2IMT7Y3qUfR/iTE2XiwX uVY0UHXBCPFvxVorxmISnnUGNUFxfR5v9VAgmJbOEU5z/9ooNDs218DDjdPgYQy3H1P5 1EDK854rDsXXP4r/APzHOjxpxgk/L5gyTPGi1mE+oL8D0PICXND0F6Cuzm7MyGO6lFBo wdzQ== X-Gm-Message-State: AODbwcDRZDW1HuNhNrRD1lJi/TLCJjJXrdCNfKmiuln2sjbKKf4sdE8P RYHQEeLQyxolrjQR X-Received: by 10.28.87.72 with SMTP id l69mr10597009wmb.111.1495032728010; Wed, 17 May 2017 07:52:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:56 +0100 Message-Id: <20170517145259.28979-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22f Subject: [Qemu-devel] [PATCH v2 3/6] scripts/qemu-gdb/tcg: new helper to dump tcg state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This adds a simple helper to dump lock state within TCG. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/tcg.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/tcg.py diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index 3e7adb87dc..91e928f6af 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -26,7 +26,7 @@ import os, sys =20 sys.path.append(os.path.dirname(__file__)) =20 -from qemugdb import aio, mtree, coroutine, timers +from qemugdb import aio, mtree, coroutine, timers, tcg =20 class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -39,6 +39,7 @@ coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() timers.TimersCommand() +tcg.TCGLockStatusCommand() =20 coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/tcg.py b/scripts/qemugdb/tcg.py new file mode 100644 index 0000000000..8c7f1d7454 --- /dev/null +++ b/scripts/qemugdb/tcg.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# GDB debugging support, TCG status +# +# Copyright 2016 Linaro Ltd +# +# Authors: +# Alex Benn=C3=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# +# Contributions after 2012-01-13 are licensed under the terms of the +# GNU GPL, version 2 or (at your option) any later version. + +# 'qemu tcg-lock-status' -- display the TCG lock status across threads + +import gdb + +class TCGLockStatusCommand(gdb.Command): + '''Display TCG Execution Status''' + def __init__(self): + gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DAT= A, + gdb.COMPLETE_NONE) + + def invoke(self, arg, from_tty): + gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n") + for thread in gdb.inferiors()[0].threads(): + thread.switch() + + iothread =3D gdb.parse_and_eval("iothread_locked") + replay =3D gdb.parse_and_eval("replay_locked") + + frame =3D gdb.selected_frame() + if frame.name() =3D=3D "__lll_lock_wait": + frame.older().select() + mutex =3D gdb.parse_and_eval("mutex") + owner =3D gdb.parse_and_eval("mutex->__data.__owner") + blocked =3D ("__lll_lock_wait waiting on %s from %d" % + (mutex, owner)) + else: + blocked =3D "not blocked" + + gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1], + iothread, replay, blocked)) --=20 2.11.0 From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495032990966247.81395366899835; Wed, 17 May 2017 07:56:30 -0700 (PDT) Received: from localhost ([::1]:49395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0NI-0004x8-LZ for importer@patchew.org; Wed, 17 May 2017 10:56:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0J9-0001lW-9q for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J8-0004fT-4Q for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:11 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:33486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J7-0004f6-VL for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:10 -0400 Received: by mail-wr0-x232.google.com with SMTP id w50so12426487wrc.0 for ; Wed, 17 May 2017 07:52:09 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s110sm2759117wrc.5.2017.05.17.07.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C641B3E087F; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qOkG1Gzi7LEm5JRwN5qbVc+hJqe9ViKx3y1dYHKPk6Y=; b=cTgOLJb0SpLaC031sOPN8VerEzUw/9sPhqQCE+MHzWwF6TpBTTEM8CDfvPGj6awjAO 4GbdHa81+lizK5gg0RhbV0r7lu6hhLHn57LmBDyi+NyS9neecmiuc4KLtilFk0XkNNc5 /fCwP2BeiZPgHKLaayoOQ4FN1m2rADfkNIhG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qOkG1Gzi7LEm5JRwN5qbVc+hJqe9ViKx3y1dYHKPk6Y=; b=D1T50dy+D0Q5+kRYqb6NVKnagnSNma6HQNjveB1q7BHA7zRiH/aTOBE2bbzqP+u4u4 9Vyy3PlFreXbbE0nBGliZ7Q7lcsfbLWSfAJUcgA86AaGcv6nRBFHK3S/CL4p0rQEdpX5 ZhmVB/Y7QdjHdgqFd2CRXCdjnKiivJzkwsV2rU5ORbTEp5xlVj+fbRsnS6ri+ld/y9am FgfrXgIcWrbCosT9qlihOK56LAcSvZHCdY1sCl2Zg++RCvDeu5fGruyjnT/Pwkon3YgX rSlQh3rwsUcd4QdxCHZLEcRr4HCcEIa32nKHDMw35nMPj0Fpk+QTSavx+tRMPdB+bLsw ejSA== X-Gm-Message-State: AODbwcCryqcUrcY6hwQ5i7JeKf1asIb7F0TVQm6FCSpHR/RJWDrAbWOO 2EEZGfWsyX515HfZ X-Received: by 10.223.163.21 with SMTP id c21mr2476506wrb.38.1495032728850; Wed, 17 May 2017 07:52:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:57 +0100 Message-Id: <20170517145259.28979-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PATCH v2 4/6] cputlb: remove tlb_flush_count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Flushing of the CPU TLB is no longer a simple count. The ratio of self-flushes to cross-flushes and if they need to synchronise across vCPUs has more of an impact. To correctly capture this we'll replace the simple count with trace points in a future patch. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Stefan Hajnoczi --- cputlb.c | 4 ---- include/exec/cputlb.h | 1 - translate-all.c | 1 - 3 files changed, 6 deletions(-) diff --git a/cputlb.c b/cputlb.c index f5d056cc08..d1859c3f37 100644 --- a/cputlb.c +++ b/cputlb.c @@ -92,9 +92,6 @@ static void flush_all_helper(CPUState *src, run_on_cpu_fu= nc fn, } } =20 -/* statistics */ -int tlb_flush_count; - /* This is OK because CPU architectures generally permit an * implementation to drop entries from the TLB at any time, so * flushing more entries than required is only an efficiency issue, @@ -112,7 +109,6 @@ static void tlb_flush_nocheck(CPUState *cpu) } =20 assert_cpu_is_self(cpu); - tlb_debug("(count: %d)\n", tlb_flush_count++); =20 tb_lock(); =20 diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h index 3f941783c5..dac9901da5 100644 --- a/include/exec/cputlb.h +++ b/include/exec/cputlb.h @@ -23,7 +23,6 @@ /* cputlb.c */ void tlb_protect_code(ram_addr_t ram_addr); void tlb_unprotect_code(ram_addr_t ram_addr); -extern int tlb_flush_count; =20 #endif #endif diff --git a/translate-all.c b/translate-all.c index b3ee876526..eeb3807242 100644 --- a/translate-all.c +++ b/translate-all.c @@ -1927,7 +1927,6 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fpr= intf) atomic_read(&tcg_ctx.tb_ctx.tb_flush_count)); cpu_fprintf(f, "TB invalidate count %d\n", tcg_ctx.tb_ctx.tb_phys_invalidate_count); - cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count); tcg_dump_info(f, cpu_fprintf); =20 tb_unlock(); --=20 2.11.0 From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14950329866811023.508296739125; Wed, 17 May 2017 07:56:26 -0700 (PDT) Received: from localhost ([::1]:49394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0NF-0004uB-B1 for importer@patchew.org; Wed, 17 May 2017 10:56:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0JA-0001nb-Qe for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J9-0004gL-8V for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:12 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:36130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J9-0004fZ-0P for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:11 -0400 Received: by mail-wm0-x22e.google.com with SMTP id 70so13262455wmq.1 for ; Wed, 17 May 2017 07:52:10 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 2sm19188660wmk.20.2017.05.17.07.52.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:08 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D7C7D3E08CD; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fkx3DolIxITVCWhGdxcm2J15pc5f5bdwpaYpklZZI14=; b=YSLZQo8SAxhOYWvsuP/KzyKCZ5FChOUcC+9vN0Q78EEzY+MEl8oe4hw+Gxw0/hg5pd T1c5gkykGddw5UBMnWZ132+TlXR7uDKY3c/hmDsFHxMNnSWPP9aHFKdjsHu484fwiJDv qM/xg4uYDgVDH1AEq8Ka/v6g+Drpkovv+VNTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fkx3DolIxITVCWhGdxcm2J15pc5f5bdwpaYpklZZI14=; b=de9PKCvZ/tv+zzJChhGYLRSTvN3mAHHqaLPEUoZJfuaM1VG+G5WnU0YMYn5EW43BBW doVcGATUzDG2zCEbMLo8g0+fpJczWOEo23RnDgkvpwkfz0NDIqTwnytLYChQCvLC+gn+ 1ajq4vlM4buqq/W+A/5H6rIBcyzGJMGs4y5ITawz/mcSfUgcZuF8RAQWb1mYZ3PCYt/T ZyMeex/pWquyUB+lhUUTuSULA9Rqw3PEV/UlhuVAb+itvpYV07wnY7RpUbYBl6D4Ciyx bVvIZJmzRDz5Zyg7P0Zo1dbn49zGGNvkNXbajwOzHd08hbq55kXJ8XB+fm92vqF6nauH lm1g== X-Gm-Message-State: AODbwcDti0n0mUvCjdMUoiExAHjkHl+QQrxnx8ezTJbh7vCTEgJcBBHc t2PiBGuzeboEX56y X-Received: by 10.28.24.207 with SMTP id 198mr6585004wmy.86.1495032729823; Wed, 17 May 2017 07:52:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:58 +0100 Message-Id: <20170517145259.28979-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PATCH v2 5/6] cputlb: add trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Given the range of costs for various SoftMMU TLB operations from deferring work for the currently running vCPU to bring the whole emulated machine to a stop for synchronised updates simple counters are less useful. Instead we log events via the trace infrastructure and we can then post-process the data in a range of ways. tlb_flush_self - the vCPU flushed its own TLB tlb_flush_async_schedule - work was scheduled and the vCPU kicked tlb_flush_synced_schedule - exclusive work was scheduled on a vCPU tlb_flush_work - scheduled work was done We can use the difference between the work being scheduled and tlb_flush_work to calculate the latency introduced. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- cputlb.c | 34 +++++++++++++++++++++++++++++++++- trace-events | 7 +++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cputlb.c b/cputlb.c index d1859c3f37..b2490863e4 100644 --- a/cputlb.c +++ b/cputlb.c @@ -127,6 +127,7 @@ static void tlb_flush_nocheck(CPUState *cpu) =20 static void tlb_flush_global_async_work(CPUState *cpu, run_on_cpu_data dat= a) { + trace_tlb_flush_work(__func__, cpu->cpu_index); tlb_flush_nocheck(cpu); } =20 @@ -135,17 +136,22 @@ void tlb_flush(CPUState *cpu) if (cpu->created && !qemu_cpu_is_self(cpu)) { if (atomic_mb_read(&cpu->pending_tlb_flush) !=3D ALL_MMUIDX_BITS) { atomic_mb_set(&cpu->pending_tlb_flush, ALL_MMUIDX_BITS); + trace_tlb_flush_async_schedule(__func__, current_cpu ? + current_cpu->cpu_index : + cpu->cpu_index, cpu->cpu_index); async_run_on_cpu(cpu, tlb_flush_global_async_work, RUN_ON_CPU_NULL); } } else { - tlb_flush_nocheck(cpu); + trace_tlb_flush_self(__func__, cpu->cpu_index); + tlb_flush_global_async_work(cpu, RUN_ON_CPU_NULL); } } =20 void tlb_flush_all_cpus(CPUState *src_cpu) { const run_on_cpu_func fn =3D tlb_flush_global_async_work; + trace_tlb_flush_async_schedule(__func__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_NULL); fn(src_cpu, RUN_ON_CPU_NULL); } @@ -153,6 +159,7 @@ void tlb_flush_all_cpus(CPUState *src_cpu) void tlb_flush_all_cpus_synced(CPUState *src_cpu) { const run_on_cpu_func fn =3D tlb_flush_global_async_work; + trace_tlb_flush_synced_schedule(__func__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_NULL); async_safe_run_on_cpu(src_cpu, fn, RUN_ON_CPU_NULL); } @@ -163,6 +170,8 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cp= u, run_on_cpu_data data) unsigned long mmu_idx_bitmask =3D data.host_int; int mmu_idx; =20 + trace_tlb_flush_work(__func__, cpu->cpu_index); + assert_cpu_is_self(cpu); =20 tb_lock(); @@ -196,12 +205,16 @@ void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxm= ap) =20 if (pending_flushes) { tlb_debug("reduced mmu_idx: 0x%" PRIx16 "\n", pending_flushes); + trace_tlb_flush_async_schedule(__func__, + current_cpu->cpu_index, + cpu->cpu_index); =20 atomic_or(&cpu->pending_tlb_flush, pending_flushes); async_run_on_cpu(cpu, tlb_flush_by_mmuidx_async_work, RUN_ON_CPU_HOST_INT(pending_flushes)); } } else { + trace_tlb_flush_self(__func__, cpu->cpu_index); tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(idxmap)); } @@ -212,6 +225,7 @@ void tlb_flush_by_mmuidx_all_cpus(CPUState *src_cpu, ui= nt16_t idxmap) const run_on_cpu_func fn =3D tlb_flush_by_mmuidx_async_work; =20 tlb_debug("mmu_idx: 0x%"PRIx16"\n", idxmap); + trace_tlb_flush_async_schedule(__func__, src_cpu->cpu_index, -1); =20 flush_all_helper(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); fn(src_cpu, RUN_ON_CPU_HOST_INT(idxmap)); @@ -223,6 +237,7 @@ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_= cpu, const run_on_cpu_func fn =3D tlb_flush_by_mmuidx_async_work; =20 tlb_debug("mmu_idx: 0x%"PRIx16"\n", idxmap); + trace_tlb_flush_synced_schedule(__func__, src_cpu->cpu_index, -1); =20 flush_all_helper(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); async_safe_run_on_cpu(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); @@ -252,6 +267,7 @@ static void tlb_flush_page_async_work(CPUState *cpu, ru= n_on_cpu_data data) assert_cpu_is_self(cpu); =20 tlb_debug("page :" TARGET_FMT_lx "\n", addr); + trace_tlb_flush_work(__func__, cpu->cpu_index); =20 /* Check if we need to flush due to large pages. */ if ((addr & env->tlb_flush_mask) =3D=3D env->tlb_flush_addr) { @@ -285,9 +301,12 @@ void tlb_flush_page(CPUState *cpu, target_ulong addr) tlb_debug("page :" TARGET_FMT_lx "\n", addr); =20 if (!qemu_cpu_is_self(cpu)) { + trace_tlb_flush_async_schedule(__func__, current_cpu->cpu_index, + cpu->cpu_index); async_run_on_cpu(cpu, tlb_flush_page_async_work, RUN_ON_CPU_TARGET_PTR(addr)); } else { + trace_tlb_flush_self(__func__, cpu->cpu_index); tlb_flush_page_async_work(cpu, RUN_ON_CPU_TARGET_PTR(addr)); } } @@ -312,6 +331,7 @@ static void tlb_flush_page_by_mmuidx_async_work(CPUStat= e *cpu, =20 tlb_debug("page:%d addr:"TARGET_FMT_lx" mmu_idx:0x%lx\n", page, addr, mmu_idx_bitmap); + trace_tlb_flush_work(__func__, cpu->cpu_index); =20 for (mmu_idx =3D 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmap)) { @@ -336,6 +356,7 @@ static void tlb_check_page_and_flush_by_mmuidx_async_wo= rk(CPUState *cpu, unsigned long mmu_idx_bitmap =3D addr_and_mmuidx & ALL_MMUIDX_BITS; =20 tlb_debug("addr:"TARGET_FMT_lx" mmu_idx: %04lx\n", addr, mmu_idx_bitma= p); + trace_tlb_flush_work(__func__, cpu->cpu_index); =20 /* Check if we need to flush due to large pages. */ if ((addr & env->tlb_flush_mask) =3D=3D env->tlb_flush_addr) { @@ -343,9 +364,11 @@ static void tlb_check_page_and_flush_by_mmuidx_async_w= ork(CPUState *cpu, TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", env->tlb_flush_addr, env->tlb_flush_mask); =20 + trace_tlb_flush_self(__func__, cpu->cpu_index); tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(mmu_idx_bitmap)= ); } else { + trace_tlb_flush_self(__func__, cpu->cpu_index); tlb_flush_page_by_mmuidx_async_work(cpu, data); } } @@ -361,9 +384,12 @@ void tlb_flush_page_by_mmuidx(CPUState *cpu, target_ul= ong addr, uint16_t idxmap) addr_and_mmu_idx |=3D idxmap; =20 if (!qemu_cpu_is_self(cpu)) { + trace_tlb_flush_async_schedule(__func__, current_cpu->cpu_index, + cpu->cpu_index); async_run_on_cpu(cpu, tlb_check_page_and_flush_by_mmuidx_async_wor= k, RUN_ON_CPU_TARGET_PTR(addr_and_mmu_idx)); } else { + trace_tlb_flush_self(__func__, cpu->cpu_index); tlb_check_page_and_flush_by_mmuidx_async_work( cpu, RUN_ON_CPU_TARGET_PTR(addr_and_mmu_idx)); } @@ -376,6 +402,7 @@ void tlb_flush_page_by_mmuidx_all_cpus(CPUState *src_cp= u, target_ulong addr, target_ulong addr_and_mmu_idx; =20 tlb_debug("addr: "TARGET_FMT_lx" mmu_idx:%"PRIx16"\n", addr, idxmap); + trace_tlb_flush_async_schedule(__func__, src_cpu->cpu_index, -1); =20 /* This should already be page aligned */ addr_and_mmu_idx =3D addr & TARGET_PAGE_MASK; @@ -393,6 +420,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState = *src_cpu, target_ulong addr_and_mmu_idx; =20 tlb_debug("addr: "TARGET_FMT_lx" mmu_idx:%"PRIx16"\n", addr, idxmap); + trace_tlb_flush_synced_schedule(__func__, src_cpu->cpu_index, -1); =20 /* This should already be page aligned */ addr_and_mmu_idx =3D addr & TARGET_PAGE_MASK; @@ -406,6 +434,8 @@ void tlb_flush_page_all_cpus(CPUState *src, target_ulon= g addr) { const run_on_cpu_func fn =3D tlb_flush_page_async_work; =20 + trace_tlb_flush_async_schedule(__func__, src->cpu_index, -1); + flush_all_helper(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); fn(src, RUN_ON_CPU_TARGET_PTR(addr)); } @@ -415,6 +445,8 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, { const run_on_cpu_func fn =3D tlb_flush_page_async_work; =20 + trace_tlb_flush_synced_schedule(__func__, src->cpu_index, -1); + flush_all_helper(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); async_safe_run_on_cpu(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); } diff --git a/trace-events b/trace-events index e582d6315d..500f84b8c4 100644 --- a/trace-events +++ b/trace-events @@ -78,6 +78,13 @@ disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=3D0x%"= PRIxPTR disable exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=3D0x%"PRIxPTR disable exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=3D%x" =20 +# SoftMMU TLB flushes +# - setting to=3D-1 indicates work scheduled on all vCPUs +tlb_flush_self(const char *fn, int vcpu) "%s: cpu %d" +tlb_flush_async_schedule(const char *fn, int from, int to) "%s: from_cpu= =3D%d to_cpu=3D%d" +tlb_flush_synced_schedule(const char *fn, int from, int to) "%s: from_cpu= =3D%d to_cpu=3D%d" +tlb_flush_work(const char *fn, int vcpu) "%s: cpu %d" + # translate-all.c translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"P= RIxPTR", tb_code:%p" =20 --=20 2.11.0 From nobody Sun May 5 17:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495032918974813.854746411166; Wed, 17 May 2017 07:55:18 -0700 (PDT) Received: from localhost ([::1]:49381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0M8-0003sf-KL for importer@patchew.org; Wed, 17 May 2017 10:55:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0JB-0001qc-K0 for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0JA-0004hH-Cr for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:13 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:33987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0JA-0004gT-3T for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:12 -0400 Received: by mail-wr0-x22b.google.com with SMTP id l9so12462915wre.1 for ; Wed, 17 May 2017 07:52:11 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n27sm1530670wra.57.2017.05.17.07.52.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:08 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E7F7F3E08D5; Wed, 17 May 2017 15:52:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zr8eaC1w14Cw1tsLDUZYCE/XYLWMKJGYH7RPzbyRiBQ=; b=I/AVSdxStsN51eRIO2vsIOMeQCZeTVLw1kpFwPftxOEg2KFG7V4l6fp46dz86rQl3c fmPtzR4ZGp5DDFt8BBxUCKoOfZoEnfd7YQBGFwA+J5aVuAFDUIegnWQdbjaV44N+zOLs ookJyJVUlo78lQTRbM5aImBFe+pPtxCm5nlMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zr8eaC1w14Cw1tsLDUZYCE/XYLWMKJGYH7RPzbyRiBQ=; b=uNWcN+Jvi5pBkNK/NxmqqtFhz8ghLa3wk38x3++y8ZFD7sRHj7pl/xGKZkE3609ct2 +dLLnYfCCE0YYWUF/1llxLwph02zx4NkwW5MYwuZ6PMK+wcCbVvTi+Mp1vDg5MntDoQj zfM58DTPEprVRUTdSJUvpefTqgpYj1dd1/wMdR/K/Uj3G3soO4e9NAGfZGwkdHqNuecS 4CWyuRIM+DJAiDXYR9OlqEc71vpNmSHzs7Gycw4KkgMKDOyx7BFdeV3tkYpFjtaE5f96 DV5zRen4Adir1wAJy4k6nPMrGbFvMtGidDmXqjb5/eMstZl+TUznM6QfvBaLHVyVsifO OU9g== X-Gm-Message-State: AODbwcA0Am4Dn5SpGexsPTnLDvDr19UEJpyFeN42GKPXaJ5i/dTQKHxR jDfDFwDwCUeCqGgI X-Received: by 10.223.179.199 with SMTP id x7mr2898073wrd.72.1495032730881; Wed, 17 May 2017 07:52:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:59 +0100 Message-Id: <20170517145259.28979-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PATCH v2 6/6] new script/analyse-tlb-flushes-simpletrace.py X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This is a simple helper script to extract TLB flush stats from the a simpletrace file and plot the results. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Stefan Hajnoczi --- v2 - re-factored for new trace events - added time and latency graphs --- scripts/analyse-tlb-flushes-simpletrace.py | 144 +++++++++++++++++++++++++= ++++ 1 file changed, 144 insertions(+) create mode 100755 scripts/analyse-tlb-flushes-simpletrace.py diff --git a/scripts/analyse-tlb-flushes-simpletrace.py b/scripts/analyse-t= lb-flushes-simpletrace.py new file mode 100755 index 0000000000..03fab8c86b --- /dev/null +++ b/scripts/analyse-tlb-flushes-simpletrace.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Generate a simple graph of flushes over time +# +# Author: Alex Benn=C3=A9e +# +# analyzer =3D CpuTLBFlushAnalyser(4) +# simpletrace.process("../trace-events-all", "../trace-22464", analyzer) + +import os +import simpletrace +import argparse +import numpy as np +import matplotlib +# Force matplotlib to not use any Xwindows backend. +matplotlib.use('Agg') +import matplotlib.pyplot as plt + +class FlushType: + Self, Async, Synced =3D range(3) + +class CpuTLBFlushAnalyser(simpletrace.Analyzer): + "A simpletrace Analyser for extracting flush stats." + + def __init__(self, nvcpus): + self.flush_total =3D 0 + self.flush_all =3D 0 + self.nvcpus =3D nvcpus + self.vcpu_last =3D [[] for _ in range(nvcpus)] + self.flush_self =3D [] + self.flush_self_times =3D [] + self.flush_async =3D [] + self.flush_async_times =3D [] + self.flush_synced =3D [] + self.flush_synced_times =3D [] + self.flush_work =3D [] + + self.unmatched_work =3D [] + + def __save_queue(self, vcpu, record): + self.flush_total +=3D 1 + # FIXME: don't seem to see -1 + if vcpu > 0x7fffffff: + self.flush_all +=3D 1 + for i in range(0, self.nvcpus): + self.vcpu_last[i].append(record) + else: + self.vcpu_last[vcpu].append(record) + + def tlb_flush_self(self, timestamp, fn, vcpu): + self.__save_queue(vcpu, (timestamp[0], FlushType.Self)) + self.flush_self.append((timestamp[0], vcpu)) + + def tlb_flush_async_schedule(self, timestamp, fn, from_vcpu, to_vcpu): + self.__save_queue(to_vcpu, (timestamp[0], FlushType.Async, + to_vcpu, from_vcpu)) + self.flush_async.append((timestamp[0], to_vcpu)) + + def tlb_flush_synced_schedule(self, timestamp, fn, from_vcpu, to_vcpu): + self.__save_queue(to_vcpu, (timestamp[0], FlushType.Synced, + to_vcpu, from_vcpu)) + self.flush_synced.append((timestamp[0], to_vcpu)) + + def tlb_flush_work(self, timestamp, fn, vcpu): + "Check when it was queued and work out how long it took" + + if len(self.vcpu_last[vcpu]): + last =3D self.vcpu_last[vcpu].pop(0) + latency =3D timestamp[0] - last[0] + switcher =3D { + FlushType.Self: lambda a: a.flush_self_times.append(latenc= y), + FlushType.Async: lambda a: a.flush_async_times.append(late= ncy), + FlushType.Synced: lambda a: a.flush_synced_times.append(la= tency), + } + switcher.get(last[1])(self) + + self.flush_work.append((timestamp[0], vcpu)) + else: + self.unmatched_work.append((timestamp[0], vcpu, fn)) + + + + +def get_args(): + "Grab options" + parser =3D argparse.ArgumentParser() + parser.add_argument("--output", "-o", type=3Dstr, help=3D"Render plot = to file") + parser.add_argument("--vcpus", type=3Dint, help=3D"Number of vCPUS") + parser.add_argument("--graph", choices=3D['time', 'latency'], default= =3D'time') + parser.add_argument("events", type=3Dstr, help=3D'trace file read from= ') + parser.add_argument("tracefile", type=3Dstr, help=3D'trace file read f= rom') + return parser.parse_args() + +def plot_time_series(time_data, label): + "Plot one timeseries, return star and end time limits" + counts =3D np.arange(0, len(time_data)) + times =3D [x[0] for x in time_data] + plt.plot(times, counts, label=3Dlabel) + return (times[0],times[-1]) + + +if __name__ =3D=3D '__main__': + args =3D get_args() + + # Gather data from the trace + analyzer =3D CpuTLBFlushAnalyser(args.vcpus) + + simpletrace.process(args.events, args.tracefile, analyzer) + + # Print some summary stats + print ("Flushes: self:%d async:%d synced:%d" % + ( len(analyzer.flush_self), + len(analyzer.flush_async), + len(analyzer.flush_synced))) + + if args.graph =3D=3D 'time': + start_self, end_self =3D plot_time_series(analyzer.flush_self, "Se= lf") + start_async, end_async =3D plot_time_series(analyzer.flush_async, = "Async") + start_synced, end_synced =3D plot_time_series(analyzer.flush_synce= d, "Self") + + # start right at the edge + plt.xlim(xmin=3Dmin(start_self, start_async, start_synced)) + elif args.graph =3D=3D 'latency': + + # Three subplots, the axes array is 1-d + + f, (ax_self, ax_async, ax_synced) =3D plt.subplots(3, sharex=3DTru= e) + ax_self.set_title("Distribution") + + ax_self.hist(analyzer.flush_self_times, 10, normed=3D1, + facecolor=3D'green', alpha=3D0.5) + ax_self.hist(analyzer.flush_async_times, 10, normed=3D1, + facecolor=3D'blue', alpha=3D0.5) + ax_self.hist(analyzer.flush_synced_times, + 10, normed=3D1, + facecolor=3D'red', alpha=3D0.5) + else: + raise ValueError("Bad graph type") + + if args.output: + plt.savefig(args.output) + else: + plt.show() --=20 2.11.0