From patchwork Fri Jun 28 12:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 808255 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp341517wrr; Fri, 28 Jun 2024 05:45:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfXPp8qjS3GgV1SOWVUL8pJLOpEjBLrkKUeqRWejXNLfiCFEWDdS0OJH80yED0J9P1VWjOTME6krV5iSKfYLqt X-Google-Smtp-Source: AGHT+IFqmNFGD8X5WjcNXj+wP4rxrRxo1Mq+ZNI8YmAmIFj1UrbprbjQfjS3uD51RJJa07qhVHkO X-Received: by 2002:a05:622a:1213:b0:444:ef14:e427 with SMTP id d75a77b69052e-444ef16dcb5mr134530101cf.52.1719578700858; Fri, 28 Jun 2024 05:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719578700; cv=none; d=google.com; s=arc-20160816; b=lcpFZCuj9VbeQAsjmythebORnAxa7iABJhNTArLkyF0wdh12gW2OZguU5/Yny45pOC r1h0t4xwmBazfgWw3egklpEnBaNjHYSR3JJz67EiLTu3iIMuYpzJQRdcokstFm7kGYXl iOdpI527SmZ7FgCRqHZc5IcFY8D2FgOMp2lNSjfTiOjvTcT/BE1dzXMBIXu20ED9P/uP 9UP4fXVf+rryBqGGPXNlfSV98RJGOVS4+Pbx9EuWptLZoS3Szoul/vzPkqV1KzCLgg6Y 6TqaSbmhtiIqbr6gqUKFMwD4+RBTBkJ0bnysxaneGqKjdp72fUaxE3Vd0lGzAx3rwH3f LZ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rvGmIc/IqaQmuLkCI/kfZ02beHV2np9KXDzigOomwVY=; fh=lYprE3b3djWrX1RXaKNWYtBM0py2TEOcoYTFuPEPQVw=; b=JG+z0sl95ZhNlfQK6SNCJ5ekIOmkAhSLL1qmGAqyMmbtffYhFtmVg6nXNzxSq8eW7O YmYSRiPWr0pHVlPH2vzeUrgPiVyzlfHUjyb7DY+6nE+XuPlscQf/rAPhjBJdKjw4j1eI cQ8DBRnlihynFIcXF4jg7ny2cQtghRwDmKsl2fSCW2pN73FKj8Ssd+/mNshInI+PJRn7 HXv36Mko4ntJu4utZXVU/yHE3Rf6jcKaln3Xu1LBHTokcol0x9zZ8RK2qAwxho3s3RCg 42Bk/Mef6+i8bphlTB+ni+qp4UW4XCyit3ak/VQKEKYHSbMiWqeS+VEGcLLRcDq9aLB8 qo2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LQ2i+wzo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446514c05b9si18088571cf.536.2024.06.28.05.45.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 05:45:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LQ2i+wzo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNAx6-0005GK-Ka; Fri, 28 Jun 2024 08:43:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNAwV-0004oO-T0 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:43:08 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNAwU-0005fs-6W for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:43:07 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-584ee8da49aso3089524a12.0 for ; Fri, 28 Jun 2024 05:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719578584; x=1720183384; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rvGmIc/IqaQmuLkCI/kfZ02beHV2np9KXDzigOomwVY=; b=LQ2i+wzo/qi5MzmYH5uZWE7RY2FTOZzYPF2qAltQjgnVzLLQnM2jYS4mhXUUzlSizY u8pg2LESNTV/pdACZILIaf9I57ltdkhyQZiyluUTrb5IpQKtoHwO3pTxWUa0zbPY2UKO F3BclslVtRW7YCIeEygP6xQB0U1GekLBbiP2M5cfXnp2LJKq1Urx4jadjM2CgpHiAx32 OD65MUJ0sflErC0p4QvxDaHvsKWe6J9iKgZIdjtylmyOpZWuLvdG/mF50ZIeb9pZYOr+ YJJ6QlnFB5OD0AhSChOMs0gqVDG0vdtxzHOJbdr+BYvVXqIyxqERGTu4mUjK1rcl1bv4 TXmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719578584; x=1720183384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rvGmIc/IqaQmuLkCI/kfZ02beHV2np9KXDzigOomwVY=; b=nknmRAEkrFXRZh7dkR1XXJpLdKEfkNKEgtXBK6SI/PQyjaWC6r9MZAnvkWqT/VQuRb b0D4BWkODXT1ZPz3GcQ3Qettd2VKZZLljFkSv+7XhYx5VS/UPTs/GJwVWS6U27bdqHlA YjSmCHLPKmsREg/DsV8qRb2xBjqhd1ysmFcFfKV/GYY174EOLdUwpI//2Dvg/2BduPyX yHfh0rQixpN0TbCKdgm2XkPzsIbhYZjt9jwwl25AEF9YBpl07BAwxEk2Xs+kD/ZmuTi0 X7LFAiuweK3K267QAfTcz1bVA33j+30hkVkziPQ+Imxh7Op3IJmHifuTsDH63UGhOdhK Re2A== X-Gm-Message-State: AOJu0Yw76eWvNw/R3IEUsCCMz5q8zXZL6roPKzZsbSdktmOkLjYtSAlq W/xNjibMjxPbGgBNIbemXyK4t/bABusvuKwzBRcUE9g6anwsabKn/B9m8B+7f4k= X-Received: by 2002:a05:6402:440a:b0:57d:1d9e:d1fe with SMTP id 4fb4d7f45d1cf-5865c1f6e88mr1438298a12.9.1719578584324; Fri, 28 Jun 2024 05:43:04 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861381756esm988562a12.56.2024.06.28.05.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 05:43:03 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A04135FA12; Fri, 28 Jun 2024 13:42:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Beraldo Leal , Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , Wainer dos Santos Moschetta , qemu-arm@nongnu.org, Peter Xu , Mads Ynddal , Mahmoud Mandour , Pierrick Bouvier , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , Stefan Hajnoczi , Peter Maydell , Richard Henderson , Thomas Huth Subject: [PATCH 07/23] test/plugin: make insn plugin less noisy by default Date: Fri, 28 Jun 2024 13:42:42 +0100 Message-Id: <20240628124258.832466-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240628124258.832466-1-alex.bennee@linaro.org> References: <20240628124258.832466-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org While the match functionality is useful lets make the verbosity optional while we are actually running. Signed-off-by: Alex Bennée --- tests/plugin/insn.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 5e0aa03223..524f9ddde8 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -20,6 +20,7 @@ static qemu_plugin_u64 insn_count; static bool do_inline; static bool do_size; +static bool do_trace; static GArray *sizes; typedef struct { @@ -73,30 +74,30 @@ static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *udata) MatchCount *match = qemu_plugin_scoreboard_find(insn_match->counts, cpu_index); - g_autoptr(GString) ts = g_string_new(""); - insn->hits++; - g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", - insn->vaddr, insn->disas, insn->hits); uint64_t icount = qemu_plugin_u64_get(insn_count, cpu_index); uint64_t delta = icount - match->last_hit; match->hits++; match->total_delta += delta; - - g_string_append_printf(ts, - " , cpu %u," - " %"PRId64" match hits," - " Δ+%"PRId64 " since last match," - " %"PRId64 " avg insns/match\n", - cpu_index, - match->hits, delta, - match->total_delta / match->hits); - match->last_hit = icount; - qemu_plugin_outs(ts->str); + if (do_trace) { + g_autoptr(GString) ts = g_string_new(""); + g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", + insn->vaddr, insn->disas, insn->hits); + g_string_append_printf(ts, + " , cpu %u," + " %"PRId64" match hits," + " Δ+%"PRId64 " since last match," + " %"PRId64 " avg insns/match\n", + cpu_index, + match->hits, delta, + match->total_delta / match->hits); + + qemu_plugin_outs(ts->str); + } } static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -216,6 +217,11 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } else if (g_strcmp0(tokens[0], "match") == 0) { parse_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "trace") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_trace)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1;