From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548389; cv=none; d=zohomail.com; s=zohoarc; b=epThDK4pdPiercP8pLDAsGWigjIgVQhdrBBi80cvczuOAbqqIFMauDfEaxq9WfJuMT+we1oP2gBO9aYEAQOqqHa6hL0ltHpolXvfJZvrplIvk8ex5dpCTPHJZt18zdTTQSwvTKlA7Ic15aVIzMl73BbwbMCq3q442w7ggkZhU2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BaxeeJgy+H1D/rDFzs4Zm7F3dDyijmRAjRzFwAHqBpY=; b=FKgCjQ3dX9ko0yI+ag3bF0bUqOu9PJantqXSIOC7KpctOekLNeR6uMXikv8TRk+WaxE8bxzkfC6xs6aeLXI4NKrUNvDvJ3bFzp5/+e2Tpht+K9PI2G5PxXqRRzdVEEdAl+V4J2Foqyqa398TbaVIMzN3I/SK3ujQqZshVRlHTj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17055483897901018.607348446233; Wed, 17 Jan 2024 19:26:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ0x-0003X1-DP; Wed, 17 Jan 2024 22:24:23 -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 1rQJ0v-0003Wf-O3 for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:21 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ0t-0002Pa-Le for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:21 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e8cc3b738so10673805e9.2 for ; Wed, 17 Jan 2024 19:24:18 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548257; x=1706153057; 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=BaxeeJgy+H1D/rDFzs4Zm7F3dDyijmRAjRzFwAHqBpY=; b=Qetw8A431ZNfIpQ0Ci8E0lamr6BTIge8EyKDMDr25OIYsDnyamqJ/HXfTItZl3NV1Y VhJVeNRBBa8iKPze3U9nPex4lQDyvuKk5FqgFL2PmimCnt/lo+jf0YX+rVO1py9BMdhW R7yj65tJrkHC+fFpVWVLwyUyQSNPMOGb5j4IjVS2v2rjlMPsplgnvVPj0shzeowFltJV I5Y22R8bQ+iE40yBYgz1dVHNQcbSR6a7duaH3U8T2QuGTWWJ3HuxIYR7ZVEDJNQi1NP4 gj13eodoGMnup/2WkCtda0Z+bdZew/7jqW+xVkcbd0fmhdNJ6EE4voduKTlgkJmXMplT T8Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548257; x=1706153057; 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=BaxeeJgy+H1D/rDFzs4Zm7F3dDyijmRAjRzFwAHqBpY=; b=f/eUAm44kP1gWzaSjykAhkkT7kCAuT35SQ1+XS2Z9kZ97jnYH4S8zUgBSc5kBAzi4k /0y9os0bofCKc5tnqttFbq8psxrhgqK4xEcfbYVLcPN9EAHzp1KHogHLqXFne4klB5nx E3l4XaUHjUU8sIYBr5Lgx2XglBvm63/g1uVW1NrZazZWJ3Tync/z8kwL6LzUjo8PUyVt eKJ3kWSm/wj0qpVpQdL0EIOpIkbmEcNl6+y1JY8nTCBrkbKxT2A1n05oVAfPeS6nbtX6 NkQKiOa12Y0ZFuLXM4z6QndUhlfg4ZrTizZQQCh/KRhBtFrbDd6RpEOiUFW/c4KMRrbz LSxA== X-Gm-Message-State: AOJu0YywFoSy+2s0Rskhbi5YpBtqKcVkzcqP/AkUUYCVvOQhFBpj/3S7 c5yCkTDY76FpfXGecYGgxOjaXzKvXMPcjO01hecKFBu7d1Y5K/0jFOyPR3d8w7Mq3XRQFhqtkra WNSY= X-Google-Smtp-Source: AGHT+IFmZNOgnsjfnQT2eSEuqy28Xa1OQCK5jhRj17Vpb37lYdS7pCBA+D0c0PE9EE37oNxmgogHYg== X-Received: by 2002:a7b:cc13:0:b0:40e:6948:3226 with SMTP id f19-20020a7bcc13000000b0040e69483226mr82431wmh.134.1705548257055; Wed, 17 Jan 2024 19:24:17 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 01/14] plugins: implement inline operation relative to cpu_index Date: Thu, 18 Jan 2024 07:23:46 +0400 Message-ID: <20240118032400.3762658-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548389975100002 Content-Type: text/plain; charset="utf-8" Instead of working on a fixed memory location, allow to address it based on cpu_index, an element size and a given offset. Result address: ptr + offset + cpu_index * element_size. With this, we can target a member in a struct array from a base pointer. Current semantic is not modified, thus inline operation still targets always the same memory location. Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 67 +++++++++++++++++++++++++++++++++++------- include/qemu/plugin.h | 3 ++ plugins/api.c | 7 +++-- plugins/core.c | 18 +++++++++--- plugins/plugin.h | 6 ++-- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b37ce7683e6..1a2375d7779 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -132,16 +132,28 @@ static void gen_empty_udata_cb_no_rwg(void) */ static void gen_empty_inline_cb(void) { + TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr =3D tcg_temp_ebb_new_ptr(); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGv_ptr ptr =3D tcg_temp_ebb_new_ptr(); =20 + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + /* pass an immediate !=3D 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 !=3D 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); } =20 static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -289,12 +301,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp = *op, void *ptr) return op; } =20 +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 =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op =3D 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 =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op =3D 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 =3D=3D 32) { /* 2x ld_i32 */ - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + op =3D copy_ld_i32(begin_op, op); + op =3D copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op =3D copy_op(begin_op, op, INDEX_op_ld_i64); @@ -330,6 +367,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op= , uint64_t v) return op; } =20 +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op =3D copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] =3D tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX =3D=3D UINT32_MAX) { @@ -395,18 +439,19 @@ static TCGOp *append_inline_cb(const struct qemu_plug= in_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ - op =3D copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + char *ptr =3D cb->userp; + if (!cb->inline_direct_ptr) { + /* dereference userp once to get access to memory location */ + ptr =3D *(char **)cb->userp; + } + op =3D copy_ld_i32(&begin_op, op); + op =3D copy_mul_i32(&begin_op, op, cb->inline_element_size); + op =3D copy_ext_i32_ptr(&begin_op, op); + op =3D copy_const_ptr(&begin_op, op, ptr + cb->inline_offset); + op =3D copy_add_ptr(&begin_op, op); op =3D copy_ld_i64(&begin_op, op); - - /* add_i64 */ op =3D copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op =3D copy_st_i64(&begin_op, op); - return op; } =20 diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index b0c5ac68293..9346249145d 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -86,6 +86,9 @@ enum plugin_dyn_cb_subtype { struct qemu_plugin_dyn_cb { union qemu_plugin_cb_sig f; void *userp; + size_t inline_offset; + size_t inline_element_size; + bool inline_direct_ptr; 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 8d5cca53295..e777eb4e9fc 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -106,7 +106,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qe= mu_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, sizeof(uint64_t), true, i= mm); } } =20 @@ -131,7 +132,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_INL= INE], - 0, op, ptr, imm); + 0, op, ptr, 0, sizeof(uint64_t), true, i= mm); } } =20 @@ -156,7 +157,7 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_p= lugin_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, sizeof(uint64_t), true, imm); } =20 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..e07b9cdf229 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -280,13 +280,18 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(G= Array **arr) =20 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, size_t element_si= ze, + bool direct_ptr, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; =20 dyn_cb =3D plugin_get_dyn_cb(arr); dyn_cb->userp =3D ptr; + dyn_cb->inline_element_size =3D element_size; + dyn_cb->inline_offset =3D offset; + dyn_cb->inline_direct_ptr =3D direct_ptr; dyn_cb->type =3D PLUGIN_CB_INLINE; dyn_cb->rw =3D rw; dyn_cb->inline_insn.op =3D op; @@ -431,9 +436,14 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } =20 -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 =3D cb->userp; + char *ptr =3D cb->userp; + if (!cb->inline_direct_ptr) { + ptr =3D *(char **) cb->userp; + } + ptr +=3D cb->inline_offset; + uint64_t *val =3D (uint64_t *)(ptr + cpu_index * cb->inline_element_si= ze); =20 switch (cb->inline_insn.op) { case QEMU_PLUGIN_INLINE_ADD_U64: @@ -466,7 +476,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, 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..2c278379b70 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -66,7 +66,9 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plug= in_id_t id); =20 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, size_t element_si= ze, + bool direct_ptr, uint64_t imm); =20 void plugin_reset_uninstall(qemu_plugin_id_t id, @@ -95,6 +97,6 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); =20 #endif /* PLUGIN_H */ --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548336; cv=none; d=zohomail.com; s=zohoarc; b=dCy1i8jwnnkWbBucNmzdLnq6DjQIFW06fLfRk1SUuUE/UdTNwkalHWD7vjlXDGC2FBSB2cNIy82TAfmyMn/5uxICv4Vl/4hUnQGVblBzOOOMgaZSnVeBjeAAyFzYAWZ5FQz6+uCoc28eJ84Fo71tWunRLSTTUU02FugrvNwXXN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548336; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z1Wm3BuytIxY9I50Ihr9Vi6BnC2ipwOgCPrtejpdauQ=; b=KSnsKSd+hQFhxK+k99sNLUj/hpLpkXV1vuNfTXQ3Izo/AeXPRtu7yVBzToNq9+1mwW2vUFiM3qFqN1TEzqZHEqtMxJfFNT2K19ubhcmNbvbcNEDx7V1YbqCml1scRSB8JuSIXKuuMDyUa+Os5M/du/uZYCnzrZjiWCmrszkopXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548336062593.7832391760797; Wed, 17 Jan 2024 19:25:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ0z-0003XX-Kp; Wed, 17 Jan 2024 22:24:25 -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 1rQJ0y-0003X9-2M for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:24 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ0v-0002WT-UY for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:23 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40e80046264so38494705e9.0 for ; Wed, 17 Jan 2024 19:24:21 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548259; x=1706153059; 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=Z1Wm3BuytIxY9I50Ihr9Vi6BnC2ipwOgCPrtejpdauQ=; b=O5ySr9os8TLR/qM4/TA+ces7YWDh+QJJ3N1meCTKQducr4CwgVI2IRyKoxK0qyv4pA JpXccWnT0bekvVMJQH4KoQjpXi+13tG3dhCHNBuzHfmyAGeyQICy7Ss1EQvVm1dDvHE8 fMJkCUnuVdNtSGwKI/I+C45lD3jUGgHerQaRLmFWGMsJM/q5hNybMLlnATRTP7NVPsxi xCbu0dtblIRgWccbP6/I+zH2XiJM3Gi8I/sjYSI1yGshbYRMwaYnpH2ZvcO2PJwesr7o HPyiZVZFjdYRGdyC6yHDSMa82i4ndgYo8qn9UBdMse+jnhX0BTd0K9wmTTbSyNHN+cH1 nE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548259; x=1706153059; 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=Z1Wm3BuytIxY9I50Ihr9Vi6BnC2ipwOgCPrtejpdauQ=; b=cdqlkTlsegh+u4WdOxfQhQQX2QTyDGJntsdjUw4luiz28sxd1XC2n7F4fiorWwBtK2 +/sP7O7ySk/hEbG+SS/fITAMX7UWDYG9pN3LjzR1C0guEhlP+4tiFbNaafEqRhMgZyk2 XGOTP6Xv4zIPnKI9b0Er7dI5OhxmFMYHB44zyJ/5XVMC7ocutZEqj9LN35+15IQqNeQ+ yc60s7yMcIrLJfvI3pAaCmpMigfXufCKwXV2c/CwhqQfWz4Xxdm9b2Bb+/Sdgr/x1KBx qvHVkszkbrWQ0DpSHh+nCSt2D5o37GMB4sl5LUnyzMSbsVc3sjHuWDco9NvZ3twc6r+u TAkw== X-Gm-Message-State: AOJu0Ywom3LMvPOI2egvGYZoP0jxO9k9avklHLTFzePgz4fJE33TYBDR 8aMAXBRkvdasEJEJMD9kU1quoGenegUK0HplNmGP2mNYqj6aZJJ/uul77ZYOdJKoiqeDc4dwgYx 4VkA= X-Google-Smtp-Source: AGHT+IE+MXoQIAc6RqJjwcJXwy+fu2U38ishVeuiM66Xy3VHgYOjWKXXrZ45/FN0Ppjh5g6BiFijEQ== X-Received: by 2002:a05:6000:1086:b0:337:2940:ab7b with SMTP id y6-20020a056000108600b003372940ab7bmr98965wrw.1.1705548259665; Wed, 17 Jan 2024 19:24:19 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 02/14] plugins: scoreboard API Date: Thu, 18 Jan 2024 07:23:47 +0400 Message-ID: <20240118032400.3762658-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548337757100001 Content-Type: text/plain; charset="utf-8" We introduce a cpu local storage, automatically managed (and extended) by QEMU itself. Plugin allocate a scoreboard, and don't have to deal with how many cpus are launched. This API will be used by new inline functions but callbacks can benefit from this as well. This way, they can operate without a global lock for simple operations. New functions: - qemu_plugin_scoreboard_free - qemu_plugin_scoreboard_get - qemu_plugin_scoreboard_new - qemu_plugin_scoreboard_size In more, we define a qemu_plugin_u64_t, which is a simple struct holding a pointer to a scoreboard, and a given offset. This allows to have a scoreboard containing structs, without having to bring offset for all operations on a specific field. Since most of the plugins are simply collecting a sum of per-cpu values, qemu_plugin_u64_t directly support this operation as well. New functions: - qemu_plugin_u64_get - qemu_plugin_u64_sum New macros: - qemu_plugin_u64 - qemu_plugin_u64_struct Signed-off-by: Pierrick Bouvier --- include/qemu/plugin.h | 7 +++ include/qemu/qemu-plugin.h | 75 ++++++++++++++++++++++++++++ plugins/api.c | 39 +++++++++++++++ plugins/core.c | 97 ++++++++++++++++++++++++++++++++++++ plugins/plugin.h | 8 +++ plugins/qemu-plugins.symbols | 6 +++ 6 files changed, 232 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 9346249145d..5f340192e56 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -115,6 +115,13 @@ struct qemu_plugin_insn { bool mem_only; }; =20 +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { + GArray *data; + size_t size; + size_t element_size; +}; + /* * qemu_plugin_insn allocate and cleanup functions. We don't expect to * cleanup many of these structures. They are reused for each fresh diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 2c1930e7e45..934059d64c2 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -220,6 +220,23 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_i= d_t id, struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ struct qemu_plugin_insn; +/** + * struct qemu_plugin_scoreboard - Opaque handle for a scoreboard + * + * A scoreboard is an array of data, indexed by vcpu_index. + **/ +struct qemu_plugin_scoreboard; + +/** + * qemu_plugin_u64_t - uint64_t member of an entry in a scoreboard + * + * This field allows to access a specific uint64_t member in one given ent= ry, + * located at a specified offset. Inline operations expect this as entry. + */ +typedef struct qemu_plugin_u64 { + struct qemu_plugin_scoreboard *score; + size_t offset; +} qemu_plugin_u64_t; =20 /** * enum qemu_plugin_cb_flags - type of callback @@ -754,5 +771,63 @@ int qemu_plugin_read_register(unsigned int vcpu, struct qemu_plugin_register *handle, GByteArray *buf); =20 +/** + * qemu_plugin_scoreboard_new() - alloc a new scoreboard + * + * Returns a pointer to a new scoreboard. It must be freed using + * qemu_plugin_scoreboard_free. + */ +QEMU_PLUGIN_API +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize); + +/** + * qemu_plugin_scoreboard_free() - free a scoreboard + * @score: scoreboard to free + */ +QEMU_PLUGIN_API +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + +/** + * qemu_plugin_scoreboard_size() - return size of a scoreboard + * @score: scoreboard to query + */ +QEMU_PLUGIN_API +size_t qemu_plugin_scoreboard_size(struct qemu_plugin_scoreboard *score); + +/** + * qemu_plugin_scoreboard_get() - access value from a scoreboard + * @score: scoreboard to query + * @vcpu_index: entry index + * + * Returns address of entry of a scoreboard matching a given vcpu_index. T= his + * address can be modified later if scoreboard is resized. + */ +QEMU_PLUGIN_API +void *qemu_plugin_scoreboard_get(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index); + +/* Macros to define a qemu_plugin_u64_t */ +#define qemu_plugin_u64(score) \ + (qemu_plugin_u64_t){score, 0} +#define qemu_plugin_u64_struct(score, type, member) \ + (qemu_plugin_u64_t){score, offsetof(type, member)} + +/** + * qemu_plugin_u64_get() - access specific uint64_t in a scoreboard + * @entry: entry to query + * @vcpu_index: entry index + * + * Returns address of a specific member in a scoreboard entry, matching a = given + * vcpu_index. + */ +QEMU_PLUGIN_API +uint64_t *qemu_plugin_u64_get(qemu_plugin_u64_t entry, unsigned int vcpu_i= ndex); + +/** + * qemu_plugin_u64_sum() - return sum of all values in a scoreboard + * @entry: entry to sum + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64_t entry); =20 #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index e777eb4e9fc..4de94e798c6 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -547,3 +547,42 @@ static void __attribute__((__constructor__)) qemu_api_= init(void) qemu_mutex_init(®_handle_lock); =20 } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize) +{ + return plugin_scoreboard_new(element_size); +} + +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + plugin_scoreboard_free(score); +} + +size_t qemu_plugin_scoreboard_size(struct qemu_plugin_scoreboard *score) +{ + return score->size; +} + +void *qemu_plugin_scoreboard_get(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index) +{ + g_assert(vcpu_index < qemu_plugin_scoreboard_size(score)); + char *ptr =3D score->data->data; + return ptr + vcpu_index * score->element_size; +} + +uint64_t *qemu_plugin_u64_get(qemu_plugin_u64_t entry, + unsigned int vcpu_index) +{ + char *ptr =3D (char *) qemu_plugin_scoreboard_get(entry.score, vcpu_in= dex); + return (uint64_t *)(ptr + entry.offset); +} + +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64_t entry) +{ + uint64_t total =3D 0; + for (int i =3D 0; i < qemu_plugin_scoreboard_size(entry.score); ++i) { + total +=3D *qemu_plugin_u64_get(entry, i); + } + return total; +} diff --git a/plugins/core.c b/plugins/core.c index e07b9cdf229..0286a127810 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -209,6 +209,71 @@ plugin_register_cb_udata(qemu_plugin_id_t id, enum qem= u_plugin_event ev, do_plugin_register_cb(id, ev, func, udata); } =20 +struct resize_scoreboard_args { + size_t new_alloc_size; + size_t new_size; +}; + +static void plugin_resize_one_scoreboard(gpointer key, + gpointer value, + gpointer user_data) +{ + struct qemu_plugin_scoreboard *score =3D + (struct qemu_plugin_scoreboard *) value; + struct resize_scoreboard_args *args =3D + (struct resize_scoreboard_args *) user_data; + if (score->data->len !=3D args->new_alloc_size) { + g_array_set_size(score->data, args->new_alloc_size); + } + score->size =3D args->new_size; +} + +static void plugin_grow_scoreboards__locked(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.scoreboard_size) { + return; + } + + bool need_realloc =3D FALSE; + while (cpu->cpu_index >=3D plugin.scoreboard_alloc_size) { + plugin.scoreboard_alloc_size *=3D 2; + need_realloc =3D TRUE; + } + plugin.scoreboard_size =3D cpu->cpu_index + 1; + g_assert(plugin.scoreboard_size <=3D plugin.scoreboard_alloc_size); + + if (g_hash_table_size(plugin.scoreboards) =3D=3D 0) { + /* nothing to do, we just updated sizes for future scoreboards */ + return; + } + + if (need_realloc) { +#ifdef CONFIG_USER_ONLY + /** + * cpus must be stopped, as some tb might still use an existing + * scoreboard. + */ + start_exclusive(); +#endif + } + + struct resize_scoreboard_args args =3D { + .new_alloc_size =3D plugin.scoreboard_alloc_size, + .new_size =3D plugin.scoreboard_size + }; + g_hash_table_foreach(plugin.scoreboards, + &plugin_resize_one_scoreboard, + &args); + + if (need_realloc) { + /* force all tb to be flushed, as scoreboard pointers were changed= . */ + tb_flush(cpu); +#ifdef CONFIG_USER_ONLY + end_exclusive(); +#endif + } +} + void qemu_plugin_vcpu_init_hook(CPUState *cpu) { bool success; @@ -218,6 +283,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) success =3D g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, &cpu->cpu_index); g_assert(success); + plugin_grow_scoreboards__locked(cpu); qemu_rec_mutex_unlock(&plugin.lock); =20 plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); @@ -576,8 +642,39 @@ static void __attribute__((__constructor__)) plugin_in= it(void) qemu_rec_mutex_init(&plugin.lock); plugin.id_ht =3D g_hash_table_new(g_int64_hash, g_int64_equal); plugin.cpu_ht =3D g_hash_table_new(g_int_hash, g_int_equal); + plugin.scoreboards =3D g_hash_table_new(g_int64_hash, g_int64_equal); + plugin.scoreboard_size =3D 1; + plugin.scoreboard_alloc_size =3D 16; /* avoid frequent reallocation */ QTAILQ_INIT(&plugin.ctxs); qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, QHT_MODE_AUTO_RESIZE); atexit(qemu_plugin_atexit_cb); } + +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size) +{ + struct qemu_plugin_scoreboard *score =3D + g_malloc0(sizeof(struct qemu_plugin_scoreboard)); + score->data =3D g_array_new(FALSE, TRUE, element_size); + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + score->size =3D plugin.scoreboard_size; + score->element_size =3D element_size; + + qemu_rec_mutex_lock(&plugin.lock); + bool inserted =3D g_hash_table_insert(plugin.scoreboards, score, score= ); + g_assert(inserted); + qemu_rec_mutex_unlock(&plugin.lock); + + return score; +} + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + qemu_rec_mutex_lock(&plugin.lock); + bool removed =3D g_hash_table_remove(plugin.scoreboards, score); + g_assert(removed); + qemu_rec_mutex_unlock(&plugin.lock); + + g_array_free(score->data, TRUE); + g_free(score); +} diff --git a/plugins/plugin.h b/plugins/plugin.h index 2c278379b70..99829c40886 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -31,6 +31,10 @@ struct qemu_plugin_state { * but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + /* Scoreboards, indexed by their addresses. */ + GHashTable *scoreboards; + size_t scoreboard_size; + size_t scoreboard_alloc_size; DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); /* * @lock protects the struct as well as ctx->uninstalling. @@ -99,4 +103,8 @@ void plugin_register_vcpu_mem_cb(GArray **arr, =20 void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); =20 +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size); + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + #endif /* PLUGIN_H */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6963585c1ea..93866d1b5f2 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -38,10 +38,16 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_scoreboard_free; + qemu_plugin_scoreboard_get; + qemu_plugin_scoreboard_new; + qemu_plugin_scoreboard_size; qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; + qemu_plugin_u64_get; + qemu_plugin_u64_sum; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; }; --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548276; cv=none; d=zohomail.com; s=zohoarc; b=OXyMdWjJmmTuEIrkrGwEW8MD9bDNi6Vw1N1MlmADGLXF9HXIgywBDtrWMXQ+77Cgg7ZV0ECS1ypmJZzeZFwjaSFgIiDx09IJLcRRKWrojXZkyPddwMDyXnuYM30JJ98sOTvWZFmusqD0gopJ5LDch+IkGMVTjJQYT04I3Xcu9R0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548276; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; b=M0weGbNEuY2IdbgbD+uN3c7rm+9rsQILy14DPREfxNMYqdf9sCw9ig3CdOx92xDLU2eESx0bveSic9SZqs9rNja+rqdQseZX/aRNeG81W6mG5TvrJ+67PVw2kmXDXSC6aL8OY9CkYRvuH9TRD/XZbyw5O+PTJ8uDrtBObC2j4Kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548276921799.4851237937667; Wed, 17 Jan 2024 19:24:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ12-0003Y5-2w; Wed, 17 Jan 2024 22: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 1rQJ10-0003Xo-FC for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:26 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ0z-0002bw-0D for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:26 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e90163be1so1817385e9.1 for ; Wed, 17 Jan 2024 19:24:24 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548262; x=1706153062; 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=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; b=qAhhsCA2CZUSKteNTjSg+gDJiQClJLQd45gcyC10Opq4y7Py5HWBvSb3ty88OEVvki H0OQHV3LO82k8cPFRoKJSbRuMowOCu7YCsNU2j49GMEJTU6Wh6lo6mLwTvbJuz5AiJwP /6YWVtNpooAm/3pr8P4YSsDGPhOFpzMpB6tgJMaE67CWlGHIbCbyx7mZmPhr/M5EBExv Ge2lLdSx5flJOY818uStiiy25cD8PBt5gcJ/UH3Lh9LYy+Qg+faNt4qUAii7q08n8xX9 cjjKOfbpQdFXCP2os0e/wP1rhVzN9RY1BUesltjpq8utM9kDMGagIvg6BGc5gOldpBnd yCTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548262; x=1706153062; 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=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; b=fTk1fjzM07vNp6j9shgMuseXwNUIypmy/CvM2n1BxfzeIT9r7ZiHyt9lNBzVbQZ2sO V5k5YIR1wSleNKHp+qOZEUQaW3GBk/sghClfDcxwRlDbzyuizYVuC6VoGs3OXc2YjTej 5yzvwguc6gkTelUNCEulcR1a/OxqyZRFieRqk2h1pswCHDdrDdGB1fMqRy9UFx03nM/g hn4zxAqxiZzEdytw7xwaVzK65byn3hlXD9zmrpUZf4THyrJRHTH7XDEUg9jMlfCE3qFP LZAm4Z3/sr6w3FCtkWulLYijE3qGTtnEZlp5xX7nBPnoGyUaCHCvQTC1BU/TLQnz0hO7 Jenw== X-Gm-Message-State: AOJu0YyaQgMF4uZZYdqSe8qIOU3C2rElLFwCTI/Cf2F8+rQ/z7n81i11 CUw26JuL1J/DI4UP4Du5MmrDRZki89Ud3MbX1JimEaAhYrGQYrW/FwxCvxT4kci65Mudt3uoGCB rZo0= X-Google-Smtp-Source: AGHT+IHpyWGs8Lq19lXKZXnpYoxZta6Xry7pR0X3v/TIrjAy3c2Ax6YxKkjqRjtW3Slc2U5pPrgmrQ== X-Received: by 2002:a5d:4a42:0:b0:337:c558:805 with SMTP id v2-20020a5d4a42000000b00337c5580805mr44130wrs.88.1705548262246; Wed, 17 Jan 2024 19:24:22 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 03/14] docs/devel: plugins can trigger a tb flush Date: Thu, 18 Jan 2024 07:23:48 +0400 Message-ID: <20240118032400.3762658-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548277775100001 Content-Type: text/plain; charset="utf-8" When scoreboards need to be reallocated. Signed-off-by: Pierrick Bouvier --- docs/devel/multi-thread-tcg.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/devel/multi-thread-tcg.rst b/docs/devel/multi-thread-tcg.= rst index 7302c3bf534..1420789fff3 100644 --- a/docs/devel/multi-thread-tcg.rst +++ b/docs/devel/multi-thread-tcg.rst @@ -109,6 +109,7 @@ including: - debugging operations (breakpoint insertion/removal) - some CPU helper functions - linux-user spawning its first thread + - operations related to TCG Plugins =20 This is done with the async_safe_run_on_cpu() mechanism to ensure all vCPUs are quiescent when changes are being made to shared global --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548389; cv=none; d=zohomail.com; s=zohoarc; b=jHmJ5NFx1RcE4bAuH2zuh1K6kluS3QwZmBWjlMeggp9n8YlU+KJMA+RJv1BCgn4yZQycNJNEVNeDekTwVs38qQeCGiaLKpjkt5NwO0zp0oFAucnLkFoKHfOpbBlcpJabReE1xQI0NBux88BmJbhyjtUj4WaDdNBpnlxUgnH+cSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=avAAc0Vlx/SbBP3d3CcEQtIUcAU9hvFMhQ4VLfaD1p0=; b=gRszpk8nd6/LSaMo5rIxn/IADcsBf7gRWCEtkZE5rsQ5i2z6HZY4Hwy+3VlDmjYQxlZm/VY1UTdbSjHj75nRrh9HwGAcmXDFu1TYTmmh3BdM6N2j/cq5mbkHKVa9NwD/7Zz+ryrEKY6cG9u70D5lWLD9QQ6gO95w02eEfhgrGSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548389570235.05488825227656; Wed, 17 Jan 2024 19:26:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ17-0003cq-Bg; Wed, 17 Jan 2024 22:24:33 -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 1rQJ13-0003YF-NN for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:29 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ11-0002cI-BJ for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:29 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-337c7148a71so711518f8f.2 for ; Wed, 17 Jan 2024 19:24:26 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548265; x=1706153065; 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=avAAc0Vlx/SbBP3d3CcEQtIUcAU9hvFMhQ4VLfaD1p0=; b=bHccsBOOJpgBhVER1p4b65HUJ1X1S3iNEQYkC1DXToxnetF9XWgPhFB7zEo5X/+ceN U/T4IC1k5kJlfhQ+KcacPef7u1KlkMaDHxt/OZlDc8hNZ3fyN06aiKOkaEboPoCbqLxD Sns38/v6JLNKPxh1vRYDuJlvkN3ZKgqp6tFHAlPY+ETHrb/ljlFLVpKRFROCkhy128hj ybGUzGKMy4BMD5RS6LbEANN+fKNlBMcvfJEh8Nvq1bvncYDaVi+RaKOxcvVt/sGVUSIJ GLyMH7mlMFFoUPRoR6sMWeNVLwKuBoB03YCyTRWy9lOBLJi7FgfVINLhYLkJmPUc1ONf fX0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548265; x=1706153065; 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=avAAc0Vlx/SbBP3d3CcEQtIUcAU9hvFMhQ4VLfaD1p0=; b=WT0XUHaaL1hoJLmXtV+rTdj9g+boC2slQ4w/abwyATdMBC7vyh+Z8m7pUuRgVTPP/E fKfd/9IF1LKMe4AvYKxjcLK7463/0AhPJoEcIkr/8cuV7mGVR6STe7Wf/cYPzRP5CEIG YA6kMT8JSFqC4brWHPvO6iRPsgrrJb7xx91AyRERfEewDtW7QwsiXC2iruuZhPK042yz AOqllKz5MeXep3oGaPFCnyhu6WA9RF/xwLRwaITKuWlQu/fVKOwTtr5rRyvkmAUmDMxW Z8n2qfcckEV3sWJ5GK6tshODm4PzWKHVMHrjNQjc6uSwIuD4V49enQCqGV2qbaXGBSzF xPdA== X-Gm-Message-State: AOJu0YxEetAAzA7338gjIO2SSdYQl7KZNOA8U25paFPHpAQ2Js1F5Tte b0WqB1uTVkTMNAU4AK+PSjKvNHZ3sYdGsXMJo/5OhTpYWYVKSErJmcaAw2EsHrmCYTNPy+Ia74R SGQ0= X-Google-Smtp-Source: AGHT+IHcn28Mh4R/3QVP0SeguZWOf7+OEAVxVu2nl70YHBWURwJwYsJPftJwilSZYk49gQwyds6NPg== X-Received: by 2002:a5d:4b88:0:b0:337:c134:61d5 with SMTP id b8-20020a5d4b88000000b00337c13461d5mr42542wrt.252.1705548265167; Wed, 17 Jan 2024 19:24:25 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 04/14] plugins: add inline operation per vcpu Date: Thu, 18 Jan 2024 07:23:49 +0400 Message-ID: <20240118032400.3762658-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548389973100001 Content-Type: text/plain; charset="utf-8" Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Those functions takes a qemu_plugin_u64_t as input. This allows to have a thread-safe and type-safe version of inline operations. Signed-off-by: Pierrick Bouvier Reviewed-by: Alex Benn=C3=A9e --- include/qemu/qemu-plugin.h | 51 +++++++++++++++++++++++++++++++++++- plugins/api.c | 43 +++++++++++++++++++++++++++++- plugins/qemu-plugins.symbols | 3 +++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 934059d64c2..55f918db1b0 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -330,6 +330,22 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * 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) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op on a given scoreboard entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64_t entry, + uint64_t imm); + /** * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -360,6 +376,22 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @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, + qemu_plugin_u64_t entry, + uint64_t imm); + /** * qemu_plugin_tb_n_insns() - query helper for number of insns in TB * @tb: opaque handle to TB passed to callback @@ -585,7 +617,24 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, enum qemu_plugin_op op, void *pt= r, uint64_t imm); =20 - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @entry: entry to run op + * @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, + qemu_plugin_u64_t entry, + uint64_t imm); =20 typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_in= dex, diff --git a/plugins/api.c b/plugins/api.c index 4de94e798c6..132d5e0bec1 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -111,6 +111,20 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, } } =20 +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64_t entry, + uint64_t imm) +{ + if (!tb->mem_only) { + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, entry.score->data, + entry.offset, entry.score->element_size, + false, imm); + } +} + void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flag= s, @@ -136,6 +150,20 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, } } =20 +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64_t entry, + uint64_t imm) +{ + if (!insn->mem_only) { + plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INL= INE], + 0, op, entry.score->data, + entry.offset, entry.score->element_size, + false, imm); + } +} + =20 /* * We always plant memory instrumentation because they don't finalise until @@ -148,7 +176,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugi= n_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULA= R], - cb, flags, rw, udata); + cb, flags, rw, udata); } =20 void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, @@ -160,6 +188,19 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, rw, op, ptr, 0, sizeof(uint64_t), true, imm); } =20 +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, + qemu_plugin_u64_t entry, + uint64_t imm) +{ + plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], + rw, op, entry.score->data, + entry.offset, entry.score->element_size, + false, imm); +} + void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t = cb) { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 93866d1b5f2..a499cee06d5 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -29,13 +29,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_scoreboard_free; --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548298; cv=none; d=zohomail.com; s=zohoarc; b=GTx/Dn8g4JKS0ZVHMZViDXRC88euSY+03GmQcL/eYMsJXzA+OAfNXHp+Us5VaN3QYwcTvEh7Z6eQ2PatNfjSbFFx+ZQvdQh2FrT4sgoRW2dYI7mD2v63m2cvhLTxwccw0yVmpAqnetV/RgRgJlom2f7JCrWSMsbdEyHhWvxFFjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548298; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oP8DElGhxgrlgCtIGb2Ytj2mtZyUCbfff7H8LKle7FM=; b=HltZ2Kegjtm94sZaKX2mBgIaD60PvN6a8JDdwjMOQkZobxZFBNF6VSmu5wAMnv6z+CwwkvPhh66zj9/3MpA6lf4Q/hSstGNu92FIGsJj9s/2Q6Q9hpneQatPS/E/wKOzrKGjO7d6F2qLFS3yzPUEkXw53uU3WtToAFf0S0t8Boc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548298404957.0572493869699; Wed, 17 Jan 2024 19:24:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ19-0003ek-QF; Wed, 17 Jan 2024 22:24:35 -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 1rQJ16-0003b9-2v for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:32 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ13-0002cj-Ve for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:31 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40e7065b7bdso47198155e9.3 for ; Wed, 17 Jan 2024 19:24:29 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548268; x=1706153068; 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=oP8DElGhxgrlgCtIGb2Ytj2mtZyUCbfff7H8LKle7FM=; b=lfyupez8eTNOe6aSKBJxzIPAnFWCCtPSx5DFORO8MQUDITTA6fSzGs1lCUmVQJC6QJ LmwJghH6yvr8AjxIhE9xp1CsrujxfBtxCZcyt6cnakX7O6IJ7qpN8bbPZ2+zPFfkJzTR A/l0MaJR5ou2jXmySI9WtdVD9TDzdcfCu7ew453PwikjlzeGuHOHCMBTr8QYTQ4qG/H4 mUf3OvIZApjF3gsYoruS3V7UewpJ1sGMTPLO0UsmPO6a6QbYu1W/+aoecUFJYjHIXQlc uopVZRLeNonetyHnPyycj9z8/tOyPQrk7EwfcApM3VPnFq9oCSLIRJyvhXIuYGW7DeEs UuLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548268; x=1706153068; 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=oP8DElGhxgrlgCtIGb2Ytj2mtZyUCbfff7H8LKle7FM=; b=wib48YrAZF+d5T6YW2XhfcyJ8FKELWGYFaJgqEiGyw+gJzjYKfZFUX9GYxjsgqW48z PmtyCrvCxJr075RJobKsL+9uigDDrUhBbceNYeiQIG5LCRomwq04XlzYpS0ts6mDG2qY AmYrZTY3zr2ANmZ5J5squq1AlGMPTAMhxbHdWyFkNIpxEHu/gJrNqhJ+qO77FvVLywsT qb7yfwaHiIBReYY3VgZK5ZKA/b27sPxG3V5uHR1R1z/2VXZnPk1qZlmPrpvFeLemJ22P l4YykOKaDt2v5UBqgtGjXXgGG8z9HcwyRFO2+BhjVbBTWzpRzU2083gtDk9fq/+OVqEM CxKQ== X-Gm-Message-State: AOJu0YwcA1vmXQC4BnxijvTTOLkpte9jezErqWAmQaWszPq8Af2nVET5 dtOQgxtWMKGOI2FBdE4OwzhaC5bt56u2i1Cx9vnTBK7oH5rrbTmLuQ0ksV/4QaZnxbH4OogEnEu Cvo0= X-Google-Smtp-Source: AGHT+IEyCx87uzMdCnU7ZgCgJ/svLjmUSSDk8XtpPbeQSr3QHl9hIElBaCcizuk9EFmIg5yPKvq+pQ== X-Received: by 2002:a7b:cb8d:0:b0:40d:8550:878d with SMTP id m13-20020a7bcb8d000000b0040d8550878dmr74695wmi.15.1705548267823; Wed, 17 Jan 2024 19:24:27 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 05/14] tests/plugin: add test plugin for inline operations Date: Thu, 18 Jan 2024 07:23:50 +0400 Message-ID: <20240118032400.3762658-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548299736100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Alex Benn=C3=A9e --- tests/plugin/inline.c | 182 +++++++++++++++++++++++++++++++++++++++ tests/plugin/meson.build | 2 +- 2 files changed, 183 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..28d1c3b1e48 --- /dev/null +++ b/tests/plugin/inline.c @@ -0,0 +1,182 @@ +/* + * 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 + +typedef struct { + uint64_t count_tb; + uint64_t count_tb_inline; + uint64_t count_insn; + uint64_t count_insn_inline; + uint64_t count_mem; + uint64_t count_mem_inline; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64_t count_tb; +static qemu_plugin_u64_t count_tb_inline; +static qemu_plugin_u64_t count_insn; +static qemu_plugin_u64_t count_insn_inline; +static qemu_plugin_u64_t count_mem; +static qemu_plugin_u64_t count_mem_inline; + +static uint64_t global_count_tb; +static uint64_t global_count_insn; +static uint64_t global_count_mem; +static unsigned int max_cpu_index; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +static void stats_insn(void) +{ + const uint64_t expected =3D global_count_insn; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_insn); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_insn_inline); + printf("insn: %" PRIu64 "\n", expected); + printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_tb(void) +{ + const uint64_t expected =3D global_count_tb; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_tb); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_tb_inline); + printf("tb: %" PRIu64 "\n", expected); + printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_mem(void) +{ + const uint64_t expected =3D global_count_mem; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_mem); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_mem_inline); + printf("mem: %" PRIu64 "\n", expected); + printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + const unsigned int num_cpus =3D qemu_plugin_scoreboard_size(counts); + g_assert(num_cpus =3D=3D max_cpu_index + 1); + + for (int i =3D 0; i < num_cpus ; ++i) { + const uint64_t tb =3D *qemu_plugin_u64_get(count_tb, i); + const uint64_t tb_inline =3D *qemu_plugin_u64_get(count_tb_inline,= i); + const uint64_t insn =3D *qemu_plugin_u64_get(count_insn, i); + const uint64_t insn_inline =3D *qemu_plugin_u64_get(count_insn_inl= ine, i); + const uint64_t mem =3D *qemu_plugin_u64_get(count_mem, i); + const uint64_t mem_inline =3D *qemu_plugin_u64_get(count_mem_inlin= e, 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 =3D=3D tb_inline); + g_assert(insn =3D=3D insn_inline); + g_assert(mem =3D=3D mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); + + qemu_plugin_scoreboard_free(counts); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + (*qemu_plugin_u64_get(count_tb, cpu_index))++; + g_mutex_lock(&tb_lock); + max_cpu_index =3D MAX(max_cpu_index, cpu_index); + global_count_tb++; + g_mutex_unlock(&tb_lock); +} + +static void vcpu_insn_exec(unsigned int cpu_index, void *udata) +{ + (*qemu_plugin_u64_get(count_insn, cpu_index))++; + g_mutex_lock(&insn_lock); + global_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) +{ + (*qemu_plugin_u64_get(count_mem, cpu_index))++; + g_mutex_lock(&mem_lock); + global_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_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); + + for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn =3D 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_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 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_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + count_mem_inline, 1); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + count_tb =3D qemu_plugin_u64_struct(counts, CPUCount, count_tb); + count_insn =3D qemu_plugin_u64_struct(counts, CPUCount, count_insn); + count_mem =3D qemu_plugin_u64_struct(counts, CPUCount, count_mem); + count_tb_inline =3D qemu_plugin_u64_struct(counts, CPUCount, count_tb_= inline); + count_insn_inline =3D + qemu_plugin_u64_struct(counts, CPUCount, count_insn_inline); + count_mem_inline =3D + qemu_plugin_u64_struct(counts, CPUCount, count_mem_inline); + 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 =3D [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os =3D=3D 'windows' t +=3D shared_module(i, files(i + '.c') + '../../contrib/plugins/win= 32_linker.c', include_directories: '../../include/qemu', --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548303; cv=none; d=zohomail.com; s=zohoarc; b=NBnSivhUfv1DgrjiSkFh89VzgKgCiE2tIFKQthc9O/pNsUX2zzpughZIyHKgLnUSJprnubrcQcNEDHRsZMhtXfMV3K6R8oCRO46c7zv3wJNcI9RhXGjFoCKCyW/GOl0zmWc0gQA/9SSLILRzQs8qIVVt1y3DlQbvelxwdUXGfHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548303; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=llai94LBCUTj3dfHKAUWRulZm20ERaPuqBXTHgqZDnw=; b=VK+toybAIlYF4NDBXkAVAoFKnwqkunh5O+4SDx+kzmM398tfxIJP/yjCgH8oDtAKpvCmMS1oz6OrqcytOliHRnuDhDskkZX7kK8RkXhlWVhjmv/A5AIL054+h0BiaxdTIKZyNVYHUWrYFhXsFgKEMpQL+XzveBxxYxqnenyLnb8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548302999135.7803778439595; Wed, 17 Jan 2024 19:25:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1B-0003ia-M3; Wed, 17 Jan 2024 22:24:37 -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 1rQJ18-0003eh-Gz for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:35 -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 1rQJ16-0002eq-RI for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:34 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-337c4f0f9daso957687f8f.2 for ; Wed, 17 Jan 2024 19:24:32 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548270; x=1706153070; 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=llai94LBCUTj3dfHKAUWRulZm20ERaPuqBXTHgqZDnw=; b=SbP0lnJdwDmTQap5ZyDxSsa0JxdL3rMLnaZtXreTBmTajfEqkFq7g1mHvCRl0zIh0f vQsPR9jiHBsKqNa7ZSI0r8vejJNdXEBI0OlOaP10zn8Kq3hI1oz3jr8YIbQU9oTvGnYW 7nknhyaqjA/4YmenEvsBLd/9ugOk9qu+6UBUXJb6LVqKf4IZ8VM6zs1XqKoos+jujUlh L95gvEV0mDg8Cmln83U2Dz08w9iCohxKAkFOF4c3TK++Pxv5bJZCecVO0tOd9aXIfyb4 bIK/D8KphvaDHxOUdaEjL4tBZEcWUE9BwV6jYrGDQmlLNlS3dgrjMxHn7bQ5UJbL4Ut1 2vsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548270; x=1706153070; 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=llai94LBCUTj3dfHKAUWRulZm20ERaPuqBXTHgqZDnw=; b=Je2Yk57HNMJ9eYUiTxCErPh//MzPgSOhjIcWs/bMxIKp849QRnxXz7dnrU993X0wh0 hxQYE+zxFaY0lCe7bsbT6mRvW9v03bn1A0ZTWVPDkYMqK5gTrVp0vsAZekg2ZD/kLo5F TyIR6d8cScTI6+guM6aLnbvb8Pzn/1fIv8rSHxxS0+2e1fqIICHVgrX4Hl2VPJa/Vq3c cjKiCiU5I4Jjxpq+YSP8WfAAPPcEYZHc1p2hlKqT7Ja3LKvwGoPdkWH7mIcslLCqv3dU zZ56ZORdtYgoyo66MdKisPZBTuGNCgw4oyBgf3mhoTfS9A2IxgqJPeN6FX8ywjV/1GH/ yGfQ== X-Gm-Message-State: AOJu0Yw5SRXhq36FiNFNsLtpCO/pw4Uav7zwCoQrndCLAia72Ab3XXio Q12Jiayj/TNyLq1wjHA7BN3V3hmX/cruM3FzgISlqbh6Bn1/RUKDb1nBBtmK3M1oRvYoF53WuXm M8kw= X-Google-Smtp-Source: AGHT+IHr8LujjqKgsTARQGfi9vk7DuZpM7YMWXOGxV0WVSGcGXZuCvtDMI6Who+yMMIMIABsYu4dpg== X-Received: by 2002:adf:ea4a:0:b0:337:b4db:321f with SMTP id j10-20020adfea4a000000b00337b4db321fmr78819wrn.110.1705548270402; Wed, 17 Jan 2024 19:24:30 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 06/14] tests/plugin/mem: migrate to new per_vcpu API Date: Thu, 18 Jan 2024 07:23:51 +0400 Message-ID: <20240118032400.3762658-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548303583100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 44e91065ba7..83b7fa1f187 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -16,9 +16,14 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -static uint64_t inline_mem_count; -static uint64_t cb_mem_count; -static uint64_t io_count; +typedef struct { + uint64_t mem_count; + uint64_t io_count; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64_t mem_count; +static qemu_plugin_u64_t io_count; static bool do_inline, do_callback; static bool do_haddr; static enum qemu_plugin_mem_rw rw =3D QEMU_PLUGIN_MEM_RW; @@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out =3D g_string_new(""); =20 - if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_= mem_count); - } - if (do_callback) { - g_string_append_printf(out, "callback mem accesses: %" PRIu64 "\n"= , cb_mem_count); + if (do_inline || do_callback) { + g_string_printf(out, "mem accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(mem_count)); } if (do_haddr) { - g_string_append_printf(out, "io accesses: %" PRIu64 "\n", io_count= ); + g_string_append_printf(out, "io accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(io_count)); } qemu_plugin_outs(out->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -46,12 +51,12 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugi= n_meminfo_t meminfo, struct qemu_plugin_hwaddr *hwaddr; hwaddr =3D qemu_plugin_get_hwaddr(meminfo, vaddr); if (qemu_plugin_hwaddr_is_io(hwaddr)) { - io_count++; + (*qemu_plugin_u64_get(io_count, cpu_index))++; } else { - cb_mem_count++; + (*qemu_plugin_u64_get(mem_count, cpu_index))++; } } else { - cb_mem_count++; + (*qemu_plugin_u64_get(mem_count, cpu_index))++; } } =20 @@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qe= mu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U6= 4, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + mem_count, 1); } if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, @@ -117,6 +123,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, } } =20 + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + mem_count =3D qemu_plugin_u64_struct(counts, CPUCount, mem_count); + io_count =3D qemu_plugin_u64_struct(counts, CPUCount, io_count); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548328; cv=none; d=zohomail.com; s=zohoarc; b=kb5VnFO8eNtBKRXb989DJ78snLDXpoV5H9VKms7FIRCnnnc1uORpziggBpYsEES139x/lr5BHkmecWdXf22JS87rn6Lrpte6u3cwSfEiIZ9+TpB9gI6a6n6YPYJS1vpXQ5b0MLygcRgJ4dRbT/uJMUsf/RQnNVIuKaOJOpHf6EA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548328; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k5p6lYRvka4FY/ZAhzAOUj9HGQolA6nHRzKa6RDIFjg=; b=AOo6t0X0xZ+gwvdLMoZKtxhFRLOWOsk8YgVhJq/Tu+YoIs4lM4IIrwE15qqy/A2KdK2OdogmAJs1PDZk/1lCwn1G9tZtCw5L9s2hXKSO8FOPiBMBxiLhQ/AsSoex5kzOWadbi1UjApRUeQEd79PE7X+xPJRpI58JS8X6rldygTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548328894819.9247070164106; Wed, 17 Jan 2024 19:25:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1C-0003jc-UX; Wed, 17 Jan 2024 22:24:38 -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 1rQJ1B-0003hl-1W for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:37 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ19-0002n6-6F for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:36 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-337bcf021a4so1565600f8f.0 for ; Wed, 17 Jan 2024 19:24:34 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548273; x=1706153073; 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=k5p6lYRvka4FY/ZAhzAOUj9HGQolA6nHRzKa6RDIFjg=; b=Wq1wlxvmRvvb4VUa9r/V++mjCyC1XD7B06oBcg02qSxhyjYKHDr2Bjy7UtqgOz4PPv huTnZg0rjr6S+3eHqly4Tc/pqgOfd+oh7E5NFDpqgjw3a/tFD8Z2BC1nYwvsrYe/xoX7 NLH0yjtoCgakn/F6gL3O/1cwdywItvbEb6KObP2yVB/EE5TFIaScfWr2EI+jaJApcjh2 WA5PIw0Hm1QrteUBJS0Tz5Y0TlDrQeP26l8gq67ZuHR/WHyIFJ49jwPtbNkrLpN1qklB cB3Uj/JND6qMqGTNXJoTitBScBFt7ohCM9jqFiUKop1enGi/9EOVMtHvrW7/YQWw+2CT q0zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548273; x=1706153073; 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=k5p6lYRvka4FY/ZAhzAOUj9HGQolA6nHRzKa6RDIFjg=; b=BqxzWdQF3chRC0dNUjzczzaOiWbNfPFRuEkNloWHvIctB7jRiYZZNGAHUmub9kz/JT 1x6mrYjX9zDZAB/u2FwpyPaJNrvn+kwfNr/7nIy8pAzwiP/S5weB40uftpCIPhGv5TeR ajBNhjPlxkkFJ+b3xX2+uJuemwIXnklDzprt2kkmhi7RWUPoI8QPPl2P4mppoLDLgKTS rIvyHrTMzN9dBYS+H74Ubw4mfR03YUURuKz8huQReHPanS3u47XhjRaj46xH3dB02Ld/ TSx5wHFeQMaOkOp8zyMu+toYquP1Mt8a6uOulHQbaxheZJ1BRnrw6LYXDcT3DMp23sUq xfnw== X-Gm-Message-State: AOJu0YwNgOWAsG1nCKvdL5gFuTwB72TjgzB2RVkN4hFGCAjtj1wOsDhF GB2MkvKfG6qtLvxBJ2plVb91Jouko4jHyG2qqlJiZmGITz+EOs/FEA2cgi1I9PTYMQw5TF+0UXn 5G7s= X-Google-Smtp-Source: AGHT+IGto5q+5YhCAl9bMtsHInwsM5QzW3owJ9QbLEu2YLz895yiENMBWNnpmFihktFSrggdyM473g== X-Received: by 2002:adf:d1e7:0:b0:337:5588:801f with SMTP id g7-20020adfd1e7000000b003375588801fmr105820wrd.57.1705548273147; Wed, 17 Jan 2024 19:24:33 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 07/14] tests/plugin/insn: migrate to new per_vcpu API Date: Thu, 18 Jan 2024 07:23:52 +0400 Message-ID: <20240118032400.3762658-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548329748100002 Signed-off-by: Pierrick Bouvier --- tests/plugin/insn.c | 106 +++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 56 deletions(-) diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 5fd3017c2b3..6fff51121d4 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -16,25 +16,21 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -#define MAX_CPUS 8 /* lets not go nuts */ - -typedef struct { - uint64_t insn_count; -} InstructionCount; - -static InstructionCount counts[MAX_CPUS]; -static uint64_t inline_insn_count; +static qemu_plugin_u64_t insn_count; =20 static bool do_inline; static bool do_size; static GArray *sizes; =20 +typedef struct { + uint64_t hits; + uint64_t last_hit; + uint64_t total_delta; +} MatchCount; + typedef struct { char *match_string; - uint64_t hits[MAX_CPUS]; - uint64_t last_hit[MAX_CPUS]; - uint64_t total_delta[MAX_CPUS]; - GPtrArray *history[MAX_CPUS]; + struct qemu_plugin_scoreboard *counts; /* MatchCount */ } Match; =20 static GArray *matches; @@ -48,41 +44,40 @@ typedef struct { =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i =3D cpu_index % MAX_CPUS; - InstructionCount *c =3D &counts[i]; - - c->insn_count++; + (*qemu_plugin_u64_get(insn_count, cpu_index))++; } =20 static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *ud= ata) { - unsigned int i =3D cpu_index % MAX_CPUS; Instruction *insn =3D (Instruction *) udata; - Match *match =3D insn->match; + Match *insn_match =3D insn->match; + MatchCount *match =3D qemu_plugin_scoreboard_get(insn_match->counts, + cpu_index); + g_autoptr(GString) ts =3D g_string_new(""); =20 insn->hits++; g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", insn->vaddr, insn->disas, insn->hits); =20 - uint64_t icount =3D counts[i].insn_count; - uint64_t delta =3D icount - match->last_hit[i]; + uint64_t icount =3D *qemu_plugin_u64_get(insn_count, cpu_index); + uint64_t delta =3D icount - match->last_hit; =20 - match->hits[i]++; - match->total_delta[i] +=3D delta; + match->hits++; + match->total_delta +=3D delta; =20 g_string_append_printf(ts, - ", %"PRId64" match hits, " - "=CE=94+%"PRId64 " since last match," + " , cpu %u," + " %"PRId64" match hits," + " =CE=94+%"PRId64 " since last match," " %"PRId64 " avg insns/match\n", - match->hits[i], delta, - match->total_delta[i] / match->hits[i]); + cpu_index, + match->hits, delta, + match->total_delta / match->hits); =20 - match->last_hit[i] =3D icount; + match->last_hit =3D icount; =20 qemu_plugin_outs(ts->str); - - g_ptr_array_add(match->history[i], insn); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -94,8 +89,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qem= u_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 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, insn_count, 1); } else { uint64_t vaddr =3D qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( @@ -117,10 +112,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) * information about the instruction which we also need to * save if there is a hit. */ - if (matches) { + if (matches->len) { char *insn_disas =3D qemu_plugin_insn_disas(insn); - int j; - for (j =3D 0; j < matches->len; j++) { + for (int j =3D 0; j < matches->len; j++) { Match *m =3D &g_array_index(matches, Match, j); if (g_str_has_prefix(insn_disas, m->match_string)) { Instruction *rec =3D g_new0(Instruction, 1); @@ -150,36 +144,34 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "len %d bytes: %ld insns\n", i, *cn= t); } } - } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_co= unt); } else { - uint64_t total_insns =3D 0; - for (i =3D 0; i < MAX_CPUS; i++) { - InstructionCount *c =3D &counts[i]; - if (c->insn_count) { - g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", - i, c->insn_count); - total_insns +=3D c->insn_count; - } + unsigned int num_cpus =3D qemu_plugin_scoreboard_size(insn_count.s= core); + for (i =3D 0; i < num_cpus; i++) { + g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", + i, *qemu_plugin_u64_get(insn_count, i)); } g_string_append_printf(out, "total insns: %" PRIu64 "\n", - total_insns); + qemu_plugin_u64_sum(insn_count)); } qemu_plugin_outs(out->str); + + qemu_plugin_scoreboard_free(insn_count.score); + for (i =3D 0; i < matches->len; ++i) { + Match *m =3D &g_array_index(matches, Match, i); + g_free(m->match_string); + qemu_plugin_scoreboard_free(m->counts); + } + g_array_free(matches, TRUE); + g_array_free(sizes, TRUE); } =20 =20 /* Add a match to the array of matches */ static void parse_match(char *match) { - Match new_match =3D { .match_string =3D match }; - int i; - for (i =3D 0; i < MAX_CPUS; i++) { - new_match.history[i] =3D g_ptr_array_new(); - } - if (!matches) { - matches =3D g_array_new(false, true, sizeof(Match)); - } + Match new_match =3D { + .match_string =3D g_strdup(match), + .counts =3D qemu_plugin_scoreboard_new(sizeof(MatchCount)) }; g_array_append_val(matches, new_match); } =20 @@ -187,6 +179,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, const qemu_info_t *info, int argc, char **argv) { + matches =3D g_array_new(false, true, sizeof(Match)); + /* null terminated so 0 is not a special case */ + sizes =3D g_array_new(true, true, sizeof(unsigned long)); + for (int i =3D 0; i < argc; i++) { char *opt =3D argv[i]; g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); @@ -208,9 +204,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, } } =20 - if (do_size) { - sizes =3D g_array_new(true, true, sizeof(unsigned long)); - } + insn_count =3D qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint6= 4_t))); =20 qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548327; cv=none; d=zohomail.com; s=zohoarc; b=BhWq866bzMYBPPj7QpyI7W8P7vsHLm41YpA8uY+fRpc8CHv4TMmSEmg/BI5CNw6Hzd3ERw/hvFW8NmFA9Ml5AE844Va8XGFK+CgPjU4JDyTnYUnmT9ktoWRzS9xckXmjf18xbWo62XL9oxYttyZ5Od+b3Quj0dI5WiJ00Vnsyj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548327; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q4Xlbv7w1QB06viMEvJrvyI5kfhMiq7AkgJexCqUX1c=; b=nrYnalzAse2foubMFLNyYQUx6+6OM+dUqY7gZxTWeGmTMMkLQcjB3UP0HEMNCa/oNa+VYqr9p1uPSr/XRTfSt+xdnFG8rvsz/NWaBb40/FtNPZIOMnM3/i/gQVRZUANINOXf6puwfskLYm93Ci9V6hthvku1k5Gm32ukykVx9f8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548327929689.3448007521954; Wed, 17 Jan 2024 19:25:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1F-0003k7-7b; Wed, 17 Jan 2024 22:24:41 -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 1rQJ1D-0003jl-Kt for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:39 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ1B-0002pi-UX for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:39 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40e8ff22383so2068995e9.0 for ; Wed, 17 Jan 2024 19:24:37 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548275; x=1706153075; 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=q4Xlbv7w1QB06viMEvJrvyI5kfhMiq7AkgJexCqUX1c=; b=stWR7/3GPjWokEno9tr/fy8azeBY+Igq9dPuHlmt0q1VrsQJChu6g8By9LMHsaLjLR cPZkWoDdO81WIVy8iEeLGF5UmJZYVZ/mnYgktWRKrbXD0Usi7G4TAnlhlkSerqEELyVw P0BifO7N5T+XogS49qVUpdCkDA6VCAxQJvSq1MqdooGPtSLBiGfU7iVOeXbIgFVIeLuv X0jmKkTcV5ZuD87Xu5mWYFSWZmQHYVa6cq1p5W1M7zpIxAR16smPF2bm8yuOPKCaq5OM Vrj+uwkvaN3HjUKjzA5qBnQZPadrMCzGFgy8nVl36+hO4jjKqWALo5HjDvjzCEV8E0wU 8Q8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548275; x=1706153075; 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=q4Xlbv7w1QB06viMEvJrvyI5kfhMiq7AkgJexCqUX1c=; b=ww4CGTLzzidbzASRNybmfCA/nodNq47NX6c2UnotMUC26HPTFL0jbA4QO6UytVhNn6 IoRYDA/jSZI+zC33ALa1BDUEkHhXKaX/xJkAR1wEOfSsDvFd7i4kxbgEblQXHI5Lqmek 1dA0j2A/oSlky6e0GxlkOqdeugo7fDaTNqVW/eej1pvX1iI0lhZxB/Z/qawEXfGc1Nfw I8HN7PqXmgqwmesetfdyi04O77E4g0KwYlm93ubXxcFGyx7/7p4xVpe4W2SKKufObw/A nrsZOnxx8JwhUG5+QJtwMxDN05SRWlJmsmKDGid4UH3KzyJiJ6lv34W6QSnB/i6qmjXs 9X1g== X-Gm-Message-State: AOJu0YzSc3vOuU389OkEGzBOmJdrXP4gq35LxLuCvnwkQ5CT89YU1Os4 k/aNn21Lu/WB/uk5qb3NC1lEjHhO5nReRFgnWNKVgrLtOEzoc0CqdAXXL8h5oluZ8KjfbCAVyra NrpQ= X-Google-Smtp-Source: AGHT+IEfkjtxT+9Dm+BkcLAudkkUEw3lH5AqTVhW7JTZg6RiyAXlML9Wvb0OIx3+zVEMH872ADevAQ== X-Received: by 2002:a05:600c:3782:b0:40d:5d9a:adc with SMTP id o2-20020a05600c378200b0040d5d9a0adcmr93116wmr.11.1705548275735; Wed, 17 Jan 2024 19:24:35 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 08/14] tests/plugin/bb: migrate to new per_vcpu API Date: Thu, 18 Jan 2024 07:23:53 +0400 Message-ID: <20240118032400.3762658-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548329673100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- tests/plugin/bb.c | 63 +++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df50d1fd3bc..3f0c25883de 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -17,49 +17,51 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 typedef struct { - GMutex lock; - int index; uint64_t bb_count; uint64_t insn_count; } CPUCount; =20 -/* Used by the inline & linux-user counts */ -static bool do_inline; -static CPUCount inline_count; +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64_t bb_count; +static qemu_plugin_u64_t insn_count; =20 +static bool do_inline; /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; =20 -static void gen_one_cpu_report(CPUCount *count, GString *report) +static void gen_one_cpu_report(CPUCount *count, GString *report, + unsigned int cpu_index) { if (count->bb_count) { g_string_append_printf(report, "CPU%d: " "bb's: %" PRIu64", insns: %" PRIu64 "\n", - count->index, + cpu_index, count->bb_count, count->insn_count); } } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) { + const unsigned int num_cpus =3D qemu_plugin_scoreboard_size(counts); g_autoptr(GString) report =3D g_string_new(""); =20 - if (do_inline || !max_cpus) { - g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - inline_count.bb_count, inline_count.insn_count); - } else { - g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + for (int i =3D 0; i < num_cpus; ++i) { + CPUCount *count =3D qemu_plugin_scoreboard_get(counts, i); + gen_one_cpu_report(count, report, i); } + g_string_append_printf(report, "Total: " + "bb's: %" PRIu64", insns: %" PRIu64 "\n", + qemu_plugin_u64_sum(bb_count), + qemu_plugin_u64_sum(insn_count)); qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count =3D g_ptr_array_index(counts, cpu_index); + CPUCount *count =3D qemu_plugin_scoreboard_get(counts, cpu_index); g_autoptr(GString) report =3D g_string_new(""); - gen_one_cpu_report(count, report); + gen_one_cpu_report(count, report, cpu_index); =20 if (report->len > 0) { g_string_prepend(report, "Idling "); @@ -69,14 +71,11 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int= cpu_index) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count =3D max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count =3D qemu_plugin_scoreboard_get(counts, cpu_index); =20 uintptr_t n_insns =3D (uintptr_t)udata; - g_mutex_lock(&count->lock); count->insn_count +=3D n_insns; count->bb_count++; - g_mutex_unlock(&count->lock); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -84,11 +83,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) size_t n_insns =3D qemu_plugin_tb_n_insns(tb); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.bb_count, 1= ); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.insn_count, - n_insns); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -121,18 +119,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, } } =20 - if (info->system_emulation && !do_inline) { - max_cpus =3D info->system.max_vcpus; - counts =3D g_ptr_array_new(); - for (i =3D 0; i < max_cpus; i++) { - CPUCount *count =3D g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index =3D i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); - } + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + bb_count =3D qemu_plugin_u64_struct(counts, CPUCount, bb_count); + insn_count =3D qemu_plugin_u64_struct(counts, CPUCount, insn_count); =20 if (idle_report) { qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548364; cv=none; d=zohomail.com; s=zohoarc; b=nvKI0y/fx70n4YlYLQaVkIixKdPK8ufjJbY3YOH7uV2NFibdEUWTKSBXOkxAjZ8exLv6t9bzlU/zeof+wQUW+Mb9HkYSPdbZDuYqEpD4lWn8becuE0wairWy8i+XkYDnh0CMn7EkwA2a93DrG7MIq7CWcbwTmR8B9cuERcSBTvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548364; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OpYndL8vLGdfYul3boxTKF+u6iZVN8VJoSivXt39QS0=; b=RqTaYSuAgRR5QIDIWN653C5P8qMD7uY8OHbsK5UdG4JaqtAHoGgWZRZLShBIsd6n3Q8Pz94jPk7HMFjUxkbxiCviyKybUrllC4FjKbV8hnU4z/fjZz8RMv0UnxsuHUa2QzJpA2LsjtogI83dZrBWkgYAtWDnwbz8Ha6UljYcoEk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170554836437412.829409833161549; Wed, 17 Jan 2024 19:26:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1H-0003l5-De; Wed, 17 Jan 2024 22:24:43 -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 1rQJ1F-0003kO-MC for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:41 -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 1rQJ1D-0002rh-T3 for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:41 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-337cf4ac600so138213f8f.3 for ; Wed, 17 Jan 2024 19:24:39 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548278; x=1706153078; 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=OpYndL8vLGdfYul3boxTKF+u6iZVN8VJoSivXt39QS0=; b=nJHf9Dv2t6oBYZc3jlNmt/Q8n6gscNK8gtwjbifA2EgKbEXcUsk/HSf92tfSRG7JVH lDO/7wknyuGm4sFWcCPS7WQ3p7Z/y+XM2yxBUpsDBh4l/hARTC6fmuRjhgZa3WrBFfOM BCwLGP9sQJ2Ix5FSv10swf2Iw4AJg75CMSJmqb2HPjGSwEvDl3ANajPgZwO40S8rdWGr 0qaq5llkj4OuvH0YPIwoX74kmDfSmYhqqzQA1WNq4Jqlrcb47SykM6/d4T76buprQzkD ya6Kv/8EGK36FXtBDFR+eyBS4L/bPyKNu/1Kb4Rey4peTx0NNqh6kvKekwGvltTfwS9S eG0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548278; x=1706153078; 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=OpYndL8vLGdfYul3boxTKF+u6iZVN8VJoSivXt39QS0=; b=PcjK7YAkKYcbc5Xz3K+Wp6HbcT6KT59aampZMQIqlsJkMdqam6GTPJrXlUIKccgJcL 9ONQ735QN0qEB4/HsB8nnJANtyo8x+BUhCucmzpxluiX+Ka9zHPc2vF6AfTLpi/uva1L as3Yj83LSQpP/WfUb0EbF1gYCSpGmVV+4shYekHFKITOBConA/dpGfec9P4HZkXBnKqk kc8pQtVsANO0NoM1XvXmv36c7d4B7NmWo4tjSxwZV7P1sMm6xnniwGVZewzvuN4xyD6T CiOsHea2l9KcwzWzloTsFZ22R+DpT7ZF7KMQvxTNK2UwzBAc+IRLsUaAgMMvbdMshAqc q8Eg== X-Gm-Message-State: AOJu0YzHb8/fhrVFmJsbX4GY42U8tykU4aRTk2NvmqFKeCCdYBYr0JeC z5eODjeUyDQ4pnXa0IQBPhJIY9FRLiT0RL5knMblbUaxLcK9+8WBkL0VIm8Egb1s7mCxImGow/x LcBM= X-Google-Smtp-Source: AGHT+IGSZ22z8wOU3luGE+66npr0jJm+T+TaGwphsd/Z33EwiBKs4Hm3OAliG8GaMPBc7d4rUxe+9A== X-Received: by 2002:adf:9790:0:b0:337:c554:9987 with SMTP id s16-20020adf9790000000b00337c5549987mr106492wrb.45.1705548278378; Wed, 17 Jan 2024 19:24:38 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 09/14] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Thu, 18 Jan 2024 07:23:54 +0400 Message-ID: <20240118032400.3762658-10-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548365919100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- contrib/plugins/hotblocks.c | 46 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 4de1b134944..fa1e2f02178 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -34,8 +34,8 @@ static guint64 limit =3D 20; */ typedef struct { uint64_t start_addr; - uint64_t exec_count; - int trans_count; + struct qemu_plugin_scoreboard *exec_count; + int trans_count; unsigned long insns; } ExecCount; =20 @@ -43,7 +43,15 @@ static gint cmp_exec_count(gconstpointer a, gconstpointe= r b) { ExecCount *ea =3D (ExecCount *) a; ExecCount *eb =3D (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + uint64_t count_a =3D qemu_plugin_u64_sum(qemu_plugin_u64(ea->exec_coun= t)); + uint64_t count_b =3D qemu_plugin_u64_sum(qemu_plugin_u64(eb->exec_coun= t)); + return count_a > count_b ? -1 : 1; +} + +static void exec_count_free(gpointer key, gpointer value, gpointer user_da= ta) +{ + ExecCount *cnt =3D value; + qemu_plugin_scoreboard_free(cnt->exec_count); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) @@ -52,7 +60,6 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) GList *counts, *it; int i; =20 - g_mutex_lock(&lock); g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts =3D g_hash_table_get_values(hotblocks); @@ -63,16 +70,20 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) =20 for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { ExecCount *rec =3D (ExecCount *) it->data; - g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRI= d64"\n", - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + g_string_append_printf( + report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", + rec->start_addr, rec->trans_count, + rec->insns, + qemu_plugin_u64_sum(qemu_plugin_u64(rec->exec_count))); } =20 g_list_free(it); } - g_mutex_unlock(&lock); =20 qemu_plugin_outs(report->str); + + g_hash_table_foreach(hotblocks, exec_count_free, NULL); + g_hash_table_destroy(hotblocks); } =20 static void plugin_init(void) @@ -82,15 +93,8 @@ static void plugin_init(void) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - ExecCount *cnt; - uint64_t hash =3D (uint64_t) udata; - - g_mutex_lock(&lock); - cnt =3D (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) h= ash); - /* should always succeed */ - g_assert(cnt); - cnt->exec_count++; - g_mutex_unlock(&lock); + ExecCount *cnt =3D (ExecCount *)udata; + (*qemu_plugin_u64_get(qemu_plugin_u64(cnt->exec_count), cpu_index))++; } =20 /* @@ -114,18 +118,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) cnt->start_addr =3D pc; cnt->trans_count =3D 1; cnt->insns =3D insns; + cnt->exec_count =3D qemu_plugin_scoreboard_new(sizeof(uint64_t)); g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); } =20 g_mutex_unlock(&lock); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_u64(cnt->exec_count), 1); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, - (void *)hash); + (void *)cnt); } } =20 --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548318; cv=none; d=zohomail.com; s=zohoarc; b=MuEMcNt9a34Wkrq0X0oXoR8H9DyYMeLRZ0yvLXId/2YO66AihVrkh+AYRdk8G0s7id7pKsuPfJ5cXazXFLWjuNTmO75oQ1Fz2v3TEPqtkUJd3IlaJdCsw3+yxtXW1lx4AKSzeojswVmFk95f6IzT8BOdEkmu5y1yT69U0XYo2pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548318; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8IOrVF2ci3KA0n859H758KBpLzvdBx7y6KGSkBugi9k=; b=SCYYE0kANUpUUvEJ/z2jMuaEg4bPHNjVQeZYP7xegZX3HMaxULm4eL0VckEOjwNRZPWaIOSe+T4gSyyo+TZjqQffd2M6Jx/arLEprfuAJU/weC5TjH2Ntg+Jelbel0HHTjl/mFFuaaerUtRWT/JOZcPgUMVEbCHH6BczICh3rbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548318236857.1183508372055; Wed, 17 Jan 2024 19:25:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1J-0003lW-QF; Wed, 17 Jan 2024 22:24:45 -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 1rQJ1I-0003lN-QI for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:44 -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 1rQJ1G-0002yy-WB for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:44 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-337cf4eabc9so132820f8f.3 for ; Wed, 17 Jan 2024 19:24:42 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548281; x=1706153081; 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=8IOrVF2ci3KA0n859H758KBpLzvdBx7y6KGSkBugi9k=; b=GR2MnKuPRD/VWdAenUG5AO/k050Dt7L6o4t0jC1OoakfDsvmScYqxFaUmz5yIgc+pb jVicqy2iHYT0C/WcZVM6AzHnDVx2TbwZMJ4xrB4iUpCELz+WIQgA6K03dS1+vBOMc+P7 wRVnzA9wbJyXRSuAeJq/mYeH67dqDjuzbuF5CuTnhe4v0IY4n90GKIQrzJ8vdWu8DOri 0BQwkm4keb9XnPrgC1Ip/g+G7pF4pdkBinFn2xO7SKbDH9amE3Gr16FEneExtG6i19Rx SRYSg6lrH/sX+mJ041O/xnXTNSV45jh/YzxeFogP8Q+unyPxWvefvnd0pqSvkZN0BjMD W5MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548281; x=1706153081; 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=8IOrVF2ci3KA0n859H758KBpLzvdBx7y6KGSkBugi9k=; b=GIUSIHC3pi+U65vIZmVs7nQSpJwfBOAXL47Jhl5iGcWhOTpQ7lJvUNhGkxsm3TDSXa +vxvSWzdhprwf60EXbxQbRWWesL01EpPsphK+cXmaEX0lTX0pbNO0IkW2/YwixmOfgP2 h32FaI6L2F/iEZkVZGRLaC2NAiev2VVO4vEob/fkdf5HtzVJD4cgbHVdFAUf6oSGbl5S f3rH7rgPU+MVAZkhxUr194PKIBG8QEFYyNH86xLYJnR5G0xVzNBrbWvOiDBfJgHoOn2g 49KFSNfYAwwCkKQaJCC9z9KKdYBh5IfBdFavtGvhUBro46JKxND2ZXUAPFeRUpvEA/aB yZqg== X-Gm-Message-State: AOJu0YxYyOpKEZa2x92w+bf9sGdMWV8CvoJbWxXkFamUbP6SSBU5taYO 91sWJ+qrx+zEggRALU7IE9n1OLrBX8sEYTSeCb3RbIus7/RxxE+23a7cHNYxhJ03TgrZqe/lsu0 ORa0= X-Google-Smtp-Source: AGHT+IFlXyc105EqJlH2bMvirSyfCg97Qnjcf1IA3SKfrTmTsUXI+I82H2L03AxuKJnqQF70jGsTbw== X-Received: by 2002:a5d:4646:0:b0:337:2aa3:ac83 with SMTP id j6-20020a5d4646000000b003372aa3ac83mr89211wrs.61.1705548280959; Wed, 17 Jan 2024 19:24:40 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 10/14] contrib/plugins/howvec: migrate to new per_vcpu API Date: Thu, 18 Jan 2024 07:23:55 +0400 Message-ID: <20240118032400.3762658-11-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548319617100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- contrib/plugins/howvec.c | 50 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 644a7856bb2..497b86fcd6b 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -43,13 +43,13 @@ typedef struct { uint32_t mask; uint32_t pattern; CountType what; - uint64_t count; + qemu_plugin_u64_t count; } InsnClassExecCount; =20 typedef struct { char *insn; uint32_t opcode; - uint64_t count; + qemu_plugin_u64_t count; InsnClassExecCount *class; } InsnExecCount; =20 @@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpoint= er b) { InsnExecCount *ea =3D (InsnExecCount *) a; InsnExecCount *eb =3D (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + uint64_t count_a =3D qemu_plugin_u64_sum(ea->count); + uint64_t count_b =3D qemu_plugin_u64_sum(eb->count); + return count_a > count_b ? -1 : 1; } =20 static void free_record(gpointer data) @@ -167,12 +169,14 @@ static void free_record(gpointer data) InsnExecCount *rec =3D (InsnExecCount *) data; g_free(rec->insn); g_free(rec); + qemu_plugin_scoreboard_free(rec->count.score); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new("Instruction Classes:\n"); int i; + uint64_t total_count; GList *counts; InsnClassExecCount *class =3D NULL; =20 @@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class =3D &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + total_count =3D qemu_plugin_u64_sum(class->count); + if (total_count || verbose) { g_string_append_printf(report, "Class: %-24s\t(%" PRId64 " hits)\n= ", class->class, - class->count); + total_count); } break; case COUNT_INDIVIDUAL: @@ -212,7 +217,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "Instr: %-24s\t(%" PRId64 " hits)" "\t(op=3D0x%08x/%s)\n", rec->insn, - rec->count, + qemu_plugin_u64_sum(rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised"); @@ -221,6 +226,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } =20 g_hash_table_destroy(insns); + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + qemu_plugin_scoreboard_free(class_tables[i].table[j].count.sco= re); + } + } + =20 qemu_plugin_outs(report->str); } @@ -232,11 +243,12 @@ static void plugin_init(void) =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - uint64_t *count =3D (uint64_t *) udata; - (*count)++; + struct qemu_plugin_scoreboard *score =3D udata; + (*qemu_plugin_u64_get(qemu_plugin_u64(score), cpu_index))++; } =20 -static uint64_t *find_counter(struct qemu_plugin_insn *insn) +static struct qemu_plugin_scoreboard *find_counter( + struct qemu_plugin_insn *insn) { int i; uint64_t *cnt =3D NULL; @@ -265,7 +277,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.score; case COUNT_INDIVIDUAL: { InsnExecCount *icount; @@ -279,13 +291,15 @@ static uint64_t *find_counter(struct qemu_plugin_insn= *insn) icount->opcode =3D opcode; icount->insn =3D qemu_plugin_insn_disas(insn); icount->class =3D class; + icount->count =3D + qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint64_t= ))); =20 g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } g_mutex_unlock(&lock); =20 - return &icount->count; + return icount->count.score; } default: g_assert_not_reached(); @@ -300,14 +314,13 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) size_t i; =20 for (i =3D 0; i < n; i++) { - uint64_t *cnt; struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); - cnt =3D find_counter(insn); + struct qemu_plugin_scoreboard *cnt =3D find_counter(insn); =20 if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, qemu_plugin_u64(cnt)= , 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, c= nt); @@ -322,6 +335,13 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, { int i; =20 + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + class_tables[i].table[j].count =3D + qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint64_t= ))); + } + } + /* Select a class table appropriate to the guest architecture */ for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { ClassSelector *entry =3D &class_tables[i]; --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548340; cv=none; d=zohomail.com; s=zohoarc; b=kaaVk0/cLreY8940K/lZ4gTGa1nmSaeRENntAHr0Il8VX3xrceIKpqIYUaoCBnB4ebKKV3RNXl23LYt4O5Gpxk4Wapzy2QnXs4mAXyHm2RwBoqDdH6WPkMt5jIYJKHo/gShMo+FYfXHk5YjRKkHs5nekR9T0NqptOXCJOvQkdHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548340; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZLvxeFqnyu9l57+cwcakx7h5EhmFm40PDnmxlZb5fZM=; b=eeOnv/lFaS5yI+6oh40LeDhLEHYUqsXeq8Q1FI4MySRPlhLE34igTTjxBixBRjCWFHagQV9N6w9CAxMc2o4kOC7G69GNkOXznFK5tXy2U4lxna4+/jRgBFlNr3G9ui/P90rozLSlLmqU96NXkcV24h2lOsWZL8AMz7jrcS81KoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548340465541.0708629483886; Wed, 17 Jan 2024 19:25:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1N-0003mP-DL; Wed, 17 Jan 2024 22:24:49 -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 1rQJ1L-0003m1-LL for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:47 -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 1rQJ1J-00037W-Oz for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:47 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33770772136so7109635f8f.3 for ; Wed, 17 Jan 2024 19:24:45 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548283; x=1706153083; 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=ZLvxeFqnyu9l57+cwcakx7h5EhmFm40PDnmxlZb5fZM=; b=GsmCWLWuHqqYaTcseaiPmeDZOtY8DJl/YRAzge0rXqj42DM4mNUiU5H+cqy9Tq5os/ y+9w4j4jgG1eQ3x/o+OOiErctkZW4qJZJ0ZDOwexuLiu4zWGiGD8TNdQycp9xZV4yFw9 twGHBGSmhqvnRfZ13GnXmai/YJxEz0FXfV3unjyLIIXeB7CmLXyNSHpBP6n4PGRRF208 LvcFd70I5+1BhOevYkNuTarJhfAjeQ+Mq7GbnMUuEzE4/tzRHCZxm1BHGyp8gEIPVItx TlcEAocO4w8scWVHppigJPMDmOnJWMu1UDARXjczk1ymhFbSRqvFFcYUyhhQHf/yrB+L Yyfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548283; x=1706153083; 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=ZLvxeFqnyu9l57+cwcakx7h5EhmFm40PDnmxlZb5fZM=; b=Um0TW1bgz0XTr8oLDBHFRQmESgIuO+HhvqVd4n+2VT7/VZKInjCKRUeJp58Qs0LDVQ ByCg/f0JtrE/HpjuNmlwjeImyPUsoEh3qi3IxGXbh+6X8VCfmcTFhSoG9U/0O1MGcAkP Rcsu1oUtOvLRfceHDIWKbQvSPtm/mSDnX9F8nScpXD8XMHhkzRCxixeM0JPZ++PVlkEN PFdS8SSFiJeQQyJqODzYDQ/D5abR1d7O7qDqhgmfRKJV+tnoZPMlBDx6KnwclrLBXn6S lSYQ7z2wVPtyOCpBqPMh7KGmkIIRTyNz9gGCJ8KnqBt7aoPETqZ8NPHMGoD/rAFvVA2M WTFA== X-Gm-Message-State: AOJu0Yz2chVzAFgkM+BZ845Lkm24g8dRAsvjzxuol9rtS3d/qNLWQNvx FEsohw4gfz/3rpoxb0AnfsPZej/NohKBbq+rFGSPOo3zD6FTsaupqgy3fmixihVSMMwMWWhlTzP PyM8= X-Google-Smtp-Source: AGHT+IHEwapwz9z16JSm25vmNOys0ITmGC8Ju4F93OT2cscbRdqLeWPVVhOm1qv3KjrVL/2ccHgpsQ== X-Received: by 2002:adf:d1e7:0:b0:337:5588:801f with SMTP id g7-20020adfd1e7000000b003375588801fmr105880wrd.57.1705548283664; Wed, 17 Jan 2024 19:24:43 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 11/14] plugins: remove non per_vcpu inline operation from API Date: Thu, 18 Jan 2024 07:23:56 +0400 Message-ID: <20240118032400.3762658-12-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548341809100001 Content-Type: text/plain; charset="utf-8" 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 can assume that we operate on a scoreboard. 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 | 29 ------------------- 2 files changed, 6 insertions(+), 82 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 55f918db1b0..3ee514f79cf 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -51,11 +51,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. */ =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; =20 -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 =20 /** * struct qemu_info_t - system information for plugins @@ -311,25 +316,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; =20 -/** - * 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 @@ -361,21 +347,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, enum qemu_plugin_cb_flags flag= s, void *userdata); =20 -/** - * 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 *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -599,24 +570,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); =20 -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any m= emory 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 *pt= r, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess * @insn: handle for instruction to instrument diff --git a/plugins/api.c b/plugins/api.c index 132d5e0bec1..29915d3c142 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -101,16 +101,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_= plugin_tb *tb, } } =20 -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, ptr, 0, sizeof(uint64_t), true, i= mm); - } -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -140,16 +130,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, } } =20 -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!insn->mem_only) { - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INL= INE], - 0, op, ptr, 0, sizeof(uint64_t), true, i= mm); - } -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, @@ -179,15 +159,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, cb, flags, rw, udata); } =20 -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *pt= r, - uint64_t imm) -{ - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, 0, sizeof(uint64_t), true, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548405; cv=none; d=zohomail.com; s=zohoarc; b=VDzK9EHn+Q7KRHMNtn34mRbBw6eZiyBKMhOruo0rl9smZxlrB6xhIZS4GB/uLo7a1nJxARHmnxQ/Wl8dhM5PvIQulgVHvzA4Wg5lrqMf/NN2TQlQh9dgLDh//LTAqb/qYWSCDUqx6yaF3JAPHMUL7ButMs6TOPk1l59CrW4jK0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548405; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pjIwKEUqnfGsc/JPgZZdh73H3Cz5ZaisrsiAEjZH8J0=; b=cd3t9dUL/rd9RndGYJdMzjAz7mY1v5/Rqu6YmJJYY4sJvv+RsUH3TF+e86diWX/4secgukPnyHhMATNnzK7SbZFTRl6qTzQEiACoMdKWHLG44JBYdZss4OkNdR9+aNNBuL73kdh2/3IcFUe4KSmJpkaajkcatpRfG9NoihzBVBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548405011962.8197012242252; Wed, 17 Jan 2024 19:26:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1Q-0003mn-9O; Wed, 17 Jan 2024 22:24:52 -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 1rQJ1N-0003mR-SL for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:49 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ1L-0003DS-OJ for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:49 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-337bcaef29eso1792675f8f.0 for ; Wed, 17 Jan 2024 19:24:47 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548286; x=1706153086; 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=pjIwKEUqnfGsc/JPgZZdh73H3Cz5ZaisrsiAEjZH8J0=; b=D8BMsB1kjVEoGzhmtZ6WOPemLJ/5emIPucdvrw8BSYpxWXPyOa4ebJPvesPdhMhyZ1 i8XhqUAhsgaorrZI9q7Fg9dJujbx668kOmSDKBvVXG3S+UeRumhI9kht+LshPCTi1Dyu eOQPre8Gcb9Z0j0RsQg/SHej3dOxZL2H/Fj6Z9/hvZNH+4ofBWrNMYQ5aNGIjd7gUgaV nMGJ7pjV1f+auu+CEtT62m39SQrmpiGM5cx3zbeI/99a6GFEnqftACDL1njWSlrYDNXA XZ4qfR1Mt/Jq16Ri0en96zZiCoFquJaDoO/ltYAnwsF6af25DXfdwoD9PYEOjimsDOUp e3fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548286; x=1706153086; 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=pjIwKEUqnfGsc/JPgZZdh73H3Cz5ZaisrsiAEjZH8J0=; b=VLot+mUZ2pFNJX58ZG0hdJUc8U/8M7wDzR2ZK1TmlJppxb9ZXL1BRhDwzUPCzXjM07 W3/je4n+kbUqonkyBlKyDZc4p30HTYyNe9mPYNawvNMfDGIhxUY9PYv9htIwvvD5Au3/ nApbQypeffF3vyg8zOn1/Fqr17zjJY8Ws++gncmN5YTb8Yw1MQLTZKLgPUm84zRhYewW Icg7D37SPLDFmU7J3i62OM+4iN2qcHANAgxGblwyMD8O5WyQWagxFo3aNwlzR2waW79T 7BXCn5RYINgpmSptkKJ4ktNKpH2LrpiQgT3MpQvUfeUC6VOjId3+c44LvLnrLp//W050 /FUw== X-Gm-Message-State: AOJu0YypSOhkP9HD1oP9XDJYIrqs465XIPHDy8sIFMqi6zow7lAMzpLR MympPDPzUtAaCmQBd5uqDCSdlaUlRwKhEbyiJYA0nPBKwfSz/5tGDCqhL3VrbLRXPAw/tYqaLOL UtOA= X-Google-Smtp-Source: AGHT+IGIjgrpHrF61cZOYqQQqStAFvbqM/MPB8mCyIKVlTyOY4HUXSKH2HsbRRoQ6md1z41wuUKfaQ== X-Received: by 2002:adf:ee03:0:b0:337:b4db:5a2a with SMTP id y3-20020adfee03000000b00337b4db5a2amr83922wrn.28.1705548286312; Wed, 17 Jan 2024 19:24:46 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 12/14] plugins: register inline op with a qemu_plugin_u64_t Date: Thu, 18 Jan 2024 07:23:57 +0400 Message-ID: <20240118032400.3762658-13-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548406044100001 Content-Type: text/plain; charset="utf-8" Now inline previous API was removed, we can cleanup code path associated. Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 7 ++----- include/qemu/plugin.h | 1 - plugins/api.c | 12 +++--------- plugins/core.c | 17 ++++++----------- plugins/plugin.h | 3 +-- 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 1a2375d7779..5e4938805e8 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -439,11 +439,8 @@ static TCGOp *append_inline_cb(const struct qemu_plugi= n_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - char *ptr =3D cb->userp; - if (!cb->inline_direct_ptr) { - /* dereference userp once to get access to memory location */ - ptr =3D *(char **)cb->userp; - } + /* always dereference userp for inline operations */ + char *ptr =3D *(char **)cb->userp; op =3D copy_ld_i32(&begin_op, op); op =3D copy_mul_i32(&begin_op, op, cb->inline_element_size); op =3D copy_ext_i32_ptr(&begin_op, op); diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 5f340192e56..b63631207cd 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -88,7 +88,6 @@ struct qemu_plugin_dyn_cb { void *userp; size_t inline_offset; size_t inline_element_size; - bool inline_direct_ptr; 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 29915d3c142..d12fed6118e 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -109,9 +109,7 @@ void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( { if (!tb->mem_only) { plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, entry.score->data, - entry.offset, entry.score->element_size, - false, imm); + 0, op, entry, imm); } } =20 @@ -138,9 +136,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline_per_vcp= u( { if (!insn->mem_only) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INL= INE], - 0, op, entry.score->data, - entry.offset, entry.score->element_size, - false, imm); + 0, op, entry, imm); } } =20 @@ -167,9 +163,7 @@ void qemu_plugin_register_vcpu_mem_inline_per_vcpu( uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, entry.score->data, - entry.offset, entry.score->element_size, - false, imm); + rw, op, entry, imm); } =20 void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, diff --git a/plugins/core.c b/plugins/core.c index 0286a127810..46175d557f7 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -347,17 +347,15 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(G= Array **arr) void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, - void *ptr, size_t offset, size_t element_si= ze, - bool direct_ptr, + qemu_plugin_u64_t entry, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; =20 dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D ptr; - dyn_cb->inline_element_size =3D element_size; - dyn_cb->inline_offset =3D offset; - dyn_cb->inline_direct_ptr =3D direct_ptr; + dyn_cb->userp =3D entry.score->data; + dyn_cb->inline_element_size =3D entry.score->element_size; + dyn_cb->inline_offset =3D entry.offset; dyn_cb->type =3D PLUGIN_CB_INLINE; dyn_cb->rw =3D rw; dyn_cb->inline_insn.op =3D op; @@ -504,11 +502,8 @@ void qemu_plugin_flush_cb(void) =20 void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - char *ptr =3D cb->userp; - if (!cb->inline_direct_ptr) { - ptr =3D *(char **) cb->userp; - } - ptr +=3D cb->inline_offset; + /* always dereference userp for inline operations */ + char *ptr =3D (*(char **) cb->userp) + cb->inline_offset; uint64_t *val =3D (uint64_t *)(ptr + cpu_index * cb->inline_element_si= ze); =20 switch (cb->inline_insn.op) { diff --git a/plugins/plugin.h b/plugins/plugin.h index 99829c40886..4c8f2ca3728 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -71,8 +71,7 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plug= in_id_t id); void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, - void *ptr, size_t offset, size_t element_si= ze, - bool direct_ptr, + qemu_plugin_u64_t entry, uint64_t imm); =20 void plugin_reset_uninstall(qemu_plugin_id_t id, --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548345; cv=none; d=zohomail.com; s=zohoarc; b=kHv0LpGYJ1euQgEd9uHcrqxYKyhtMDMv0hzMOPhU1E2KBbHGa63KVIQ0qYLkFs0Wmz0xWX6diPoeK5yaKpaPhYGi6KNzf0pk0DClBb0QCmeQ/6nSe3Vdq4dGo3FEn2WKCUrPogE+ptzJIknaHJiFJ8epOywUS7zV+P8/R3CEu3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548345; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gY1HvrcRK/jb3DOwoSe5cKTH6nvlDdjohKhPFmwO/ik=; b=eyv501iwuaqZ3+qX7KfGumjY03TseREBZTUJe8Fd4KZeoGWnhQG/UtywXQXz9T4YbN2FrEm4vYEM9vgIZ5gNAj0aVva8c4gJvlFVq0VTfi3xN84kZOgNfcjROG47ZbBVE10hFKbNyiAPBXEcYF1k+GMUfDcwvxpuTIcoJa2A1cM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548345724607.1661531437938; Wed, 17 Jan 2024 19:25:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1a-00045n-Mq; Wed, 17 Jan 2024 22:25: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 1rQJ1X-0003yH-KC for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:59 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ1O-0003Fv-PF for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:52 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-337b71a0240so2209959f8f.0 for ; Wed, 17 Jan 2024 19:24:50 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548289; x=1706153089; 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=gY1HvrcRK/jb3DOwoSe5cKTH6nvlDdjohKhPFmwO/ik=; b=CEuUsMTqe4kEKady6Yx/3J7/s0FeyHCskAsv4vvSRTwOqLiAt4/xd+QMg8O3Q0ZcWD /WfR49Mc/kSAg13XMxFQhEQOjcOoDSX4YBuXQGBLHYQU2/FKic2tJV0c+997a6Kqde/T 6L2Fm1cUucOcOoKcaUbm/ZxhpNcMLXri5Miq8MaDPmFtA1cYL9hVW4IETfKNTqIKiqOC 9+mC1CbpT73svLXKeZuWxG8e18gcxPQYWADDSFqq9qiA7yNCXV8/wpFfEliwRxjYR6ui zt5/WHWMe8ghVEIcIb+4YpU2zjkZJrYFxUV4nZOxHVFjV5kcSkCOGjRAPER82xLnghtE E5cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548289; x=1706153089; 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=gY1HvrcRK/jb3DOwoSe5cKTH6nvlDdjohKhPFmwO/ik=; b=oRrR1OJjaW2UZjj9wAS0mdFzhxCxz8UfhlxT4pyTU19i0FxeWX7coIq+IRff6Xrtwb bqq/SY3dgMU5+ir1wl+s9q9t4KqQ9g2rGlQnGee2u2OWIgFAyLqTazAiBl40fSb36tCi 1iStZodbV2y/lnTtaWc3ca8ZIsIbKbpuakGfSUmhv/E5EkdCOq9S7rRQ2OK4dccT/xAp koUe98EjxHYn6XaIj/Z9rO0Psae8DMEjOMdGD9jUKdEBgWXPKONMu/wEjxG/+njE8s0k 7wVI5+wuNK/wpQ4guQZarbfenF/4fV9jwLUZLBSo8jb299pY2aj1F3XvGIbGH3AZejwd bAdw== X-Gm-Message-State: AOJu0Yw8DH9BfuZP+rNVRhovkc/iyd1Kv5df3G13RsQbDi4m+/ktcloO MHDspmwT7YiFNPF4A5BVoUSF1u6iod+WHk6ZHAnCpZPKRCZvfRFnGILPDoZlPYnWz+kFUhL/YLn M/r0= X-Google-Smtp-Source: AGHT+IEA734t+UkU+45d5yZH/WkWNiJhR0hRNtZfoVrYGmN7qsOBuFn2954VLj9/uj5bz553GUoABg== X-Received: by 2002:adf:f4ca:0:b0:337:c2fa:3d22 with SMTP id h10-20020adff4ca000000b00337c2fa3d22mr75747wrp.139.1705548289125; Wed, 17 Jan 2024 19:24:49 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 13/14] MAINTAINERS: Add myself as reviewer for TCG Plugins Date: Thu, 18 Jan 2024 07:23:58 +0400 Message-ID: <20240118032400.3762658-14-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548347734100003 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Pierrick Bouvier Reviewed-by: Alex Benn=C3=A9e --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index b406fb20c05..206d813ea5e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3675,6 +3675,7 @@ TCG Plugins M: Alex Benn=C3=A9e R: Alexandre Iooss R: Mahmoud Mandour +R: Pierrick Bouvier S: Maintained F: docs/devel/tcg-plugins.rst F: plugins/ --=20 2.43.0 From nobody Thu Nov 14 07:01:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705548359; cv=none; d=zohomail.com; s=zohoarc; b=lZcuFx01WtT2iDY+jBV/bEL7dZ1gbSD1AjpogLeTTy5xeYbysKsUETIasNuFW5xu9byHjr41M0qwEh3VWzKb7+7AU70uZvK9HICl/7vyiwqB5eC6bbhQe+l7gfhsuCnaXjD3IP2FO8GV5MlvgLqI2zK+kChhtH8iZ0iGBuVrxpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705548359; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+unRKaCSDZUa7wMcF5VMrkBGXnAvyrlpB3hgAdHK8PY=; b=D7iiVWGCTR+yVb7Tgf8he/weOzyyfjqPVP/rm1yef3XUUVsmYTPg52/SxvHJaa9PBv4YhkPwUA7Ttc6ocDAJ2xEjGPcnTKzOHUiYH0YnMCRDUsYLAo4OZ3yohToitfCM1u7IXwFHRoaICpkHNEGOBZ/Fuic5cqdpg2D6adtYOjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705548359650487.72088747809585; Wed, 17 Jan 2024 19:25:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQJ1e-0004G7-Qz; Wed, 17 Jan 2024 22:25:08 -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 1rQJ1Y-00042V-Vs for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:25: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 1rQJ1X-0003Nu-CB for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:25:00 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-337cf4ac600so138287f8f.3 for ; Wed, 17 Jan 2024 19:24:52 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548291; x=1706153091; 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=+unRKaCSDZUa7wMcF5VMrkBGXnAvyrlpB3hgAdHK8PY=; b=QthVr5L/3rgKmJxTYz75EZDpeU+dLr0d1/PtCF7YUznvW3jDp6oCJXyJsMA9LG9VUh sMAXozJyAqbd2zjG1RSf8IuuyXdyiJiGY126MW7vQCrsWf6xx4qqvvESQlZK9AQu9Coh pzrI5GggKb+176XMObIsqd4W99i1UEQrD50xz5VEPGI4uN0dCE2ckBC3fTTF0rZMTFUy qzt528FYD5IZeC4zdPnATsacx79uuMwZz9dsaHf59uFGWHWpFor14tNU+PsisZ93VGUV olehHEfyOx5vVan+QyItkDVwTcQHlbrpEj87Sor7zzbIbLq2eMUYUc15tvZl8rGv0K4B qXGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548291; x=1706153091; 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=+unRKaCSDZUa7wMcF5VMrkBGXnAvyrlpB3hgAdHK8PY=; b=ExKSn4bCHhQyFYf/eAS6xk4VhEywMcv9nZzTfPvKTWhRFQ2AK3VOQY3xcPxpXrBHeE qisjubwQyJABPiXBlxJGIlN7gEDodX61Z7LYnUoUv7HLw4UGq0sh8PwPFwdYKD/WDZcd d3DzLBElEWVCIebsbfRyPBaopSl4zlYTQ/BC3vdF+f239PON5Hs27hu4q/o8vJlMdv3O f3Lw1C3+C7yedtgARS3sN9SIvUtHjrrAwC2QXCkRsE0RH5JBnrUae+fpvsXd6NLSexD+ kWMqhodGhw8hrvAvdXUKhJHRyvi7m4LThBiyhl8dJBNcwQu8fblW/dR+UT2qHpzfLBao Z9cA== X-Gm-Message-State: AOJu0YwBprz5wf06OzyTSmG1e/iuaZ4ke3Z7wIFLIM0J1vsm/lpVxl7u qwbzh45jEUEqGIshXi7J20jJndk5rAmiBA8OPNwzFCQ25L07nUyWzqfhI4fMJWYCyWsdvDMvc5e C1bQ= X-Google-Smtp-Source: AGHT+IFV0Em1wRTe1Kx+/W8PvRT4YiCDXPR49XTYRGqIJy5thoHK+AUPqqsQ6hGk51MA2bKDnqe9eg== X-Received: by 2002:adf:fa8a:0:b0:337:9953:5183 with SMTP id h10-20020adffa8a000000b0033799535183mr76562wrr.64.1705548291695; Wed, 17 Jan 2024 19:24:51 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v2 14/14] contrib/plugins/execlog: fix new warnings Date: Thu, 18 Jan 2024 07:23:59 +0400 Message-ID: <20240118032400.3762658-15-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> References: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705548361963100003 =E2=80=98g_pattern_match_string=E2=80=99 is deprecated, Use 'g_pattern_spec_match_string' instead. passing argument 2 of =E2=80=98g_ptr_array_add=E2=80=99 discards =E2=80=98c= onst=E2=80=99 qualifier from pointer target type Signed-off-by: Pierrick Bouvier --- contrib/plugins/execlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 5a4de1c93be..d12137ce5c0 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -336,8 +336,8 @@ static void registers_init(int vcpu_index) for (int p =3D 0; p < rmatches->len; p++) { g_autoptr(GPatternSpec) pat =3D g_pattern_spec_new(rmatche= s->pdata[p]); g_autofree gchar *rd_lower =3D g_utf8_strdown(rd->name, -1= ); - if (g_pattern_match_string(pat, rd->name) || - g_pattern_match_string(pat, rd_lower)) { + if (g_pattern_spec_match_string(pat, rd->name) || + g_pattern_spec_match_string(pat, rd_lower)) { Register *reg =3D init_vcpu_register(vcpu_index, rd); g_ptr_array_add(registers, reg); =20 @@ -345,7 +345,7 @@ static void registers_init(int vcpu_index) if (disas_assist) { g_mutex_lock(&add_reg_name_lock); if (!g_ptr_array_find(all_reg_names, reg->name, NU= LL)) { - g_ptr_array_add(all_reg_names, reg->name); + g_ptr_array_add(all_reg_names, (gpointer)reg->= name); } g_mutex_unlock(&add_reg_name_lock); } --=20 2.43.0