From nobody Sat Sep 21 07:49:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704983168; cv=none; d=zohomail.com; s=zohoarc; b=XTMYT208E/C4L5Hixpjr/cHSSsr+PbFkLwm8lgqgjaRjZWiXTidLoMhlxzDZ2m4kZtPUzPaxnX/MZ7Yso6cBdGFq+ItQClKSaO33d0YT2SgIBv6oUcD4FBb2dZTBYZAJlfRKYRjUCU5/fUJgsxphsbSfVbTQ/zvRqwIC1+ejYm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704983168; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8ZO5SKzeIPzFy5xT17BpWpFDUdZJfOe9VoGxrmodP4k=; b=PzMdJ2yFQyqPX8FIfPzVPqXX6TG1siGlyCWrA+jgR3NYc+zh5BTYJOiHb2plzYT7Q3UIPDNr6Gc6iby0RuFOFRaZrABprkR3ecS51GJ6NFYCmo5/r1al7l85EcnaAz10/+clrGwLk1OrII4mk5CyabW0JCfVgsJzRvQM92xL0MI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704983168597940.5319956446009; Thu, 11 Jan 2024 06:26:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNvyt-0004UK-VB; Thu, 11 Jan 2024 09:24:27 -0500 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 1rNvyl-0004Q2-Ib for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:20 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyh-0002lF-8F for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:17 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-336897b6bd6so5067136f8f.2 for ; Thu, 11 Jan 2024 06:24:12 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983050; x=1705587850; 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=8ZO5SKzeIPzFy5xT17BpWpFDUdZJfOe9VoGxrmodP4k=; b=gH8qm+1uRwTu1hinB1nS2dyaevmEh3hXNsHgVzyh0R/NAt8n3ssN6VxX0I3ysmbGQD Z9P+OQwh6Zvq8nOq5rIWJQEepIcE6mTsSx/Y6g70QjXzaK4N2hzuYMla5znxYF/qrLKM EiGIatKzNX1uPJTURw869fAyt3Z1vF17vBlhpSYvpSYqhMfwYnP+40qtSiay6OpJl4+i UOSONm1ufnDY8kMSI3MreazzODI9CdyH2xQauAJvbgTTXMUq9v9H2o2bznDOze9He1DG DHrbT7D8ltMO/ppM0OckxktPM8hG1nstCzp0i7O+Bgma8YXPsolWgNJf1ZzoJN0NxC5M NOEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983050; x=1705587850; 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=8ZO5SKzeIPzFy5xT17BpWpFDUdZJfOe9VoGxrmodP4k=; b=tF5muU/Pg7SXS4YUPBshu7vAzT7jTqwA86Wm23ameZp68T+8ekvu0oODqV1jHPM71R lOnpRAlBlfp7sae9gIiI9ViV9NCYOQxrXZrz+P5HRRFiyTbSn2iXEFXw2zhuTMrVGnXV ssBjXaZe8St+6pjEhSGv4UWdRUAdARxckreBu8yapPloehZ4SjBaZ3sJfYzbJnWqoBvF OdJYhNxnxDQgPk1BEIzpWpmAT8ZhG6JbqzJqBc/Fh3kfaIblJXL0BFOUVd0ejm39ZF6x uPa1gpDAnwliqjeAHDCRjQLv8UW7o/MUBfWuMC55tdz/tXEbt7nefhypgxS6yE9bixbR yTLA== X-Gm-Message-State: AOJu0YzFBN9RhJ06/QrY8C5euB4QfkAIz/7ymDZTUf29bDRUSjz9FuwS ZII8/NFX6dH3P0bRo5gMPsZxkqgIn2hZcfuvf6+AF8yjUF+TIQ== X-Google-Smtp-Source: AGHT+IHAwaDo1QprEHcY4Gs7xzhHvdVLPO99Qss3H52sVwUJy51FoudvHw0i15WLH6jlYeklsM7YwA== X-Received: by 2002:a5d:490a:0:b0:337:3f72:3de2 with SMTP id x10-20020a5d490a000000b003373f723de2mr641930wrq.36.1704983050508; Thu, 11 Jan 2024 06:24:10 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 10/12] contrib/plugins/howvec: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:23 +0400 Message-ID: <20240111142326.1743444-11-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111142326.1743444-1-pierrick.bouvier@linaro.org> References: <20240111142326.1743444-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704983170172100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- contrib/plugins/howvec.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 644a7856bb2..46230a43927 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -22,8 +22,18 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 +#define MAX_CPUS 8 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) =20 +static uint64_t count(uint64_t *arr) +{ + uint64_t res =3D 0; + for (int i =3D 0; i < MAX_CPUS; ++i) { + res +=3D arr[i]; + } + return res; +} + typedef enum { COUNT_CLASS, COUNT_INDIVIDUAL, @@ -43,13 +53,13 @@ typedef struct { uint32_t mask; uint32_t pattern; CountType what; - uint64_t count; + uint64_t count[MAX_CPUS]; } InsnClassExecCount; =20 typedef struct { char *insn; uint32_t opcode; - uint64_t count; + uint64_t count[MAX_CPUS]; InsnClassExecCount *class; } InsnExecCount; =20 @@ -159,7 +169,7 @@ static gint cmp_exec_count(gconstpointer a, gconstpoint= er b) { InsnExecCount *ea =3D (InsnExecCount *) a; InsnExecCount *eb =3D (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + return count(ea->count) > count(eb->count) ? -1 : 1; } =20 static void free_record(gpointer data) @@ -180,11 +190,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class =3D &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + if (count(class->count) || verbose) { g_string_append_printf(report, "Class: %-24s\t(%" PRId64 " hits)\n= ", class->class, - class->count); + count(class->count)); } break; case COUNT_INDIVIDUAL: @@ -212,7 +222,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "Instr: %-24s\t(%" PRId64 " hits)" "\t(op=3D0x%08x/%s)\n", rec->insn, - rec->count, + count(rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised"); @@ -233,7 +243,7 @@ static void plugin_init(void) static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { uint64_t *count =3D (uint64_t *) udata; - (*count)++; + count[cpu_index]++; } =20 static uint64_t *find_counter(struct qemu_plugin_insn *insn) @@ -265,7 +275,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *= insn) case COUNT_NONE: return NULL; case COUNT_CLASS: - return &class->count; + return class->count; case COUNT_INDIVIDUAL: { InsnExecCount *icount; @@ -285,7 +295,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *= insn) } g_mutex_unlock(&lock); =20 - return &icount->count; + return icount->count; } default: g_assert_not_reached(); @@ -306,8 +316,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) =20 if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + cnt, sizeof(uint64_t), 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, c= nt); --=20 2.43.0