From patchwork Thu Jan 11 14:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761851 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422706wrz; Thu, 11 Jan 2024 06:25:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDlcghy0/2Py8tz/Bi+ajDTmmK6KgnwgtETW5u85T6Er1ptjDSln23PZqJhBaHA34370dX X-Received: by 2002:a05:622a:49:b0:429:8b1c:cdcc with SMTP id y9-20020a05622a004900b004298b1ccdccmr626897qtw.118.1704983131535; Thu, 11 Jan 2024 06:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983131; cv=none; d=google.com; s=arc-20160816; b=DIW5TP0lTRffcreZ8A2ovqrjaYqKYM0ndCKOiq2MK8Pgn5kVLOd9oytx+tdrQ10JyY vvCKwZADGXT0j4ySR4OqKLO3yQGcFTnwdPUdaxKkKlBelCb1wKWP29+MyPouwuefIFn+ lmPylf9dL2mKPIl330uWzqeH2quawyMXNJiCb60fclFjQe0uKtTZXxWbi54XtK0GMt/r A1Z/kYS0QqJggi/8iWqA//cZeXnl7KobXBsNMZkxfsJsVYrMp6bCZR+cWk65JcQO637S MsLG2OzBqsz76YD9kgKFelCy3Fzrwp+/djFtVhEjFuqDrxISvFeBwACRcqkvWSygFfux Rupw== 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=IJ7j1cDsI/uXWEkCQ4Id/bagXB6Y2gY5m1Du+N1BU48=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=d9q6mdK0ZDT0R6m5hcUQbqJkwoeP0wudcLe6lzkVws3NrDuzlGXaERRziryXeXserw K2BAHxqsEvN6/kmqUH0AH5GZ7mhMskfYxT+XH7n2FUlAhwQhvEdKnWEhZeguI6BT1Oht C7sCiCVnyv51tO98nxzRxP2Oo0/4gxfNON0CmWSvm7l40CDdYC3jE/TYzwmXq9P1nSep KBBwe7uh+ngwOHn1qv//HTSUoeHzCEASEZlZ+tZXvKjWbXJ/69xV4d/GDXAVh45s0lO5 LjwBZYaHclAdZQv49AL0/G57VJLt84ArL1cWkGUChn/DuUcl/LLBknl9Muyot+nBgIe4 fg0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qe6Nl1d2; 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 u4-20020a05622a198400b00429bcc07136si1045422qtc.71.2024.01.11.06.25.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:31 -0800 (PST) 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=Qe6Nl1d2; 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 1rNvyR-0004LB-Bk; Thu, 11 Jan 2024 09:23:59 -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 1rNvyO-0004KX-4y for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:23:56 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyG-0002Iq-Sb for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:23:52 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3368ac0f74dso3746580f8f.0 for ; Thu, 11 Jan 2024 06:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983024; x=1705587824; 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=IJ7j1cDsI/uXWEkCQ4Id/bagXB6Y2gY5m1Du+N1BU48=; b=Qe6Nl1d2T0CXnGKGDLyVVf4YGDSlyjhfHRLj8h2nPeXFtfd4tLawDdqJNqmgoLB/kw RV/pNUfs3jLKbvUu1Wqk3x3y05J5iUBWLngcihxN9FPxsjt6JQnUovMS6Fp72MWUfGkM PL/e85f25fQRsXWfQ3SWAe2W/2i7yIAjDZh7Xc7607oanP3y0ZAifiuv8sm5u2v2RyJP y6vh/063zJd2QhSCrgNAd7ZQln/FYl1RJ245mctYMUremxlgDhFWcROYZQcqiLErQzae Z3NEfNNo8fqdbq5QUFdYB5f9A6jjWMaxx5OZ2MhkE+ZnSaglm4Z6A1D9TN5kC9KOoAKe pqZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983024; x=1705587824; 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=IJ7j1cDsI/uXWEkCQ4Id/bagXB6Y2gY5m1Du+N1BU48=; b=xLOH2k5vhALY/JMlqRkG1Zsb0cq8WrYBbRNyEstveIRbV3rlHw1w8TRKC84whFT4n7 rdKctalPY0jFnIu3AoqfF12K4JzeWMiz+QAnrAvRDSMDsYSrCbO4i5+wgCgiZp5Effpa o4x+T+mVO+s4Vg3aQ/RW4oSP9+VYd7CsJxAcixDM9KF0zWMctbIr3KYOuhEofvFpEDBY /UQEhwfslDueXm8HYDyfGcBESQ5i3p88QjJBpGX+enutUwcGaje+++o79oxB38UC0tvr T+zOMdJpEygU+ORAesNolQXMWILFY/o8ciRFtn8KQPArgHFY8UXfuRESU64j/KuCAP47 lZFw== X-Gm-Message-State: AOJu0Yx7Ih7E3KAxv9e1nv50TKDDOBWDJm9y4qOmumHUXhSfziJ7mhJv WdM6YcdRrA10/uyjlePWQPnyDUG2T9nHrHFSJvwyYq0PNrCPtA== X-Received: by 2002:a5d:480b:0:b0:337:62d3:f68a with SMTP id l11-20020a5d480b000000b0033762d3f68amr690624wrq.81.1704983024567; Thu, 11 Jan 2024 06:23:44 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:43 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 01/12] plugins: implement inline operation with cpu_index offset Date: Thu, 11 Jan 2024 18:23:14 +0400 Message-ID: <20240111142326.1743444-2-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 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x432.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of working on a fixed memory location, allow to index it based on cpu_index and a given offset (ptr + cpu_index * offset). Current semantic is not modified as we use a 0 offset, thus inline operation still targets always the same memory location. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- accel/tcg/plugin-gen.c | 60 +++++++++++++++++++++++++++++++++++------- include/qemu/plugin.h | 1 + plugins/api.c | 7 ++--- plugins/core.c | 11 +++++--- plugins/plugin.h | 5 ++-- 5 files changed, 65 insertions(+), 19 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 78b331b2510..fc9d3ee23bc 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -118,16 +118,28 @@ static void gen_empty_udata_cb(void) */ static void gen_empty_inline_cb(void) { + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr(); TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + /* pass an immediate != 0 so that it doesn't get optimized away */ + tcg_gen_muli_i32(cpu_index, cpu_index, 0xdeadbeef); + tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); + tcg_gen_movi_ptr(ptr, 0); + tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); tcg_gen_ld_i64(val, ptr, 0); /* pass an immediate != 0 so that it doesn't get optimized away */ tcg_gen_addi_i64(val, val, 0xdeadface); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_ptr(ptr); tcg_temp_free_i64(val); + tcg_temp_free_ptr(cpu_index_as_ptr); + tcg_temp_free_i32(cpu_index); } static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -274,12 +286,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) return op; } +static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) +{ + return copy_op(begin_op, op, INDEX_op_ld_i32); +} + +static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_ext_i32_i64); + } + return op; +} + +static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) { if (TCG_TARGET_REG_BITS == 32) { /* 2x ld_i32 */ - op = copy_op(begin_op, op, INDEX_op_ld_i32); - op = copy_op(begin_op, op, INDEX_op_ld_i32); + op = copy_ld_i32(begin_op, op); + op = copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op = copy_op(begin_op, op, INDEX_op_ld_i64); @@ -315,6 +352,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) return op; } +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op = copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] = tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX == UINT32_MAX) { @@ -380,18 +424,14 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ + op = copy_ld_i32(&begin_op, op); + op = copy_mul_i32(&begin_op, op, cb->userp_offset); + op = copy_ext_i32_ptr(&begin_op, op); op = copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + op = copy_add_ptr(&begin_op, op); op = copy_ld_i64(&begin_op, op); - - /* add_i64 */ op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op = copy_st_i64(&begin_op, op); - return op; } diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 7fdc3a4849f..4548affc295 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -85,6 +85,7 @@ enum plugin_dyn_cb_subtype { struct qemu_plugin_dyn_cb { union qemu_plugin_cb_sig f; void *userp; + size_t userp_offset; enum plugin_dyn_cb_subtype type; /* @rw applies to mem callbacks only (both regular and inline) */ enum qemu_plugin_mem_rw rw; diff --git a/plugins/api.c b/plugins/api.c index 5521b0ad36c..0fcce825680 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -99,7 +99,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, void *ptr, uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, imm); + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, ptr, 0, imm); } } @@ -120,7 +121,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, { if (!insn->mem_only) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - 0, op, ptr, imm); + 0, op, ptr, 0, imm); } } @@ -145,7 +146,7 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, imm); + rw, op, ptr, 0, imm); } void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, diff --git a/plugins/core.c b/plugins/core.c index 49588285dd0..cc6d7720b1f 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -280,13 +280,15 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, size_t offset, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = ptr; + dyn_cb->userp_offset = offset; dyn_cb->type = PLUGIN_CB_INLINE; dyn_cb->rw = rw; dyn_cb->inline_insn.op = op; @@ -431,9 +433,10 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } -void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - uint64_t *val = cb->userp; + const size_t offset = cpu_index * cb->userp_offset; + uint64_t *val = (uint64_t *)((char *) cb->userp + offset); switch (cb->inline_insn.op) { case QEMU_PLUGIN_INLINE_ADD_U64: @@ -466,7 +469,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE: - exec_inline_op(cb); + exec_inline_op(cb, cpu->cpu_index); break; default: g_assert_not_reached(); diff --git a/plugins/plugin.h b/plugins/plugin.h index 5eb2fdbc85e..e597ef3c30e 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -66,7 +66,8 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, size_t offset, uint64_t imm); void plugin_reset_uninstall(qemu_plugin_id_t id, @@ -95,6 +96,6 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); #endif /* PLUGIN_H */ From patchwork Thu Jan 11 14:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761849 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422542wrz; Thu, 11 Jan 2024 06:25:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8XXaGpm9AhJ2UG5d5qw/9AZKVnnbUZsvC2t6+m3USnRgtgu3E/njbYrH9gBrtCRiZbatv X-Received: by 2002:a05:6808:10c5:b0:3bd:53c7:988e with SMTP id s5-20020a05680810c500b003bd53c7988emr1217661ois.105.1704983111784; Thu, 11 Jan 2024 06:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983111; cv=none; d=google.com; s=arc-20160816; b=xckEDAKo6VvMwmtNZ603MyIJF+7bU73Zpy+Hu+IOnMPmXahXyy1BDuuKP/tpv/NP4F 89XTpLNy1T/RQAfgbiKhXEnAsTXJ5SAFY5yM3w0LqIEizn8lOx/EvVNehrP5SM4jCHgq QOHlPwCtk+t7EcNnVTapIKwbV3nB6Oh54pDIAMLDCENRP470mBmp1XJ0dAqaQUStlVLx GSc6nBICOJeF+u8nZDIK1EQ4R/ufLL6KvpQukUe9T54Kti/Anc7Lhtk8TXPT5yS26ANK sVI1rerhMIG3AW80b2JM6icVn2o76BQifSDWXUy8Vu9QTZeJvy0ut42abnCk01x6W+ZZ tFOg== 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=9c37JOuaNhDBeKaXx4tgumlULh1m5+dxPGdg6049b/w=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=bJPw1HFdJrg8yhlcoWskdPmWJkCxz8ORUBtfEq0KUXM5v+7B6NXasUZ0PjOBudyM6l J4X6WHcnoW7iI47R6knC5NeKWJec9AxW1Jd3V6FHWs5YZsUP1hvAS/V9Ld4k3y0tnGUP bvBnF/VmjtXeahr2fkpNZLrNnusGOAPNSwb6R6zFrLD3weYCEcXL1g/1vxNJztnJd+Ww Fe9LQYGj/TAw7Z3SLFFi4Sc9DWYMpFRs3kMAEnAEzFMPrtd2mxcCzeYWsIKZPEq40/D1 tSbWuUdEuPiyVKCDFqNulz0tafArXog+yg7buCGXAY5z8zTLujQUq/yfcRKEQroq+oZl bjmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FkwwlSjz; 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 v5-20020a0ce1c5000000b0067f95d02028si882756qvl.248.2024.01.11.06.25.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:11 -0800 (PST) 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=FkwwlSjz; 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 1rNvyW-0004Mv-Jm; Thu, 11 Jan 2024 09:24:04 -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 1rNvyR-0004LP-Jo for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:00 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyJ-0002Je-I7 for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:23:57 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3376555b756so3138564f8f.0 for ; Thu, 11 Jan 2024 06:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983027; x=1705587827; 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=9c37JOuaNhDBeKaXx4tgumlULh1m5+dxPGdg6049b/w=; b=FkwwlSjzBenwbfpkxNVcPtlIrh37eXa7GUBIe7cEwSi4tBh6CQ5BlwVojTq4Gv/Y6X W+Q4R3BOH2VUbI7pv54SgRnQTgP+jSpIzU7G8RkbQ7v/Fnw938Y16Gac5Q6f0pdlc+4i ShX8NvTyQYYOj/x190hSr+rWMjKGs0No59tErrYNsuLC9UKBLRRn4Aj7WmEDQtwu1cPT c1qEm/OgDz//CCXUyhnu6vrK6fx/J9dl6ZhOtPYZg9FdgQDrb10nkhZ0aYiPh/0D1od/ xigRQdNlBCTxb/Gj8hRy5hdJ06KcSeibUvDx9k3YjqxQLYJiozry5oXqb8Y31uGPseFj uhWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983027; x=1705587827; 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=9c37JOuaNhDBeKaXx4tgumlULh1m5+dxPGdg6049b/w=; b=t3z9vuFDbJ5MvnahYk8QO3OUU8/2ZS5cHxwF/p/PUU4Cm6uprUSPc6rf82dZaBSpsa CIn8dn8Hve14XS/agmjCluHNoB8U7X5t5NhySR7duNpqZs//I+ELDB03HsBYHo+8sgr8 P23yqwZSb/VU/5OG43B3S6f7scgImqbvlfRjsrx6uq8A7q2xAS+iqKtjklIxC99DE1uN VCqlCb/QGeLDx1wc3/yMOzJt+tfdtaT0tBFob8eiegI7zXLm+4LIObgnrQFqywqv+5ce bgXVgcJfV9bV3q84EuFxm8d8g+YfnWGoPuwPAzV14aytwaqSbJHPWKuB+JVIufA2joiZ Pdrg== X-Gm-Message-State: AOJu0YyzPHkrRPBiBDPtiou71Y8GCpwFXyiX50lL70WPx22HDq/pxPaQ rUyHvFpItP9/ofwfYyK273taBWaASf9zm/nJ0200R5Xulv5Qrg== X-Received: by 2002:adf:f811:0:b0:337:6208:99df with SMTP id s17-20020adff811000000b00337620899dfmr610967wrp.20.1704983027314; Thu, 11 Jan 2024 06:23:47 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:47 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 02/12] plugins: add inline operation per vcpu Date: Thu, 11 Jan 2024 18:23:15 +0400 Message-ID: <20240111142326.1743444-3-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 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Compared to non per_vcpu versions, ptr is now a base, and current cpu_index and an offset are used to compute memory location on which operation happens (ptr + cpu_index * offset). This allows to have a thread-safe version of inline operations. Having a flexible offset is useful in case a user wants to target a memory location embedded into a struct. In this case, the offset between two memory locations will be bigger than sizeof(uint64_t). Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/qemu-plugin.h | 56 +++++++++++++++++++++++++++++++++++- plugins/api.c | 36 ++++++++++++++++++++--- plugins/qemu-plugins.symbols | 3 ++ 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 4daab6efd29..8a0691a760e 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -312,6 +312,25 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); +/** + * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @ptr: point to memory location for the op + * @offset: offset between two memory locations + * @imm: the op data (e.g. 1) + * + * Insert an inline op, on a memory location associated to a given + * vcpu (whose address is ptr + offset * cpu_index), + * every time a translated unit executes. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm); + /** * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -342,6 +361,23 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @ptr: point to array of memory locations for the op + * @offset: offset between two memory locations + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time an instruction executes. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm); + /** * qemu_plugin_tb_n_insns() - query helper for number of insns in TB * @tb: opaque handle to TB passed to callback @@ -567,7 +603,25 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @ptr: point to array of memory locations for the op + * @offset: offset between two memory locations + * @imm: immediate data for @op + * + * This registers a inline op every memory access generated by the + * instruction. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm); typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, diff --git a/plugins/api.c b/plugins/api.c index 0fcce825680..fd6ce678501 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -97,10 +97,19 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm) +{ + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(tb, op, ptr, 0, imm); +} + +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm) { if (!tb->mem_only) { plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, ptr, 0, imm); + 0, op, ptr, offset, imm); } } @@ -118,10 +127,19 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm) +{ + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, op, ptr, 0, imm); +} + +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm) { if (!insn->mem_only) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - 0, op, ptr, 0, imm); + 0, op, ptr, offset, imm); } } @@ -137,16 +155,26 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], - cb, flags, rw, udata); + cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, void *ptr, uint64_t imm) +{ + qemu_plugin_register_vcpu_mem_inline_per_vcpu(insn, rw, op, ptr, 0, imm); +} + +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + void *ptr, size_t offset, + uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, 0, imm); + rw, op, ptr, offset, imm); } void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 71f6c90549d..56ba30e5a81 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -27,13 +27,16 @@ qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; qemu_plugin_start_code; From patchwork Thu Jan 11 14:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761846 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422468wrz; Thu, 11 Jan 2024 06:25:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdNJhYRIKx5ADYd7RKNokKPTYBKXF9+2Y0ZRsFwJCHVtFt1akoXUUZQgt1KbbXb5GRwsoL X-Received: by 2002:a05:620a:4445:b0:783:23ca:8e21 with SMTP id w5-20020a05620a444500b0078323ca8e21mr1235579qkp.3.1704983100276; Thu, 11 Jan 2024 06:25:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983100; cv=none; d=google.com; s=arc-20160816; b=zKdJjKp2lxGlANOGeTfx63ei8/QHDD+bmFBbesrlUl6cU/FX2dvpfpcz4Vkbp50Ord aQXiljI0S8BYdVcYy3ZbCA/okzVUkVnplYK/IVb6CoqN/icGQmjPocT27VdkoGLRc5oG LRw0fzupB1GU4W9MYDbgQAs0sWDnfzMx6eHH3tge25z4/oozLqbw0Nc0C6XXs7jhHK5V knlGYMpgi4jaHqiBV61L9Ue4pfqU5ItX22QIMEMYOAWUlyvMxo4Dz35vYteLATqhp6o0 jLm26JJXgObJcQqilg/rhgtCK4SKQYDs755UquBacW+AZ65jdm4gor5A3BPasdLHIitF 2ToQ== 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=Uz8JV8pCaZV1R2zPKE6qluGGJZ0UQ4yZCw51RxB81hM=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=uU3bPYmIDNgm8rDZBDyIDLa7xuwu41HGMpbE+V2UraPjuQ/yZcSBiY4Asj9+BAgVpu vAwvVs8auIZUAjRDnvBQUrRjjNROdNg1nMIT++097e4IwGRVoGM4Jq0Qax+/cm59McYR 4i2w3HIx7K13HvCkfv9KV0g1UcCmpOA6vsq0ElvPh6EWpiNaO0o8KffKveFWXg+OtlVl uJLrod/TfdcnA90NWlpa39aaa3/b1NdQmkdYItWYyCqpRv/62lSWz8J4SqonNRVXoRcT yNlc0Vq3NMvDp4ZC4PQEG6dSv7sepLD6bqFEfrj6TFyWZ0jc4vPosMvRHj+sexxGIK1m Jstg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z8Fd4pSP; 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 ay36-20020a05620a17a400b0078331c5e3b6si1031283qkb.231.2024.01.11.06.25.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:00 -0800 (PST) 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=z8Fd4pSP; 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 1rNvyU-0004M3-NE; Thu, 11 Jan 2024 09:24:02 -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 1rNvyR-0004LQ-Jh for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:00 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyL-0002OV-QO for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:23:59 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3373bc6d625so4635703f8f.3 for ; Thu, 11 Jan 2024 06:23:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983030; x=1705587830; 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=Uz8JV8pCaZV1R2zPKE6qluGGJZ0UQ4yZCw51RxB81hM=; b=z8Fd4pSPGJDC7q+zO7bfmdtfnLXCPrj2PV4yhL7WThdkjyI4h01oN+OZdTyyTZU8fZ 1W7eBh85Rj7Rf2rv68Tw4SkzpGTPuaM1BMAP0gR+Cd8F8bd7txxSdbwjMmbfxrozJNge PoEc8TwWlEvt6wsY+oYnt/YNerPueAVXJrEE48J5J06QB5gorFBWTDVVEwIDxYWVCi+p 4ZnaQXxWhA6erbO0ahqvDRonXi/8MIiQMRTJl00mh42S+/ntBKi4vOkvEk1hHV3vVkF2 J7li879BI6SZNg9AYsqIgz/wqAe+vRecLVT9OVT7NGEYyiobMDF6OCuf/RQMHuxOWu0q Bgiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983030; x=1705587830; 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=Uz8JV8pCaZV1R2zPKE6qluGGJZ0UQ4yZCw51RxB81hM=; b=mwvRlZXpJnsU/M8j1KVcbs8P54IjTwfMDaNhmcDby/CNuvQWulfJJTxYwbFCYDXZVA +jAxrLuEM5NVLwT6RTTSxCOiv1wFmQXreanp6kpSYL3DYOL1DPw3BIG0/QE69TVjfc5M PMd307JjSIGGAvug97BNv1ost73TTilejvhmqDleRPTHOMpgbAq0Hzm0LiWqL+XHlnit PscJOEad5q2MT/eX5HSOuA/EYWXq5zkJ5Ae20iC4xdcv55NP3W3Xjcnl/R+KXBxky+yy OLHF6o+BuZh02WQd6uO766vNujIyfmeXO0j5Wqn9lEHRoDvPGVR6zd0KhmwFuqQns/pn yREg== X-Gm-Message-State: AOJu0Yyj9pou2drFFn0QYPbYS9gzL1qLoS+hO/rOBTEeItWIVy6VUXxJ KnRNChnOIZXRR+gE6LcJ9DhVeEQPlQw1fr/sb2UHVokLri2PPw== X-Received: by 2002:a5d:4449:0:b0:336:96d:475c with SMTP id x9-20020a5d4449000000b00336096d475cmr758971wrr.5.1704983030205; Thu, 11 Jan 2024 06:23:50 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:49 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 03/12] tests/plugin: add test plugin for inline operations Date: Thu, 11 Jan 2024 18:23:16 +0400 Message-ID: <20240111142326.1743444-4-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 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added. Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one. Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 183 +++++++++++++++++++++++++++++++++++++++ tests/plugin/meson.build | 2 +- 2 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 tests/plugin/inline.c diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c new file mode 100644 index 00000000000..6114ebca545 --- /dev/null +++ b/tests/plugin/inline.c @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2023, Pierrick Bouvier + * + * Demonstrates and tests usage of inline ops. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include + +#include + +#define MAX_CPUS 8 + +static uint64_t count_tb; +static uint64_t count_tb_per_vcpu[MAX_CPUS]; +static uint64_t count_tb_inline_per_vcpu[MAX_CPUS]; +static uint64_t count_tb_inline_racy; +static uint64_t count_insn; +static uint64_t count_insn_per_vcpu[MAX_CPUS]; +static uint64_t count_insn_inline_per_vcpu[MAX_CPUS]; +static uint64_t count_insn_inline_racy; +static uint64_t count_mem; +static uint64_t count_mem_per_vcpu[MAX_CPUS]; +static uint64_t count_mem_inline_per_vcpu[MAX_CPUS]; +static uint64_t count_mem_inline_racy; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +static uint64_t collect_per_vcpu(uint64_t *values) +{ + uint64_t count = 0; + for (int i = 0; i < MAX_CPUS; ++i) { + count += values[i]; + } + return count; +} + +static void stats_insn(void) +{ + const uint64_t expected = count_insn; + const uint64_t per_vcpu = collect_per_vcpu(count_insn_per_vcpu); + const uint64_t inl_per_vcpu = collect_per_vcpu(count_insn_inline_per_vcpu); + printf("insn: %" PRIu64 "\n", expected); + printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + printf("insn: %" PRIu64 " (inline racy)\n", count_insn_inline_racy); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); + g_assert(count_insn_inline_racy <= expected); +} + +static void stats_tb(void) +{ + const uint64_t expected = count_tb; + const uint64_t per_vcpu = collect_per_vcpu(count_tb_per_vcpu); + const uint64_t inl_per_vcpu = collect_per_vcpu(count_tb_inline_per_vcpu); + printf("tb: %" PRIu64 "\n", expected); + printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + printf("tb: %" PRIu64 " (inline racy)\n", count_tb_inline_racy); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); + g_assert(count_tb_inline_racy <= expected); +} + +static void stats_mem(void) +{ + const uint64_t expected = count_mem; + const uint64_t per_vcpu = collect_per_vcpu(count_mem_per_vcpu); + const uint64_t inl_per_vcpu = collect_per_vcpu(count_mem_inline_per_vcpu); + printf("mem: %" PRIu64 "\n", expected); + printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + printf("mem: %" PRIu64 " (inline racy)\n", count_mem_inline_racy); + g_assert(expected > 0); + g_assert(per_vcpu == expected); + g_assert(inl_per_vcpu == expected); + g_assert(count_mem_inline_racy <= expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + for (int i = 0; i < MAX_CPUS; ++i) { + const uint64_t tb = count_tb_per_vcpu[i]; + const uint64_t tb_inline = count_tb_inline_per_vcpu[i]; + const uint64_t insn = count_insn_per_vcpu[i]; + const uint64_t insn_inline = count_insn_inline_per_vcpu[i]; + const uint64_t mem = count_mem_per_vcpu[i]; + const uint64_t mem_inline = count_mem_inline_per_vcpu[i]; + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " + "insn (%" PRIu64 ", %" PRIu64 ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + g_assert(tb == tb_inline); + g_assert(insn == insn_inline); + g_assert(mem == mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + count_tb_per_vcpu[cpu_index]++; + g_mutex_lock(&tb_lock); + count_tb++; + g_mutex_unlock(&tb_lock); +} + +static void vcpu_insn_exec(unsigned int cpu_index, void *udata) +{ + count_insn_per_vcpu[cpu_index]++; + g_mutex_lock(&insn_lock); + count_insn++; + g_mutex_unlock(&insn_lock); +} + +static void vcpu_mem_access(unsigned int cpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, + void *userdata) +{ + count_mem_per_vcpu[cpu_index]++; + g_mutex_lock(&mem_lock); + count_mem++; + g_mutex_unlock(&mem_lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &count_tb_inline_racy, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + count_tb_inline_per_vcpu, sizeof(uint64_t), 1); + + for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, + QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + &count_insn_inline_racy, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + count_insn_inline_per_vcpu, sizeof(uint64_t), 1); + qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, + QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_MEM_RW, 0); + qemu_plugin_register_vcpu_mem_inline(insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + &count_mem_inline_racy, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + count_mem_inline_per_vcpu, sizeof(uint64_t), 1); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + g_assert(info->system.smp_vcpus <= MAX_CPUS); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index e18183aaeda..9eece5bab51 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,6 +1,6 @@ t = [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os == 'windows' t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', include_directories: '../../include/qemu', From patchwork Thu Jan 11 14:23:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761850 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422612wrz; Thu, 11 Jan 2024 06:25:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHep9oc4G9t5+hi0D37qwCshlnQ0A2XWaKIcRiff6YUydN12RMqMryKc/oStS/VTqLYcmLC X-Received: by 2002:a0c:dd0a:0:b0:680:b789:97d8 with SMTP id u10-20020a0cdd0a000000b00680b78997d8mr1002924qvk.126.1704983118799; Thu, 11 Jan 2024 06:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983118; cv=none; d=google.com; s=arc-20160816; b=Twh7tzfWWXaYDea9ol8d06YcKjR8JvC+/eQmFalZJNpBv1XPfA+ci/siK6pAqFVeix F/4/hAtWEDIXz96m4MV4bIF1uYtIOlc8HQ3gfXy7Guo/JpkVoImPC1pnOPfnHh91Y4I2 IK1BwMV1e4iMM/NzLBKzBOS0n21Zp727SzS/5RBaRKtHIx/2kD9L9RxHgpMQDAI4e/il HqiTWDEhXpvjs7XHbVnETkU5B1rebUwi0IbjAZZj2iQRbZehMJ4IuiDrktUeVr13U5Mn 2jvvEY6G5k4+eaHCLnXdSa76ZY9XniGda+6+SW9ocvYiACot4S5y0dLFXQbVVkEUDwju HVvg== 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=xFv6E5kkXfIGfEX1pT8iilVpb1LB0Hjh6FDK0KUik1o=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=HGhH2Pr8swWdOSUFNXHkB5UvDlel14HpujsFNULaY/lRsAVhnARHcy1vL7TglPoMXA R6SKtRSQphzhGP4ghkWpiItn4jY1wsJWI27t/5BhgiwK2ka5x2d2roujb6J5fwA11lLi TJgO1mOvgptpCLn1EzikDyv+YrO/dmIGn2AHSWbenOAVMc58hpnISCPrqdpRk+uKvFH7 L9381LHQx7uXVA58DCC2ge2KjxdesNLjQFar8QzrrYczKoucZX08x0MmPrmaKK9KtxC9 IuUMJB+BMbOZaQvU6n3YmJa0a9o0detEni3iWOwhDjSZIx0kqvSpYHj3bPiY1zqMHhZB osgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GMitChlb; 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 p10-20020a0ce18a000000b006803463703bsi878824qvl.129.2024.01.11.06.25.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:18 -0800 (PST) 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=GMitChlb; 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 1rNvyV-0004Mb-Dz; Thu, 11 Jan 2024 09:24:03 -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 1rNvyR-0004LR-Jx for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:00 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyN-0002QX-FI for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:23:59 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3367a304091so4690002f8f.3 for ; Thu, 11 Jan 2024 06:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983033; x=1705587833; 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=xFv6E5kkXfIGfEX1pT8iilVpb1LB0Hjh6FDK0KUik1o=; b=GMitChlbw9fHcIenm3QtyIOZdslthxohFULnifPccdh6uFrGzVJBz2Q7Gt1HDX8Nrn v1U8bdgkpu/W5Na0DPaIPTtCWRc3wDNcZ4Zrd75HM9aDexUAAAcGv8x479a+3RgN9PPq R2kRliVelgWhp5ZcKn6+lycO2Kh7H4jSUnIaBJlgvPKYTdkRhI6DalwZ353c0XtbTrje 7z6lEk/W35bRgQPmBWP20dKNey8/xBpTEQmYZeys736segLCumkT8WUUCPVvVEjtgHz9 Of30+UhofC77QbCi2cjrtB8+xrwL5jUcinXEcZdNFHq4JlLl3ZjfqQHyv2SmD1yv5Ez7 ztJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983033; x=1705587833; 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=xFv6E5kkXfIGfEX1pT8iilVpb1LB0Hjh6FDK0KUik1o=; b=RrBsMJZ8kbsW7Fw/npwsDAFprTaIQheXyj+O8nTS5e4UMQVdjqQuS2t16FE/aYm0ox 4kS0xvzSUYyChsowDieIzNNWDpHeRE9hbbpyeueCbAXHl/xqeHBpisApA4KcedMlKBlP QKyN1r5hgvw8Gqbw1Y9YEpb7krWezGnV1PkRqYgqHbLygyCznCZsf6YbFNCgEBrNsDuk i5rNwVIpI121wyEl2J3xccH8OVO5lBgvjfLuwJhwWHnGznboj4OOOpI5Um63t9dF6Xwd qdSP+BC1Ign7yJ/QZQG3vrexIjELlq43dFO+HK90C7Jeih26K0+dF7P9DpEosCSX+gmJ utzQ== X-Gm-Message-State: AOJu0YwhM09oq7QH00YdeSPtMJ69XzY0Ll/Oq4dfJdXuLr7PJIKl/dpk rP/XdZy76OOPaIyGV92+0OU+rLJiFpog8j1pUTPHZe+66tg3xA== X-Received: by 2002:adf:cd07:0:b0:336:5bf4:9904 with SMTP id w7-20020adfcd07000000b003365bf49904mr430816wrm.142.1704983033223; Thu, 11 Jan 2024 06:23:53 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:52 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 04/12] tests/plugin/inline: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:17 +0400 Message-ID: <20240111142326.1743444-5-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 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x436.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 6114ebca545..ae59f7af7a7 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -18,15 +18,12 @@ static uint64_t count_tb; static uint64_t count_tb_per_vcpu[MAX_CPUS]; static uint64_t count_tb_inline_per_vcpu[MAX_CPUS]; -static uint64_t count_tb_inline_racy; static uint64_t count_insn; static uint64_t count_insn_per_vcpu[MAX_CPUS]; static uint64_t count_insn_inline_per_vcpu[MAX_CPUS]; -static uint64_t count_insn_inline_racy; static uint64_t count_mem; static uint64_t count_mem_per_vcpu[MAX_CPUS]; static uint64_t count_mem_inline_per_vcpu[MAX_CPUS]; -static uint64_t count_mem_inline_racy; static GMutex tb_lock; static GMutex insn_lock; static GMutex mem_lock; @@ -50,11 +47,9 @@ static void stats_insn(void) printf("insn: %" PRIu64 "\n", expected); printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); - printf("insn: %" PRIu64 " (inline racy)\n", count_insn_inline_racy); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); - g_assert(count_insn_inline_racy <= expected); } static void stats_tb(void) @@ -65,11 +60,9 @@ static void stats_tb(void) printf("tb: %" PRIu64 "\n", expected); printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); - printf("tb: %" PRIu64 " (inline racy)\n", count_tb_inline_racy); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); - g_assert(count_tb_inline_racy <= expected); } static void stats_mem(void) @@ -80,11 +73,9 @@ static void stats_mem(void) printf("mem: %" PRIu64 "\n", expected); printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); - printf("mem: %" PRIu64 " (inline racy)\n", count_mem_inline_racy); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); - g_assert(count_mem_inline_racy <= expected); } static void plugin_exit(qemu_plugin_id_t id, void *udata) @@ -142,8 +133,6 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &count_tb_inline_racy, 1); qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline_per_vcpu, sizeof(uint64_t), 1); @@ -152,18 +141,12 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, - &count_insn_inline_racy, 1); qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline_per_vcpu, sizeof(uint64_t), 1); qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, 0); - qemu_plugin_register_vcpu_mem_inline(insn, QEMU_PLUGIN_MEM_RW, - QEMU_PLUGIN_INLINE_ADD_U64, - &count_mem_inline_racy, 1); qemu_plugin_register_vcpu_mem_inline_per_vcpu( insn, QEMU_PLUGIN_MEM_RW, QEMU_PLUGIN_INLINE_ADD_U64, From patchwork Thu Jan 11 14:23:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761853 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422875wrz; Thu, 11 Jan 2024 06:25:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdIuGtGuDvBNf/dQaj8LW5OsQN8C90BQMY/AUYDnweK/YU4CCqDUXMrj63NOMgfufF2Qsc X-Received: by 2002:ac8:57c8:0:b0:429:a66a:2560 with SMTP id w8-20020ac857c8000000b00429a66a2560mr746233qta.19.1704983154278; Thu, 11 Jan 2024 06:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983154; cv=none; d=google.com; s=arc-20160816; b=x/w662M4LE/K+ppSL9/97TZTpikkXGkorWXZXRKdDXRQ4R3mEIHhD0tSDWA8RD1KqY v1Zj4AdCnFktBPadSXay0ALu/AuHy2cTBReRDnu+X+7qJNmlYaFPTaA+JhUgzKh55zvV aQG7Zor+rTocURkywdG1F+QDFwlv/LBCwG1ZeH6vneYYRHB5wVoNcZ+XioGZNXmqtGti jWmIuHxRKT24Mv/jl8btLnDLhvaBFRNscO+MgK6aMIPczWomlE1R6l30qUj9tBbM/9sD 6x9l3psagKJyZfzRWNI8jKMWZMBKMInNf8WYE+5/IiqFEceyszWDcEjO5n4AmxYFjxa1 nzXA== 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=ln64hRwHlJJ0pQEAuAxOaAua0Oss5Jze+kXnvVQ8J9Y=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=I7tmcobCdIupFJCoP50IBuD74joYY4pnWR2A4bAOdvxg3VkgxSHhkGSlh4Vmuc29QI giRC3nFou3GuaXx74ZDJgS9kz5erUxFvF8gnFcEEUgE8uSBO6B0TvehIqAl5LPNz1TUF O4fm2h/wPvc2jCKcsauH6Tr6AsiPDk/ZAaey86G4GGOG1ubT3DRFRz3ZafYSQNbXLNvf iKheiWKY7U5Ds9UwVPwgxxDXFZzPQ3kdSOSpOTvgz6Rx34n+8x1oaP0sea3h/tnuy2bl bbJS7eadvlcrMX73uELQXymkiA1+fhClOXU/f/BJ8jCKGE9tPiI0Tl2JK49vIQzYrvMJ YDMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qVCWhdnj; 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 z9-20020a05622a060900b00428366bfccdsi976550qta.555.2024.01.11.06.25.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:54 -0800 (PST) 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=qVCWhdnj; 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 1rNvyX-0004NK-Ne; Thu, 11 Jan 2024 09:24:05 -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 1rNvyT-0004Lw-GZ for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:01 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyR-0002V6-Bx for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:00 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3368abe1093so4265725f8f.2 for ; Thu, 11 Jan 2024 06:23:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983036; x=1705587836; 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=ln64hRwHlJJ0pQEAuAxOaAua0Oss5Jze+kXnvVQ8J9Y=; b=qVCWhdnjMNRsk4KgqDKJDOleIlTIvsqnp1GHOKKcXIF7DengGwMBrBIGLMeCwfTX7w XMTuMTZg1fVn66R0WkW0j2sXALLHTbl9PIcffAuJa8VCh9u6XTBWbDse2RC2W3mPcA0B X0dQemz/ObxZkIca8udQKEJ0jhRXUmpht5xv2qKCwB+boC6NIHNj5dwJrxwIbEWSLrZn Ixh5eiO126xHcJV301zIkd2K9Ij0RJ9iThWBBM3GQ5SJZIr6NQZXexD2eiAgnOKHzUlH SF0s1qyOUSW51mf3JnGHcFsCUZ28g1eQXORzlOS2HEN/vpRlUKV8IIJdhIUaI0KE+WpV 3FfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983036; x=1705587836; 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=ln64hRwHlJJ0pQEAuAxOaAua0Oss5Jze+kXnvVQ8J9Y=; b=FgjFPW01w3Tqqp7x5KgDM9V1X+wkaRwmurJFfMTsKN4Hogr6oCy1CsgUvX3iZPk+Gp n7No1MdU2ACICYck5PxZOVwh7R+Xo2W2UmojX9rcX5VTuTR0tzkE6C/bFHqL9JZgEBma kXax0PLjcF3gzsG11awRRn+2M4YaXplRHeWisP6uXQCtVRse6GzwsGMf2o8wY4zOxH3c mqQStWtddbNvfSsmD78kyKS9baFkPNu9OWmua8+XrUcHF98anfQDLbG5CCNfNzT8tAWO hUfa8g+x4M/glXlO9IoQD+cPC+Q2vd1QRmBTMagE8FtTAYDcsz+MDqJNcpsX75+v4u6k 8WPg== X-Gm-Message-State: AOJu0Yw2ODJooSBOX5LsbBjyQVV6GO32ErC25XJ461QkV7M5D8YCMXZ8 jEXh19Hvy7ZMWlR+TOlJqsWikAdcHSj1XHTPJyXB2BltwU+4gg== X-Received: by 2002:adf:eb01:0:b0:336:60ea:319d with SMTP id s1-20020adfeb01000000b0033660ea319dmr574008wrn.63.1704983036016; Thu, 11 Jan 2024 06:23:56 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:55 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 05/12] tests/plugin/mem: fix race condition with callbacks Date: Thu, 11 Jan 2024 18:23:18 +0400 Message-ID: <20240111142326.1743444-6-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 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce a lock so global count is correct. This was found by comparing with new inline per_vcpu inline op. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- tests/plugin/mem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 44e91065ba7..beca8232342 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -22,6 +22,7 @@ static uint64_t io_count; static bool do_inline, do_callback; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; +static GMutex lock; static void plugin_exit(qemu_plugin_id_t id, void *p) { @@ -42,6 +43,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t vaddr, void *udata) { + g_mutex_lock(&lock); if (do_haddr) { struct qemu_plugin_hwaddr *hwaddr; hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr); @@ -53,6 +55,7 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, } else { cb_mem_count++; } + g_mutex_unlock(&lock); } static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) From patchwork Thu Jan 11 14:23:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761847 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422538wrz; Thu, 11 Jan 2024 06:25:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFe6cVLfWg/v2Tv0n81f7WUF23wF7X7xhXLdiyA050hUJbfKisuGAFveJHvWz1TJumVXLS+ X-Received: by 2002:a05:6214:29cb:b0:67f:70f1:e57 with SMTP id gh11-20020a05621429cb00b0067f70f10e57mr1250027qvb.24.1704983111284; Thu, 11 Jan 2024 06:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983111; cv=none; d=google.com; s=arc-20160816; b=j5nrC2gf8lsO0+K6PVVaHp/cjn6YdP42nY2inVAP83nDYyQ4usCK/W8Oou89A1O6vc vkAjlPucD/X4ps+EWEXzF49M6Lprysqs+swmrwuFBrxn8jmMITaIQJxyg8A4wEtO7b6+ qbdxN/6pb6Glh3zfvBwq3b/fBDZD+lDjpd64B5FbSjcy3IBbTMefxf+aK61luoA580x4 /31m5s5zQGJugp2or3gTKaJ0V3oZkLef8O7h5I55/XL/pCkxJEF/+sJfTRPHHMr90AOz CwRKjzfleH+VnQ81nlGmQKhcszGr5MsjpCdVX21ulOZ7rDPnpMfWX9g6AuCVTPQVkqv6 VYuQ== 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=Aq5DjSOiw7b/OxzS4nPd0JW8zSf3ntDpqvE/K8se7oQ=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=1Ecnd9Tcm0wIyRakFKL1aDZmJ7ZcICkk2iXyoBpxIioB//qOf+YFfnU22Xkaj9GD50 C8+qf6GJ67enlyTFVFj/IXwz2Wv/278u4Slkp8oqNYwBkENY3kPRZAomvH9q/SOJZ0+T KHHEA22sV4o28VMcql99lEt3BAj1DXw8XefTKB8heFw2U6Gg1zaYVObKdTos3xFTRllx 2l5uJhLK2I/J8mdOfuFMTA+vUzJXp1dKZgW0T6mZMvZUE7mfuz28EtdZPDwuWUhNO3z3 rSH9EIImg/s5XjSKcosqowJ6V4UGxLP1XZiO+01GcpRrvcq4RAGW2GtCb4o8NHVbDVOF tOqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eSPgyD8C; 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 m19-20020a05622a119300b00429c95922cfsi286577qtk.641.2024.01.11.06.25.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:11 -0800 (PST) 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=eSPgyD8C; 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 1rNvyo-0004QZ-Fq; Thu, 11 Jan 2024 09:24:22 -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 1rNvyV-0004MO-8C for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:03 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyT-0002Ye-8S for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:02 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40e60e137aaso5433935e9.0 for ; Thu, 11 Jan 2024 06:24:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983039; x=1705587839; 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=Aq5DjSOiw7b/OxzS4nPd0JW8zSf3ntDpqvE/K8se7oQ=; b=eSPgyD8CXHMRwKAEQhTj6eIVTxjd7eOkOTniWJcBVsBmGrEqD33/QSoxv1yOz4G8RE EBEI8p8/Ei8LKjL9OmQuJbbItZHEGcnGIHeZgO8tRtzahFd5l4DQq4PI0GQXMrr3cVpG INNtoywVk9lCEAqWtFruB8U6sODXQsJp2HMno+gdMhVHGasanzldcsX5D9jU5lXP66r8 wgLUO9xQ1FPNc38adyb7DscS6PYvV6yCXcr6p26AREL464a2y9tpNp5gI4j22BCwYWMU 05OTn/SMuRzh0fDb59ylryu/FHjkb11/ow0cyTXfW65TX2V8JXkV5i7cPyXS1Z91Ep/F gZHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983039; x=1705587839; 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=Aq5DjSOiw7b/OxzS4nPd0JW8zSf3ntDpqvE/K8se7oQ=; b=mLPX3fmed+XsUOFxmNRL+PI/XHQuWuCvLHbp0yM/C7ah0F8l819zJqXnCI2WXJhkXO 4g1oqUBetzAiyXEuzuLwKnRZWtM/fyPTOFD42Tj582p4s9s4EG0TFZuyZlA657rhL+DE ziunCBggZCtEJGveOIi/DWnttl9h6obBwzXW6cODuMEUGEK4yINhWgsHe2yG55YgmuB4 OexUdISku+s5HinSGi2CzCIjLRXZCTrQogvxzWviz+Z75ak9l5sNB8hTXKXNzdJ6OgKz WPqtlZE3LNUFIt6ofvS1ciW33jb1qZjUL8GxDI7IBBU9rrFla8hI9FhtCIMOo0K1vhnb Ydwg== X-Gm-Message-State: AOJu0Yzm78LjoqoyqEiDfnAUAEVUzB/pEnSdycsXFaZaEa50QnWLSHD0 8BukgB7IdniA7ZHI87dUV+mGK0u2cIsiJL0ppHMjJz+hTGr8TA== X-Received: by 2002:a05:600c:54ed:b0:40e:5996:2291 with SMTP id jb13-20020a05600c54ed00b0040e59962291mr511531wmb.138.1704983038931; Thu, 11 Jan 2024 06:23:58 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:23:58 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 06/12] tests/plugin/mem: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:19 +0400 Message-ID: <20240111142326.1743444-7-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 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index beca8232342..06f2d80d0ec 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -16,7 +16,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -static uint64_t inline_mem_count; +#define MAX_CPUS 8 + +static uint64_t inline_mem_count[MAX_CPUS]; static uint64_t cb_mem_count; static uint64_t io_count; static bool do_inline, do_callback; @@ -29,7 +31,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_autoptr(GString) out = g_string_new(""); if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_mem_count); + uint64_t total = 0; + for (int i = 0; i < MAX_CPUS; ++i) { + total += inline_mem_count[i]; + } + g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", total); } if (do_callback) { g_string_append_printf(out, "callback mem accesses: %" PRIu64 "\n", cb_mem_count); @@ -67,9 +73,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U64, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + inline_mem_count, sizeof(uint64_t), 1); } if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, @@ -109,6 +116,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + g_assert(info->system.smp_vcpus <= MAX_CPUS); } else if (g_strcmp0(tokens[0], "callback") == 0) { if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_callback)) { fprintf(stderr, "boolean argument parsing failed: %s\n", opt); From patchwork Thu Jan 11 14:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761852 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422860wrz; Thu, 11 Jan 2024 06:25:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQx418Q0aZvMDp2f3tCOZ3KkPxdEZaqTIxUTDuMsgsweDC21gC/lyY9fjEVEOE7cWx4O6u X-Received: by 2002:a05:620a:8426:b0:781:db57:572 with SMTP id pc38-20020a05620a842600b00781db570572mr1153061qkn.95.1704983152507; Thu, 11 Jan 2024 06:25:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983152; cv=none; d=google.com; s=arc-20160816; b=MEaNwK0EA0/byJQUMASSqhD2mlt1qra+6AaUGnsWNp1d8rV1cdOLPvR/rGxj2dCcDV IkgzkUJjRev9Zyd/VKZ8REPGaNSgaqNJrwIZJV3QW3TEVr1nVb4mbhjRYXSAanJ/XM4e 7loZGdPwn4kJSB1wL/CT9n1Q+wsK8XSnO2oQXtxEWh2ZgwP5ftCmlI6LjVVy5KDNTEZE W2AdOwoyPusS4qGG43JNC0XBa+6cQnOvr+NUl8Fi/vXSpCwMCjF9wrnaNi39+C+esjrV ik4HLcQGiXjklvWq5duQlI9e2gdLVpgBbSiIDU+IFSgZditRZg1I9X4zYuHlFFIssRqo Pr4Q== 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=BTn8iqDeGr0XAAzxAxgUm6NGko/94wD5dpWMO4sCVF8=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=hbwxrCZcQKSVF4tJDIkGvLDtzqbZKG7W74+jAAb9+fcPHvjRtKC+olxx7EYmjkWMlX yYzgJIiRtq1zvXg5Hlw5roHZ3UGlWdnpyMaXJk0SPiVZtnlNyg/KDgj9O47302Xy86qq LWUE2NJqOWIvysnY8rxge7uHiSWJl3imLMP3XAUbADJ7utBURKS5dij/xWsZGyGElcJi OEPX0WEP7x4UAxkZ8N68KNRxTWhmJzNpUrzzIZAHRKfb2kr2csbnhgPGF35F8j4uqo3N xx/0T1ZgYggIHfcyhtp/yRAIxwlyvlz9BPt0Qy4HZhA8tq6DAJAjZonikZzeFp3h4+a0 A6Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VMnAyScO; 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 j7-20020a05620a000700b0078323332e60si994513qki.43.2024.01.11.06.25.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:52 -0800 (PST) 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=VMnAyScO; 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 1rNvys-0004Sx-QK; Thu, 11 Jan 2024 09:24:26 -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 1rNvyX-0004NM-Pv for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:06 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyV-0002by-Kz for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:05 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40d5336986cso69028505e9.1 for ; Thu, 11 Jan 2024 06:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983042; x=1705587842; 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=BTn8iqDeGr0XAAzxAxgUm6NGko/94wD5dpWMO4sCVF8=; b=VMnAyScOHl86YYgTkYSIR5fFYzjmx2+0mRv6hEu0cq5ZABhIGfdVuMxxoBwhjAhvEG 7pjyMkUuPP60q54gXtuLKfCn+7TqjnWA1Pm26RIs+oGntkuoB5zOq7xOUxgTMpjtGDFR TRzMthr+J9d+TMfc6KRtW3+szaEPWSKLeaxaNeumIKjXHrtK5FzhCGYxAQP0EE5t9Xwe CBfGOqZXyzF4FKezt0VheCmpudMyyaa2AIOXozKtfRY/6PSr5d4kWzUXhgX4FlFUr+KI Fa2PwIorD/T+7MxLUo3fQguLuQfKZoamFzoUAXa2fl8RTPCP/REKG85U+PTAnzeKWXRU B8LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983042; x=1705587842; 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=BTn8iqDeGr0XAAzxAxgUm6NGko/94wD5dpWMO4sCVF8=; b=cBG/rrJmt/FyJ6Vd3OLiEwWY6+T2kXj5jEni679sZwuv2PZZjmmxfe3/MBVG2n5ZBP 5YfX3SMKLqUVjZofs9ed5B5VOWSM2p2ea+WKh/8/jbja3o8F6ADLnB1BmngQtk/uuAvW nVJUAA9UrFAaUz7qoATMloAqe2tPUZSVeqo6IYaVWSW+yXUX86Wd7ZhE26eChRAF4ZLV pQAZEripFmulpsc0+aKBXiE6qMEXlj9g8Tl39xM0ZmvG1ywS6LwNoU5kDvaft9ldMnk+ dG6qUuVYc68wAp+QvakIahULkOYHFWwymEydZURkRplXV1NwJIqKpxK7qgdHS+bn4bCw Q1hg== X-Gm-Message-State: AOJu0Yw2IGe/bAkcnrbYBbK89I+oT9UHdutOdt1bqUg2sPZzVNCn1JEY inCSgBEMPfXkE1qX8Ob2pSVPbWPzBT62iLsjLcOa1u6Bv+TZow== X-Received: by 2002:a7b:cb96:0:b0:40e:393d:715e with SMTP id m22-20020a7bcb96000000b0040e393d715emr454996wmi.207.1704983041835; Thu, 11 Jan 2024 06:24:01 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:01 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 07/12] tests/plugin/insn: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:20 +0400 Message-ID: <20240111142326.1743444-8-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 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x334.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- tests/plugin/insn.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 5fd3017c2b3..be79c5080fd 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -23,7 +23,7 @@ typedef struct { } InstructionCount; static InstructionCount counts[MAX_CPUS]; -static uint64_t inline_insn_count; +static uint64_t inline_insn_count[MAX_CPUS]; static bool do_inline; static bool do_size; @@ -94,8 +94,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + inline_insn_count, sizeof(uint64_t), 1); } else { uint64_t vaddr = qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( @@ -151,7 +152,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } } } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_count); + uint64_t total = 0; + for (i = 0; i < MAX_CPUS; ++i) { + total += inline_insn_count[i]; + } + g_string_append_printf(out, "insns: %" PRIu64 "\n", total); } else { uint64_t total_insns = 0; for (i = 0; i < MAX_CPUS; i++) { @@ -195,6 +200,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + g_assert(info->system.smp_vcpus <= MAX_CPUS); } else if (g_strcmp0(tokens[0], "sizes") == 0) { if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_size)) { fprintf(stderr, "boolean argument parsing failed: %s\n", opt); From patchwork Thu Jan 11 14:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761856 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2423170wrz; Thu, 11 Jan 2024 06:26:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5n7wzdxxK0Bn06QxfJ4t6svXfBQbDNF0Z+i5em3jjg1Nj/clXwTGL5JUD9GQpEZ/MFSZ+ X-Received: by 2002:ac8:5c45:0:b0:429:bc8e:3e0 with SMTP id j5-20020ac85c45000000b00429bc8e03e0mr895605qtj.18.1704983188407; Thu, 11 Jan 2024 06:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983188; cv=none; d=google.com; s=arc-20160816; b=Ny9fQYDr8ESco3ydnxkojRQMbRLNRbq/hMxCA/a5mCHefNfwO2ruU/kVkM12boPMnC qcU0FpUE0Sfomn0Zwo+r3MkD3mQIZDEK6kgKLMD9eaKAPg5ESupMp2/MK90HDHoW91DR PnJVJ3U5d9tEjgyjwS69g2h/TO2YsKieefCCWgJb4uFoMl0nmAVemmbNG56dfSMZKtlq ZQ82YUhjd4reOHAsk3szyVZZ96DsvgFU8lm1A1d/H187+WFp/457D5VWJlTLOP/1GUDu QMYz17Bv7ldgVPExPL5mFmKLYTLKKSPgS0CebyzOf40IbEY8nnvZ5Ow80XriZh01+TVW bYbw== 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=YWE1tVGsIn0zEV+TvKSOjYsl0DanjdWaNblTi9NxIMc=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=D5DBEWIQ+CyAvTenvQhPl2DYGgFrtlCZO3rLhga210LPsrxibd3na5ez/M5dTsL7ML nfhmxUqiPDJbv1g2nr6Ia/GGpjsy4/KR5FxuOyP2wIuC0zyAvMKXJ6D5fMza155zujni ZswhfiC1Rab04EXEDUv0XCxTWnKNTyN8J+9BVbT0V3BdFP10M76m6bh+FvrG0XlNwGlI AfAmPHxqWR0OLDhpYxEX7CmItlp3XAjijE0iv41JuRsX4nZJ/DqSXOUQOuGCEC99HTWh jNrKISHwXJE9rUrlMk4oFj5D82w4lIaD1esZ937bZec8LvqTAgBkJlhlQ8viQ+5GRkEf +5FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q7ddo9eM; 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 7-20020ac85947000000b00429c529ae98si985550qtz.266.2024.01.11.06.26.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:26:28 -0800 (PST) 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=Q7ddo9eM; 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 1rNvys-0004SI-Ip; Thu, 11 Jan 2024 09:24:26 -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-0004Q1-TP for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:20 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyc-0002ie-Pa for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:17 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3374eb61cbcso4837049f8f.0 for ; Thu, 11 Jan 2024 06:24:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983044; x=1705587844; 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=YWE1tVGsIn0zEV+TvKSOjYsl0DanjdWaNblTi9NxIMc=; b=Q7ddo9eMNb/c7HnnvX0iiEmQslCFcQRu1OyxsQ2XL8gi8Z50ZTp5Pwr5n/nDv+/qvZ VvTCUTI85APJzO/82XGW2gNyT7AiIBZgLdfPGNovg8OgQTicJB+DPKwI+nLrOrfZ8s53 fk+BJ0YP6cQg08TtWCn+vtl61h5XE8HBC+hWwrEb5siPLmvZdQmialIEY911Jx3pi205 /6ulw5iA2sCjnXJdMojeUY7OmGkY7/JNELfQEigYRS3yXpUGaU9ztUI97HAVQBpDa1c7 mHygybgYGw9M3v4tbqei0wU11uOSPG8VwO7SO2f5vPCnaKNQ5M67buhiUDM/5pUchUom BOCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983044; x=1705587844; 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=YWE1tVGsIn0zEV+TvKSOjYsl0DanjdWaNblTi9NxIMc=; b=c0Scj9XYfhcLsHSviudowrv38U/R2RNuB+CgqPQYDDe5qSdpPYHkzQVmunqTwuImIJ ZBdLqCJUNVX6R9SE77vMo3F26HwObiKmMcQT3s7gVCXWwCoQ/ZwPIlpgPUPPKLR6Vb66 ZUwlXe8/+20se80x+TwCyvXA3YxRnKcQjJEX0kd8aIBH5WNVGi4IEI88mUe6a8lrS3b4 kWJiMcuGwCY23lC5/Zj/SvF4QVWQmd+2RIhTC8dknbf7d4Gb2oPNGaxYMqFuEpcKpFQG eHUg5ur5ZbwAWGS02sI0kp07+KJ19m/S+gKCLJAGv5HQQoUX0vRtemYQHLRD9yXLNFjQ kqyQ== X-Gm-Message-State: AOJu0YxTMgON6h55QbWST1Z0hA7snKog+CHzOEJXu2XHQDf8W4VNzNz0 mDSGd2DH5nfkAjl6Vr6jxBw62AYI4/uR+A5WKZk+poXJDo/Keg== X-Received: by 2002:adf:ffc8:0:b0:337:76ae:34ca with SMTP id x8-20020adfffc8000000b0033776ae34camr762518wrs.77.1704983044702; Thu, 11 Jan 2024 06:24:04 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:04 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 08/12] tests/plugin/bb: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:21 +0400 Message-ID: <20240111142326.1743444-9-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 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x431.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since we need a fixed offset between count memory location, we now need a contiguous array of CPUCount (instead of array of pointers). Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- tests/plugin/bb.c | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df50d1fd3bc..644a36f3128 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -16,6 +16,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; +#define MAX_CPUS 8 + typedef struct { GMutex lock; int index; @@ -23,14 +25,10 @@ typedef struct { uint64_t insn_count; } CPUCount; -/* Used by the inline & linux-user counts */ static bool do_inline; -static CPUCount inline_count; - /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; +static CPUCount counts[MAX_CPUS]; static void gen_one_cpu_report(CPUCount *count, GString *report) { @@ -46,18 +44,26 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report = g_string_new(""); - if (do_inline || !max_cpus) { + if (do_inline) { + uint64_t total_bb = 0; + uint64_t total_insn = 0; + for (int i = 0; i < MAX_CPUS; ++i) { + total_bb += counts[i].bb_count; + total_insn += counts[i].insn_count; + } g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - inline_count.bb_count, inline_count.insn_count); + total_bb, total_insn); } else { - g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + for (int i = 0; i < MAX_CPUS; ++i) { + gen_one_cpu_report(&counts[i], report); + } } qemu_plugin_outs(report->str); } static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count = g_ptr_array_index(counts, cpu_index); + CPUCount *count = &counts[cpu_index]; g_autoptr(GString) report = g_string_new(""); gen_one_cpu_report(count, report); @@ -69,8 +75,7 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count = max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count = &counts[cpu_index]; uintptr_t n_insns = (uintptr_t)udata; g_mutex_lock(&count->lock); @@ -84,11 +89,13 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) size_t n_insns = qemu_plugin_tb_n_insns(tb); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.bb_count, 1); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.insn_count, - n_insns); + CPUCount *first_count = &counts[0]; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + &first_count->bb_count, sizeof(CPUCount), 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + &first_count->insn_count, sizeof(CPUCount), n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -121,17 +128,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } - if (info->system_emulation && !do_inline) { - max_cpus = info->system.max_vcpus; - counts = g_ptr_array_new(); - for (i = 0; i < max_cpus; i++) { - CPUCount *count = g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index = i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); + g_assert(info->system.smp_vcpus <= MAX_CPUS); + for (i = 0; i < MAX_CPUS; i++) { + CPUCount *count = &counts[i]; + count->index = i; } if (idle_report) { From patchwork Thu Jan 11 14:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761848 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422541wrz; Thu, 11 Jan 2024 06:25:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDwuWXBRWyU8zYOx2BI6XZU8e37IpO7Sg8LiWoArx+s/nrfzMKKJLNNH+fTP8pU9s+pxiM X-Received: by 2002:a0c:e349:0:b0:67f:8d72:8cb2 with SMTP id a9-20020a0ce349000000b0067f8d728cb2mr887375qvm.16.1704983111675; Thu, 11 Jan 2024 06:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983111; cv=none; d=google.com; s=arc-20160816; b=rsFJN8zQ6XihtCL+6B44Hm2uLOrwm0xdr1pkWgNfbsfvjESt0DdcquKcMk/zR9IVKI SZJXOHXqYzeL7tLamv6Og2CTx594cFmAOEIccOYe/0t7nJDmkJe1o7ScOMhjNrRhXB2+ qJLiTQDaVaTzN2sfUS6iYnWmchtYWfXkJf5iF1G0LrFpvtvLG0hsDB2dD20x0Ko9CRaI SR35P4s7K5QTIAXT3CCBPwqd5ITnxNJV/JmlWCKx3WnoUqRZcTtGdBKdMAjZkDFCtARV ovvlC/EDHzd9eybSNKoXqM45Uv3a48EuOM+yD1xbd7EK9z769GAS9Tpznxp9UmfLyR4f vIjQ== 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=uKEHWzAFUZUFQemWuP8DkGrbgCslhiVNabDeLsILYDs=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=VAsxcaqGZuqZMBYsqzNQI/gdTTdi7ZFGcE3QiToWzFdyns8ZFjhzlfexuPyDbQqLAX LGqzxZnpW8TQ8tatQc7C6b60037pTOMhrQTER/5hL6aVSsnULy9h6WURemVeT0yBw0DU 4DaPIvonTQz0jQUcJtp8Z9MJk0SGj3nH39nHRb60fMW9+Wfjl/HuIhTdSuH8y1HTjsOR OKq4MucsAeZ/5cEpMUaFl8kxPPHwIXZhAbaYjzKXepFSrSSmw9Z58r7m1D59T/ZcVrDi WKsuThbB3ztJPN6FnO5ca7qQAmQIGCoDRY4pOE0WCo+DqhQmhlZv8lY6zSD70+DoNPmu 4iMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IY+4PP3R; 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 w20-20020a05622a135400b00429af934db6si995191qtk.213.2024.01.11.06.25.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:11 -0800 (PST) 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=IY+4PP3R; 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 1rNvyt-0004U3-8M; 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-0004Pu-QQ for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:20 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyh-0002kr-8g for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:17 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3376f71fcbbso3419644f8f.1 for ; Thu, 11 Jan 2024 06:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983047; x=1705587847; 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=uKEHWzAFUZUFQemWuP8DkGrbgCslhiVNabDeLsILYDs=; b=IY+4PP3RRnYODzQ4PCuWOUaoD/2tBQUyeKp4EfDY8W10tK9bXGmkV3FPsmfEWWoZwe mEXUyZCLTqZjXkzQKJLPj0WNwtrhTRQIquwhjVjCJaOoz9zdXWABAjjMZHgCltOsPlUj kuqsdLm7kp+62uZVoq6q//MJRguQadrBGXhV1gEsOwADcMuH1jwata35rMn0hfQfcQPq iWRyGbbbs8n0wDaGYDNW613mexlmtc0jRQQR4EfdVUSRsPBnqYg2Zwia34rHvWojDu0E RfpcilZTTrshAC4JZNxXGoVZ0pBywropKD/tuT6soDECq2RSY7ZBnmvNsgj5Q5rN8aT8 pxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983047; x=1705587847; 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=uKEHWzAFUZUFQemWuP8DkGrbgCslhiVNabDeLsILYDs=; b=aBXpwVBkH2L9miWWTjFM6m/Af0rpStdtqjtELKrVqaAXLY7ZIHvI1L/tpKRXX117Z9 7bFlTGbznLkUDvyRfDP/svMBwwoDTn9cE3bj2WBCEiU8mk9PHYhNfGi4D2tIvvdlISbK kgm81fifTvfw4dAbvkEfIQPMtmPL7+Otma2en3j50PvwR/+GZSftxeyg/QF3M/eG0WIn fURWpdfmN2jcL8cYzx/Td/Fhqt0VHqeEUHDzDGKKRCylyoQYmM6h1VKScV8TNg2anPRS Sy61GN7T+R3lw5Mju8vM+g4Lrz5lmmlNsfOxw4BrtzqlCPDriGOXqSm3j4J3vmOwXznV digg== X-Gm-Message-State: AOJu0YyXIJTtm6wfprhg2qrZCnfVexMtCkHLfOqb8ITOmLx1ZhxnQz4E KCIiRq194JQj/2xl+uWH5O4RQzdsGfDUYMd5OAwRseq6hZr42g== X-Received: by 2002:a05:6000:1090:b0:337:68aa:c63d with SMTP id y16-20020a056000109000b0033768aac63dmr495790wrw.37.1704983047533; Thu, 11 Jan 2024 06:24:07 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:07 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 09/12] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Thu, 11 Jan 2024 18:23:22 +0400 Message-ID: <20240111142326.1743444-10-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 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x436.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- contrib/plugins/hotblocks.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 4de1b134944..1d95ac53143 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -17,6 +17,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; +#define MAX_CPUS 8 + static bool do_inline; /* Plugins need to take care of their own locking */ @@ -34,16 +36,25 @@ static guint64 limit = 20; */ typedef struct { uint64_t start_addr; - uint64_t exec_count; + uint64_t exec_count[MAX_CPUS]; int trans_count; unsigned long insns; } ExecCount; +static uint64_t exec_count(ExecCount *e) +{ + uint64_t res = 0; + for (int i = 0; i < MAX_CPUS; ++i) { + res += e->exec_count[i]; + } + return res; +} + static gint cmp_exec_count(gconstpointer a, gconstpointer b) { ExecCount *ea = (ExecCount *) a; ExecCount *eb = (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + return exec_count(ea) > exec_count(eb) ? -1 : 1; } static void plugin_exit(qemu_plugin_id_t id, void *p) @@ -65,7 +76,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) ExecCount *rec = (ExecCount *) it->data; g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + rec->insns, exec_count(rec)); } g_list_free(it); @@ -89,7 +100,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata) cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash); /* should always succeed */ g_assert(cnt); - cnt->exec_count++; + cnt->exec_count[cpu_index]++; g_mutex_unlock(&lock); } @@ -120,8 +131,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) g_mutex_unlock(&lock); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + cnt->exec_count, sizeof(uint64_t), 1); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -149,6 +161,7 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, plugin_init(); + g_assert(info->system.smp_vcpus <= MAX_CPUS); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; From patchwork Thu Jan 11 14:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761855 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422998wrz; Thu, 11 Jan 2024 06:26:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMMipmU2SwwmAlM2k8LkGZQRwn0l7IqazxE4cVMVxqswRuOb60ohmla6dh1MkF0Qu76eUA X-Received: by 2002:ad4:5949:0:b0:67f:c0f2:5ca6 with SMTP id eo9-20020ad45949000000b0067fc0f25ca6mr1158823qvb.99.1704983168757; Thu, 11 Jan 2024 06:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983168; cv=none; d=google.com; s=arc-20160816; b=jCzIU62I7iMAXkZtvHn4V1CfFIN1FUthChgSn4JCI/ovj1YIy9U4eIncZIQMA7fsy3 /QvVIC2iBEsINRffHLJ+T1D7JtYrPZSXHp27umfUgoAGc9KQZm/Nc2OPHBo/mZiETK9z EgawnCD7bxGqWaoQyrGP5YtWrPCBYMDwXF2p6pPWsHGRnRsCpxSNnQGugBOryWCxi7Sw HgbI1H8+NxRA0KAK1KKoge2h1yHosmJuBWsYuMDtMaNVFK2WNq4TWvCvOevDFnQUC23H YUaTT7IuZPe8mJbby5tGDBbFCNYDwshe2AlCyePMOcmDrP8Rk+KHI+SJciUUHQG/hEEg N5+w== 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=8ZO5SKzeIPzFy5xT17BpWpFDUdZJfOe9VoGxrmodP4k=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=LIBITic0xjwlm5FfghmjSKUihR1NxIY2XhjOLknxqWAIr6dQ3gO7Rh/u/ZoesXsTK1 nZ3l+MFkv9PMhFzc2FNlZWw5RjDmby274ZQNo6JwvU6ijVus8xBm3vgLqz8TtUu38Y2k rcn3x8P7rTD3EyTxlDTpSHroioEi9ywGljn24m3d6fyRFMQuGnmzLyz11S8swTLf30gy r5/Ii79Wgbl0XVPkomzdW1vik4lGXnPNIS0EM9k9VWou0yze7CqNyVvxAzUKyYqMUhBt NNun3f5K8l0MYgw27iy/T3FkAXYOdL+Pq35K8CayOinspT8nCb8nVZDAeiC/HNVpoSSP DsFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gH8qm+1u; 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 d9-20020ac85ac9000000b004298fa9947csi1032931qtd.662.2024.01.11.06.26.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:26:08 -0800 (PST) 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=gH8qm+1u; 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 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; +#define MAX_CPUS 8 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +static uint64_t count(uint64_t *arr) +{ + uint64_t res = 0; + for (int i = 0; i < MAX_CPUS; ++i) { + res += 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; typedef struct { char *insn; uint32_t opcode; - uint64_t count; + uint64_t count[MAX_CPUS]; InsnClassExecCount *class; } InsnExecCount; @@ -159,7 +169,7 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) { InsnExecCount *ea = (InsnExecCount *) a; InsnExecCount *eb = (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + return count(ea->count) > count(eb->count) ? -1 : 1; } static void free_record(gpointer data) @@ -180,11 +190,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class = &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=0x%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 = (uint64_t *) udata; - (*count)++; + count[cpu_index]++; } 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); - 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 qemu_plugin_tb *tb) 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, cnt); From patchwork Thu Jan 11 14:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761854 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422913wrz; Thu, 11 Jan 2024 06:25:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6RBEzmJyzOIWakM5NCkITs5slxU04gsrL/53vLz+YyY1JhCC1XWkSHFLnXoYwyZ1XBiX2 X-Received: by 2002:ac8:7d4a:0:b0:429:b92a:39f9 with SMTP id h10-20020ac87d4a000000b00429b92a39f9mr698989qtb.85.1704983158981; Thu, 11 Jan 2024 06:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983158; cv=none; d=google.com; s=arc-20160816; b=RBHyhbpTVKRBmC5EZz1I9FHUGf/4pN2nUkdE13d5rBgKd1bt1gDCOC5T+tJD3gTZGh ULvEi55avPqQ1cKe1/fzmfNJGMsI/YfQ4lhVSjMwXg4bCQ3Dets8IGHdlh7GDjPj6yq1 WqJnIawHpj0TWfAa4GEFAuEtD+Eoj0Q3IYlWdiG06TjMTg4cSEbE0Wgo2EOCVMEhcJEh 8qb1yh4OT7y0e4SKXcFtbSUJIKcxmQqHTYnMXi006PHIzh1NNK2MEUij/YsfNJ9zbtNy aq0FENSyt5RXaEttBbNO0bqNUEUufjigni8sb4penQ2jOpRO1fqMBHmyYgd335MDfQ1K G8hA== 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=Zp8qrWUcSTBg18ScDzokCUU9rq/1sFICSbhnSWqMC94=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=iNTbM+AZf6m6980QCRd+xKj1DuZ44wicMOMmNxWKMBHiH1LlnVy8GDc199vB4pGD1g YVf0UEeKzLDVfpSF9LoZpryxttTrTxWLKsz5gwjmpYt9UvrAtigZzdzvoUpPEWRNqMX2 4IfeuI8YmGu6kmquQl7EWf90m4CG9Oh79DrX0l8z8WfUaKfQPKm1r3zeRCSnkACtdLiP rWXB2b6yijENxH+6ukoBQXAZHXDpqNq5ZPaZHW7ZY+OzITG/lYALpso6QtMHdDrHZtt0 b9EEXqQCiotZrekANjdbZHWMo6i92+saK1yHo22SweazGckP2HMeiTBLBEdlDtZXOxvw susA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOBzJuTA; 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 t10-20020a05622a180a00b00429c89bbc92si429260qtc.566.2024.01.11.06.25.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:25:58 -0800 (PST) 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=jOBzJuTA; 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 1rNvyu-0004UN-5y; Thu, 11 Jan 2024 09:24:28 -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 1rNvyn-0004RT-39 for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:22 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyj-0002mb-9N for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:20 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33748c4f33dso5226330f8f.1 for ; Thu, 11 Jan 2024 06:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983053; x=1705587853; 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=Zp8qrWUcSTBg18ScDzokCUU9rq/1sFICSbhnSWqMC94=; b=jOBzJuTAYdM4hrQg3vHJbgL0SBKDfNmaFiyqQ1indKmHghHifplZ/IK1WIq4N/Yj5P 3j9x5FUbKaREicdC59mZ16Tx3H+B1u8+c9jmWRiaGVmLghHTW0DX/4nrMulF7mJbbrnX taFa5q3hN2/6lB3iNi4XoaIqaojRpRYCI8MPqaIlDcPNA3Q3+w47BHfovuZx7dHn4Hfl 8sE/n086eGaSlJFJvLaovrDgGJBCreZ4TtWwWRPeHqxEeef6LGW42vao9UFu8ryw0SSB vWa/z86wshucagdHhNrCUXqp24Uc4fQJI06BtMzhQnP+grUHH436Qh6xML9B3FHYUdyl xKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983053; x=1705587853; 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=Zp8qrWUcSTBg18ScDzokCUU9rq/1sFICSbhnSWqMC94=; b=Y94/+/Ed4YNEHsmemVNiL2TBSPU+RkWLr5lk5hsH4Lyve5Izd/9xuGHc3U6xrRxBGJ 0/N0HuxtoKe0RYYYRJu61SAKoy10ucVzq4PGGbsC3u9t5oqIo821IVD82GfvD6aigY/J A3m0jTA5uowovMRJmWXnFK9t7rMxFugvKZYUO96vhCFMolugSTEdbxArJYD+KpikK+wu YAoan/YxzFBjDa1mUMFYDReI2PWYsxFNXvExEUJx/AhnEDBan3LZg5skaxDvhjLSbuER fFoVQKrzYcmNju8C5DjCuoZ/FYdG00dl4sJM/Dy2pVs4SaMat+3gXvRKW2QZySmLZswW l+gA== X-Gm-Message-State: AOJu0YxPMgU5Jqs6m6Eg4E0Ddh7ZnQxGJv48FvMWmBPFat/h7dOXDgrD AdjB6+3MRyvoaQatXuYlGoOrjSHvUK+yYlcFla5oJey3bYvdeQ== X-Received: by 2002:adf:ed0a:0:b0:337:3e7d:11bc with SMTP id a10-20020adfed0a000000b003373e7d11bcmr589416wro.107.1704983053331; Thu, 11 Jan 2024 06:24:13 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:12 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 11/12] plugins: remove non per_vcpu inline operation from API Date: Thu, 11 Jan 2024 18:23:24 +0400 Message-ID: <20240111142326.1743444-12-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 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x434.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now we have a thread-safe equivalent of inline operation, and that all plugins were changed to use it, there is no point to keep the old API. In more, it will help when we implement more functionality (conditional callbacks), as we know can assume that all inline operation have an offset associated. In case a user still want the old behaviour (target a single memory location), it's still possible to define an inline operation with a 0 offset. Bump API version as it's a breaking change for existing plugins. Signed-off-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 59 ++++---------------------------------- plugins/api.c | 22 -------------- 2 files changed, 6 insertions(+), 75 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 8a0691a760e..65e770f5c56 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -50,11 +50,16 @@ typedef uint64_t qemu_plugin_id_t; * * The plugins export the API they were built against by exposing the * symbol qemu_plugin_version which can be checked. + * + * Version 2: + * Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. + * Those functions are replaced by *_per_vcpu variants, which guarantees + * thread-safety for operations. */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 /** * struct qemu_info_t - system information for plugins @@ -293,25 +298,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; -/** - * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op - * @tb: the opaque qemu_plugin_tb handle for the translation - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time a translated unit executes. - * Useful if you just want to increment a single counter somewhere in - * memory. - * - * Note: ops are not atomic so in multi-threaded/multi-smp situations - * you will get inexact results. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op * @tb: the opaque qemu_plugin_tb handle for the translation @@ -346,21 +332,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_cb_flags flags, void *userdata); -/** - * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op - * @insn: the opaque qemu_plugin_insn handle for an instruction - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time an instruction executes. Useful - * if you just want to increment a single counter somewhere in memory. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -585,24 +556,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any memory access - * @insn: handle for instruction to instrument - * @rw: apply to reads, writes or both - * @op: the op, of type qemu_plugin_op - * @ptr: pointer memory for the op - * @imm: immediate data for @op - * - * This registers a inline op every memory access generated by the - * instruction. This provides for a lightweight but not thread-safe - * way of counting the number of operations done. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access * @insn: handle for instruction to instrument diff --git a/plugins/api.c b/plugins/api.c index fd6ce678501..a51585b3e53 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -94,13 +94,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, } } -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(tb, op, ptr, 0, imm); -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -124,13 +117,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, } } -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, op, ptr, 0, imm); -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, @@ -158,14 +144,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm) -{ - qemu_plugin_register_vcpu_mem_inline_per_vcpu(insn, rw, op, ptr, 0, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, From patchwork Thu Jan 11 14:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 761845 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2422406wrz; Thu, 11 Jan 2024 06:24:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwXWac0WzucCfhiDGg6RAMit4skb8rRORve0Gk8rOlfdUuPYg0dnLPerO8IxdTxWHuBFOL X-Received: by 2002:a05:620a:444a:b0:783:15f6:aed5 with SMTP id w10-20020a05620a444a00b0078315f6aed5mr1640749qkp.27.1704983092167; Thu, 11 Jan 2024 06:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983092; cv=none; d=google.com; s=arc-20160816; b=Y7Vhswz14i45CygI73PdWjT+0WPgvdXUxqojhTd+HYnv+v2ys5jUIzWB2X3M02HcLu tUIOS/TvBvdZAdZoBKA+XJ2YbYbbm2cPqLRQiV9oPhnf63HKgIZqxy0Qoj0DxAdze5b7 RvuF+i6X4Ik4HOR7AUId3E2z7KeB0TSvx0I8kXRovXBU6CgVXcfw59okG/DH6vXXlmkJ nTA0/vEMO5h3uyCqI52RTdKiVwECEaWMg21BHpNiR1TSWnngI0/0mnUAjGOAQrV75taX xW8mf5tfJzJVPNgwpB5z3gaWb3LOiFzYOa2iHmjK16YPEawDHPBUsftJpzTrXP5az+a9 6UWA== 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=qeKSzzbqMDtEWciJm9Qsrh/SczbLK7mHOS9/ulXfvRw=; fh=4xQMyYYtmbynAmJxwWPpZ6ivTwZNkSfAt6fhFI9aNBQ=; b=r2GalNDeYS2Jsfyh265FEIL7EUL5BmJ3/kS96j91xGhPBIOZR+C8F1YgUA4OH8Baz1 t/4x1pRiUZA3oaCTaDJbq7Btt0kmS5N7dCNo8IWuUmm/Umm/wjgman0kv1rXm+ryZn19 +fx0jzUnG0TdVy/QDk3GfRytml0DQgjrc516FzLo6BW53e4AbCDEyxe8m8vewYdCmzJB Bhcj1MIX9fgDbWcocNJcrK4froxGN57quKDUUxMw1Z2NixGlqjjw9orgmKS5VT8kKVTv YTfFxJU7hzivwuLw1LeDVKwiNfhZnyz1L7H8PWkKv/6v6ie+uGPsyv+93SqTtkpHivmD Le7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eJLFIQ2V; 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 g13-20020a05620a40cd00b0078345e015casi517953qko.413.2024.01.11.06.24.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 06:24:52 -0800 (PST) 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=eJLFIQ2V; 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 1rNvyt-0004UH-JW; 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 1rNvym-0004RS-OA for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:22 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNvyl-0002pL-8K for qemu-devel@nongnu.org; Thu, 11 Jan 2024 09:24:20 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-336c5b5c163so3236972f8f.1 for ; Thu, 11 Jan 2024 06:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983056; x=1705587856; 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=qeKSzzbqMDtEWciJm9Qsrh/SczbLK7mHOS9/ulXfvRw=; b=eJLFIQ2ViPEHbpHvlkuAMDTxQdXX7VP61rA0oWJ/VzWHFYiPsovf6sfXc+ZwwzNJGb WdGKb417KFreoqXnhoN3iiLbvL//qZ2+AAoXAdtm3eMzlY2nYHDtkjhHLCNJrEvJ78pv 5k7tnNIvHi5Dt5Z/yVOJTWNo/sqe35C04RBsXm0NWG+s1dLaHuWk0cnRBjQC0OKPyJWh MKY261WV8V5p4WU22Ad90VeEyF3gFd5GcxIFwpJ0DiIFefbExzt3NvyzVg32X7loMJ6N q9X4D7S24nyCdt1H0GC6roP0x39da7CQYvOqLN0WyECWg4aWUkCuX5yCQwM75gsLwimc QRAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983056; x=1705587856; 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=qeKSzzbqMDtEWciJm9Qsrh/SczbLK7mHOS9/ulXfvRw=; b=HY+idrSZukelor1P62I5/3FAcg8TGVa7bWIZW3OHW7DrrrM4sTxSJzvrKFld8TIspN 8NGQZAEDJ8B2lP3f6vXGMPUhif6WQeJrJkwECL4WfdFzt6fD3FrpAuyQWSSyVIjW9y3s kg2gUYVQLXBdrxEG/tK5dYsaklsjPZLbj3SLgGGKRWj3iFFvViMsnGSKk5jZMyxKP6nx VpXECa0nTpshsD5g28eEGE1OkHu/mJMai/scD7VpsjQmAnjMM8yP5//ip/DrvcikL3ta 5/SW1BciCNDQQzx1+Fv15BDktfZH3H6cu9uFOvEBai/4V44sm61rKEeIH8vCMGG68RJY 7aaw== X-Gm-Message-State: AOJu0Yw82Gli5Mzym8sC56SEZUELGiqNbc70VIFnYiPvuSjatcD7yl86 vCGLaqLPvH0DvaDIBTYwTQII8ZT6Z8wU4MCRJmxBKPI9cCa9nA== X-Received: by 2002:a5d:4585:0:b0:337:49ea:3845 with SMTP id p5-20020a5d4585000000b0033749ea3845mr505884wrq.40.1704983056189; Thu, 11 Jan 2024 06:24:16 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id h7-20020adff4c7000000b0033677aae2e2sm1349000wrp.107.2024.01.11.06.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:24:15 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Mahmoud Mandour , Richard Henderson , Paolo Bonzini , Alexandre Iooss Subject: [PATCH 12/12] MAINTAINERS: Add myself as reviewer for TCG Plugins Date: Thu, 11 Jan 2024 18:23:25 +0400 Message-ID: <20240111142326.1743444-13-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 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 00ec1f7ecaf..4a621aca978 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3660,6 +3660,7 @@ TCG Plugins M: Alex Bennée R: Alexandre Iooss R: Mahmoud Mandour +R: Pierrick Bouvier S: Maintained F: docs/devel/tcg-plugins.rst F: plugins/