From patchwork Thu Jan 18 03:23:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763611 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589873wrz; Wed, 17 Jan 2024 19:26:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQcBhIvaTjzNL2mde99uDcZ7GzB+QCsy+lDqJ8A3Ce/0dljxtJ8kbw9G0I/SLiOtgZEo3Y X-Received: by 2002:a05:622a:553:b0:42a:14e9:7fb6 with SMTP id m19-20020a05622a055300b0042a14e97fb6mr399354qtx.67.1705548389618; Wed, 17 Jan 2024 19:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548389; cv=none; d=google.com; s=arc-20160816; b=OmGff7FKrw3q/IPsagQLXj8U78wP/3s5NYBDPr1HoK1FunFOvllCHRipvmKHJZCCwR F4SJ7DKV9S614zcBHWTCrbD4rtLpAEhi+RMS3f94hbroYr9Qanbw0AbYsTzkqWg8yooz tzA8pVr81yUcUXLQ2G9LbOcykkSOEBThbUUDQxb4dbMvJDv53kxHXsifZUw6I/QvVh6Z ZaOrLpdQJYpU9FPysSrVXaU8JAfUgvO4pKJ5D93IrD1EbrMTaG51JT1X8+ke2DOeYA6U hJ62FYIBLn7gCdBshUQF8QIwVqECNlI5KpgZQ0r1Ur9fjAmjoK6uGXblucPUn7leluFR HfOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BaxeeJgy+H1D/rDFzs4Zm7F3dDyijmRAjRzFwAHqBpY=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=AkXA4jmCrY8rehC98sdsfn8m/TbaEYqf9CzMrzyM+2tgtwwFCsKmO0b/OzwAahHoSB 1HooTkVFx9f9DiOkky8NWq7DzyWRL8bjwYV00UU2+6glQNGvEghOQyLrEWjuBOLIkM+d 8Y5Pc3q4lBQnuA2Q+TZXoGYbwT9tO4kmAhnwUMdyHZjMfwtCZI7/JA20dHelINypXmUU 3YMvdB+dvUp/lGh5tCk7eY8zR/ja4AMpmkWE7GzzSPxr3LifyvSPUtBN90tb78nVi9SA aX4qapdgKgeEqgt0GcH4Dt6CDhSHC4yQhWw3Mtuac7RYg825j1Ug9TX+D0v/eJk8DF3o ktZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qetw8A43; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u9-20020a05620a120900b007833008db9bsi13033573qkj.602.2024.01.17.19.26.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:26:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qetw8A43; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr(); TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + /* pass an immediate != 0 so that it doesn't get optimized away */ + tcg_gen_muli_i32(cpu_index, cpu_index, 0xdeadbeef); + tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); + tcg_gen_movi_ptr(ptr, 0); + tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); tcg_gen_ld_i64(val, ptr, 0); /* pass an immediate != 0 so that it doesn't get optimized away */ tcg_gen_addi_i64(val, val, 0xdeadface); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_ptr(ptr); tcg_temp_free_i64(val); + tcg_temp_free_ptr(cpu_index_as_ptr); + tcg_temp_free_i32(cpu_index); } static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -289,12 +301,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) return op; } +static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) +{ + return copy_op(begin_op, op, INDEX_op_ld_i32); +} + +static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_ext_i32_i64); + } + return op; +} + +static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + op = copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) { if (TCG_TARGET_REG_BITS == 32) { /* 2x ld_i32 */ - op = copy_op(begin_op, op, INDEX_op_ld_i32); - op = copy_op(begin_op, op, INDEX_op_ld_i32); + op = copy_ld_i32(begin_op, op); + op = copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op = copy_op(begin_op, op, INDEX_op_ld_i64); @@ -330,6 +367,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) return op; } +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op = copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] = tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX == UINT32_MAX) { @@ -395,18 +439,19 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + char *ptr = cb->userp; + if (!cb->inline_direct_ptr) { + /* dereference userp once to get access to memory location */ + ptr = *(char **)cb->userp; + } + op = copy_ld_i32(&begin_op, op); + op = copy_mul_i32(&begin_op, op, cb->inline_element_size); + op = copy_ext_i32_ptr(&begin_op, op); + op = copy_const_ptr(&begin_op, op, ptr + cb->inline_offset); + op = copy_add_ptr(&begin_op, op); op = copy_ld_i64(&begin_op, op); - - /* add_i64 */ op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op = copy_st_i64(&begin_op, op); - return op; } diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 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 qemu_plugin_tb *tb, void *ptr, uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, imm); + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, ptr, 0, sizeof(uint64_t), true, imm); } } @@ -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_INLINE], - 0, op, ptr, imm); + 0, op, ptr, 0, sizeof(uint64_t), true, imm); } } @@ -156,7 +157,7 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, imm); + rw, op, ptr, 0, sizeof(uint64_t), true, imm); } void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, diff --git a/plugins/core.c b/plugins/core.c index 49588285dd0..e07b9cdf229 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -280,13 +280,18 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, size_t offset, size_t element_size, + bool direct_ptr, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = ptr; + dyn_cb->inline_element_size = element_size; + dyn_cb->inline_offset = offset; + dyn_cb->inline_direct_ptr = direct_ptr; dyn_cb->type = PLUGIN_CB_INLINE; dyn_cb->rw = rw; dyn_cb->inline_insn.op = op; @@ -431,9 +436,14 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } -void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - uint64_t *val = cb->userp; + char *ptr = cb->userp; + if (!cb->inline_direct_ptr) { + ptr = *(char **) cb->userp; + } + ptr += cb->inline_offset; + uint64_t *val = (uint64_t *)(ptr + cpu_index * cb->inline_element_size); 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 vaddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE: - exec_inline_op(cb); + exec_inline_op(cb, cpu->cpu_index); break; default: g_assert_not_reached(); diff --git a/plugins/plugin.h b/plugins/plugin.h index 5eb2fdbc85e..2c278379b70 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -66,7 +66,9 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, size_t offset, size_t element_size, + bool direct_ptr, uint64_t imm); 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); -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); #endif /* PLUGIN_H */ From patchwork Thu Jan 18 03:23:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763605 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589705wrz; Wed, 17 Jan 2024 19:25:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFdCgDWBrt07icndZhWh8Q7GI1N2tvBPR22vZaQ3Ii/voBlFPojQ7s/AkaKEL4p+3mc9EO X-Received: by 2002:a05:622a:309:b0:429:cd4f:8429 with SMTP id q9-20020a05622a030900b00429cd4f8429mr203490qtw.74.1705548335460; Wed, 17 Jan 2024 19:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548335; cv=none; d=google.com; s=arc-20160816; b=T0wtmniVHISPY+nQmmBoV5vH0JZ2i+mVV3VGA53H4DGy3Ugy7W1h8p1t27gN4M7+pk cdUZGFe0uw6u+mtreh1dnY7WDcVT1q/Y377YxJXYSHBgC1Z6IiN63pxCbTf6hLBHATC3 5RUZPY/0LT4icZTyLgNUwdvKgjUk1hJSoz/ifIJWvDMlOY+qKBJXGq6E1s70CWPaNnxf qKS/TyYkyZFmvW+4o1SCR755rrjQAvsG1JgEyfPxgDB14+9hADtpoMv5FpGH5fFgW7AM HLO7vwclDZRgFIVXYhGjbhyrt+NFQUGVQBbFC4k19U07oIAvhkOto7VR7kIILyaiJ/Hz cAiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Z1Wm3BuytIxY9I50Ihr9Vi6BnC2ipwOgCPrtejpdauQ=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=CgolBdu6L5B2RfCmDnvEN+SanWAVtUPgJaKb4BldTYEd8KVLKxuV60ZZMoa2wdbGtN GBqkewyUC7kAt17iXIRe44ff5KCxqVJF5Zo9UYjuUoCeoxJa0QWd+tv320sHs+qajh74 c14a5zjgNyhikOLn4UIl7brIcoIjs/2krTT9XgfPX7L0iQy12ME12QjhzzGYg+F7Xwyr UHXbBOLYzU4FPllJKNsYyZpVPPB03jTwHhLDs37lDDNMCBXN/B6Ix7kA5sGd5WgC8Xl0 lRB9/KUQPp0L2C4YdrNdAAh5YbntmqTdv6xBX2LUKCfTbUO44DCGr+syl4NNYZbqtsHt LINA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5ySr9os; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o11-20020a05620a0d4b00b0078321155348si12530807qkl.523.2024.01.17.19.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5ySr9os; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; }; +/* 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_id_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 entry, + * 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; /** * 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); +/** + * 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_size); + +/** + * 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. This + * 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_index); + +/** + * 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); #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); } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size) +{ + 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 = 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 = (char *) qemu_plugin_scoreboard_get(entry.score, vcpu_index); + return (uint64_t *)(ptr + entry.offset); +} + +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64_t entry) +{ + uint64_t total = 0; + for (int i = 0; i < qemu_plugin_scoreboard_size(entry.score); ++i) { + total += *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 qemu_plugin_event ev, do_plugin_register_cb(id, ev, func, udata); } +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 = + (struct qemu_plugin_scoreboard *) value; + struct resize_scoreboard_args *args = + (struct resize_scoreboard_args *) user_data; + if (score->data->len != args->new_alloc_size) { + g_array_set_size(score->data, args->new_alloc_size); + } + score->size = args->new_size; +} + +static void plugin_grow_scoreboards__locked(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.scoreboard_size) { + return; + } + + bool need_realloc = FALSE; + while (cpu->cpu_index >= plugin.scoreboard_alloc_size) { + plugin.scoreboard_alloc_size *= 2; + need_realloc = TRUE; + } + plugin.scoreboard_size = cpu->cpu_index + 1; + g_assert(plugin.scoreboard_size <= plugin.scoreboard_alloc_size); + + if (g_hash_table_size(plugin.scoreboards) == 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 = { + .new_alloc_size = plugin.scoreboard_alloc_size, + .new_size = 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 = 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); plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); @@ -576,8 +642,39 @@ static void __attribute__((__constructor__)) plugin_init(void) qemu_rec_mutex_init(&plugin.lock); plugin.id_ht = g_hash_table_new(g_int64_hash, g_int64_equal); plugin.cpu_ht = g_hash_table_new(g_int_hash, g_int_equal); + plugin.scoreboards = g_hash_table_new(g_int64_hash, g_int64_equal); + plugin.scoreboard_size = 1; + plugin.scoreboard_alloc_size = 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 = + g_malloc0(sizeof(struct qemu_plugin_scoreboard)); + score->data = g_array_new(FALSE, TRUE, element_size); + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + score->size = plugin.scoreboard_size; + score->element_size = element_size; + + qemu_rec_mutex_lock(&plugin.lock); + bool inserted = 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 = 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, void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); +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; }; From patchwork Thu Jan 18 03:23:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763599 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589477wrz; Wed, 17 Jan 2024 19:24:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwMiKPXoZrxNcMLfLamiSCBOxADloMexc2YXijhnBmUTy5xGj83vzIDMjqMy+cNIDoUu7E X-Received: by 2002:a05:622a:1817:b0:42a:160b:4ae2 with SMTP id t23-20020a05622a181700b0042a160b4ae2mr243432qtc.120.1705548276556; Wed, 17 Jan 2024 19:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548276; cv=none; d=google.com; s=arc-20160816; b=PQG5Hjw6Tk965q7rgT35NYcmg8m7MB7+ergcyZxebIHY1ItmIrnxX0W/6eE1oDoplg mgTT3ybsb4zpfaFbBok5Ms34U6pXT6Ma57xG0oXSEB6usjqRaOBDlIVHtMwU9LQcVnvF /ULkyB7G8Ak6kOiLq3WVET3gDDpEji/937hfjIvZ912ZYctRr552oMdsHRNFjhX23nI0 Sywqlccm5i7nkoV4PImsvOib+14H0SCJS8ZvaRdF9Cvstg++F3XIcKCmVJI4jJRo0+tU 9jJskGCyiZ+NzezPq9LCsj9zPVxSvrsgQXaRzS7vQ+bDBeRvRx2y9O96cU+DAXI9oDiN O+Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OCiv7Y34jUunl2R1CBjG/RVHjCXAnByZwR7nxj0vfkc=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=OxYDdt+kcKfiNI17C7U4XaSmjC1N70Sjx2ydl0JWFHNsHtORghc+N2UV/TGYAeYaT5 igaM6Hjv7/ODzR3cNx8Q3W2GHPdnN1i9f/+Dty325GMplJjqcdA5m1lVhgSNCZ+o/auU OoFNphOJj/WJoF0AzQeJjDOAGPKFimVLkSRFVRefYpK0nwRYwA05eAGI5hZLoOgUJkpp qXhOhXdNVdpk+Fu+GRgzh2juP/GbKJfakpQCbRa/dXQjI4Em5hu9fR67SjTh6keWJymO QVfmrAp78C+URM9aV93LzmxxkQlqx5lsSzesuY1y5KV2gCGi9xLmc3bW77IvRevD+Bqw 7iDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qAhhsCA2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w18-20020a05622a191200b0042573335c80si13317439qtc.263.2024.01.17.19.24.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qAhhsCA2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 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 From patchwork Thu Jan 18 03:23:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763610 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589869wrz; Wed, 17 Jan 2024 19:26:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwTfk9WtgmGv1mki7l4qaUWytTXIGRk7cbYSs1ALEAHBh4LHol7GjvJpqUn+gHt8x9/PZI X-Received: by 2002:a05:620a:144d:b0:77f:b027:8aba with SMTP id i13-20020a05620a144d00b0077fb0278abamr137048qkl.145.1705548388913; Wed, 17 Jan 2024 19:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548388; cv=none; d=google.com; s=arc-20160816; b=kAhnY0P0/HAFFhnL0mtBvwuBwGRdw80LHLlY4fx7arxHtve7xM4wZ8cUc7ErjZ7IjX rlU9oRwh2gXt1cCdvMPPuK5OxjCfLwLS9Carl0Hp3d2FfZtlZyeRVmYQvEnI89XzewAt l6Dx5A6tlDYKieBTMoiYUrpj9CwkIDQxGzeOFPJVYmi6eb/15UkWDU7mOJWqPRoNIG4O Rg3ykOJIwu7bNN3GHfFVpR3CsImZlRo81nbwfNS0jcFrhZzumKYmq24M05oUiIGUmSXT mb5QEihD1VcEdT+6oXi64XyUXv+vslV7/Ha/M6Eh4YEbKuvuNaUnNxBaxLdgLaYGqH4D /aow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=avAAc0Vlx/SbBP3d3CcEQtIUcAU9hvFMhQ4VLfaD1p0=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=pJYhYMmX3hRSw9mx3pLmC4b0abvSkeuryn/mC9y5AhGf4p/kLumciZb7+CSsT6ZqnW vmmxBvj8MhQdimNJu45rBXL1h3RKQVwAo6pG+ZvnBABbG6xfsi+A3gzTDftxZcyZCFRX DhUY67oSb30IKvalwnYtXX8ashfO8+UJCqBOrBJ23VkjjTgV/6w6PYfiPBbjOBh91uU+ DRYHJ1bXNarmcxq8Ejf+XZyPzYXNwQ78z2SVDCa7MWD4qDiVdF2kDlRRzcuKRHzd+LsU Hm8Z9d5f6Gx3176Lt5ng2iVRww+hbbNm7FwFp7vrDJdO2XS7Ps9lHikb6XjEAg91cF+1 +DwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bHccsBOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z27-20020a05620a261b00b007837441ec63si2292746qko.317.2024.01.17.19.26.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:26:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bHccsBOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). 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ée --- 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 qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); +/** + * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @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); +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @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 *ptr, uint64_t imm); - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @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); typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, diff --git a/plugins/api.c b/plugins/api.c index 4de94e798c6..132d5e0bec1 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -111,6 +111,20 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, } } +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 flags, @@ -136,6 +150,20 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, } } +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_INLINE], + 0, op, entry.score->data, + entry.offset, entry.score->element_size, + false, imm); + } +} + /* * We always plant memory instrumentation because they don't finalise until @@ -148,7 +176,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], - cb, flags, rw, udata); + cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, @@ -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); } +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; From patchwork Thu Jan 18 03:23:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763600 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589572wrz; Wed, 17 Jan 2024 19:24:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxixPoUBi0RaU+Al4BN+UUyTEmcXPfoPlHWZFn4m8PgJGh+3wRoqON3aZbyR+c414wcccl X-Received: by 2002:a05:622a:5c7:b0:42a:14fa:8f3c with SMTP id d7-20020a05622a05c700b0042a14fa8f3cmr253474qtb.11.1705548297867; Wed, 17 Jan 2024 19:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548297; cv=none; d=google.com; s=arc-20160816; b=VGhXv9wq/FrPI16DEdCfBxgGf5Vh6/lunS/aCkSN3KSF4502aG0bzDHJTkATb6cfWA swuxZeCKirnKWmclKowmI+k0VM2siK8XoxNrUXALIF8rxrCutbkrZP/UMQ1SS7dBUd40 VAr4Jd1LJl5xMKuB/tsmX44D1pC7IM/BDCJcM+5qRefpyPcZzSMop7L5iTloZanQOERP xIBIbijxn5fR1vFMkys3AxpYySdeYqBzvMDh7DPBzpvw7vE7UY6rc9iELG6891iIy+hl GrpcK8TURmBe5KEQHqcPikyh1HL63SDf2r1bflryb3Jd/fdEH+tWA2jq6KTF68/wiB1u Y2Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oP8DElGhxgrlgCtIGb2Ytj2mtZyUCbfff7H8LKle7FM=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=0LpOlQYlICPwAVkPMqhYVk5DhG/A0eVxaZLoSjOlmxiqIJCc3rT/Zt/LTnsuVKmlHF te1TSrvs05EuOJvXT48nAsY6NYlJ6ee35nMiR11M4zIeMUIz7gK6SCnrHbtY8qp7+kqF jOcdn8KJs1cA+8zIsnVT/7ngaBoNs9LjAju/UMBf7b9ADKPEtEdqNWv+sQB/Q1Lp8bNM jywNZscXCQy3N1u0wSzfJjknFFwdHBxqz5eQMwv02cfIFLs2aNseL2tbddd1LJnjuxjU h4zQmujEk5hBEoDBWpHiQThoyN9lIiY6Xkm6lpXmI+57B8v2qXgi202i5nvJ6aFsoxld V+OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lfyupez8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b16-20020a05620a04f000b00781cc3f5103si12494346qkh.511.2024.01.17.19.24.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:24:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lfyupez8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added. Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one. Signed-off-by: Pierrick Bouvier Reviewed-by: Alex Bennée --- 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 = QEMU_PLUGIN_VERSION; + +static void stats_insn(void) +{ + const uint64_t expected = global_count_insn; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_insn); + const uint64_t inl_per_vcpu = + 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 == expected); + g_assert(inl_per_vcpu == expected); +} + +static void stats_tb(void) +{ + const uint64_t expected = global_count_tb; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_tb); + const uint64_t inl_per_vcpu = + 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 == expected); + g_assert(inl_per_vcpu == expected); +} + +static void stats_mem(void) +{ + const uint64_t expected = global_count_mem; + const uint64_t per_vcpu = qemu_plugin_u64_sum(count_mem); + const uint64_t inl_per_vcpu = + 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 == expected); + g_assert(inl_per_vcpu == expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + const unsigned int num_cpus = qemu_plugin_scoreboard_size(counts); + g_assert(num_cpus == max_cpu_index + 1); + + for (int i = 0; i < num_cpus ; ++i) { + const uint64_t tb = *qemu_plugin_u64_get(count_tb, i); + const uint64_t tb_inline = *qemu_plugin_u64_get(count_tb_inline, i); + const uint64_t insn = *qemu_plugin_u64_get(count_insn, i); + const uint64_t insn_inline = *qemu_plugin_u64_get(count_insn_inline, i); + const uint64_t mem = *qemu_plugin_u64_get(count_mem, i); + const uint64_t mem_inline = *qemu_plugin_u64_get(count_mem_inline, i); + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " + "insn (%" PRIu64 ", %" PRIu64 ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + g_assert(tb == tb_inline); + g_assert(insn == insn_inline); + g_assert(mem == mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); + + 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 = 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 = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_insn_exec_inline_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 = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + count_tb = qemu_plugin_u64_struct(counts, CPUCount, count_tb); + count_insn = qemu_plugin_u64_struct(counts, CPUCount, count_insn); + count_mem = qemu_plugin_u64_struct(counts, CPUCount, count_mem); + count_tb_inline = qemu_plugin_u64_struct(counts, CPUCount, count_tb_inline); + count_insn_inline = + qemu_plugin_u64_struct(counts, CPUCount, count_insn_inline); + count_mem_inline = + 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 = [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os == 'windows' t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', include_directories: '../../include/qemu', From patchwork Thu Jan 18 03:23:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763601 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589589wrz; Wed, 17 Jan 2024 19:25:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwN611kgE0iaBU/O7iqGzbt8kUUlEF6SHlinIuX+jhlZAYfWmXHB1rbsON6q4IttNERyP7 X-Received: by 2002:a05:620a:261d:b0:780:e6b9:621a with SMTP id z29-20020a05620a261d00b00780e6b9621amr239753qko.67.1705548302664; Wed, 17 Jan 2024 19:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548302; cv=none; d=google.com; s=arc-20160816; b=fYgRjYwglYE0XFyVQMVy5VUsSeA87VuVODuqccMLD1Ny7jmsShX+OwKkGcanD0Upp9 w23W/D7t42kChwyrnJx0dMDbIYu/rA1sOV9g+kDz5hlfBr6wxiJ56fe6WKFiPOfY3E+3 nkhBj0aE7FGvXYSpnOR95T8fcfj4oeidMdUJMcycBr2JnbhDYBOqfGK4+7ZIq72ukkrb XFnYtM3E3jiNmL3mJpumgZNrNV1oykfnn1GTiYSV45WWmXJjymQymwhvFG95tpfGBkY9 0GccbwMDI/NILfMpATHedfhckLl/1LDwftQRftjXCnWydxLs9yW7Z739f/fK50UG7pG1 wOyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=llai94LBCUTj3dfHKAUWRulZm20ERaPuqBXTHgqZDnw=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=Oe79eNDaXymj6NVP2DqSn0a7vHkvDkGpFNiM2B+RLV6itqPj14b3P4jo60wianKuxE ioO7YXwGa27zULCXWlB+rbZHEEQXMH8WpQ2TkD+7kcEVP+0YmkjpV9Br3kk14I/Te2aP 7P5uO1SBprl635R6I+x1jmCvyJhl2DxTAq3VdusVmUfksTsc1ZtoLJNkOospsSSXMpiD cxo7ul4jHKf4VxdArJFBVQ7fQpeYRbNmOZZty0P0J/ZwfvSNsjm6MbJTwyt9wPJPtc2O NZKXU9/3Gl7TrAWW3MBCZFQlY9u/UjIBK45DSIdUcwYvKT0ZCvaDUSb6mwct87qJbtsU DDHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbP0lnJd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l3-20020a37f503000000b0077f6ff697c6si12653120qkk.164.2024.01.17.19.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbP0lnJd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier --- 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 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -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 = QEMU_PLUGIN_MEM_RW; @@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out = g_string_new(""); - if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_mem_count); - } - 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); } 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_plugin_meminfo_t meminfo, struct qemu_plugin_hwaddr *hwaddr; hwaddr = 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))++; } } @@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U64, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + 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, } } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + mem_count = qemu_plugin_u64_struct(counts, CPUCount, mem_count); + io_count = 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; From patchwork Thu Jan 18 03:23:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763604 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589682wrz; Wed, 17 Jan 2024 19:25:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM9JS6hfQV9SQJey00If/QgLfPhFlfIUyLbEeudeC4Y8jEJbtFG5ZvSQBmVuUBdSfmvYDu X-Received: by 2002:a05:620a:ec7:b0:783:1dda:f09 with SMTP id x7-20020a05620a0ec700b007831dda0f09mr2385062qkm.44.1705548328474; Wed, 17 Jan 2024 19:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548328; cv=none; d=google.com; s=arc-20160816; b=FnDH/3py25OVXYk4yZqqMf1pcy0ybkM9yEAZRVDEFFGbcPajTFbs6NxVls5cZpMjuY 5h4vSQUZt1XnO3j/v536NMlIirGwGO8tLKIG4asWxybLx86v9PjidXk0UT2lczVXDkD7 ZleatWO9sE6r+T/d5lSjb4JiXeIvQRMbbmUjF+IuVeODwIeyEvSqojG5i/tdE2/ksv1w zB60rMoi8X8LdMe0hdx0UKz29I2n2r1t91Xf71BpdCZA/FjH75tgLZiXX0vIy7X6KsVd L94F11hL9Ny9EEtECyE1TonKtXF3NHyxjjaZhPa0WKNWjp0fqd3VrdPkL6IhlRkwx5VV Wspw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k5p6lYRvka4FY/ZAhzAOUj9HGQolA6nHRzKa6RDIFjg=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=QQtsQoOmOrdGqFMdm7HEOC7wEWa+NOwFEZsaLX3QggGcMcqbvzGq8GteZKW16ZIYwL Z6MPNWuTbAgZBAnHUd+ZP0iqxET+HftEHk1qNy5beq9ZaSJIZGlgeiKPbOH59YRMp3oC Nt4kbWJgGn7bxze8q1oOlwkNomtcrFdeJR7D/vM4v4DYM4xYtsG+/XaAGYyFUgJir8H3 zITZ/A476Ltsn4y1AoRjOltf3uPXmU0id7sJIo8KmD4j3Ovq6H0YmpuQnM7Fs/lksFxx krexncJ4gN73EmM5wIyhR0/1soVwJ4TaiRxy/hkbe7dwBHBzRFekNBbKx07JA+W5QfOD CRYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wq1wlxvm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o8-20020a05622a138800b004282544d995si13097547qtk.383.2024.01.17.19.25.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wq1wlxvm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -#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; static bool do_inline; static bool do_size; static GArray *sizes; +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; static GArray *matches; @@ -48,41 +44,40 @@ typedef struct { static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i = cpu_index % MAX_CPUS; - InstructionCount *c = &counts[i]; - - c->insn_count++; + (*qemu_plugin_u64_get(insn_count, cpu_index))++; } static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i = cpu_index % MAX_CPUS; Instruction *insn = (Instruction *) udata; - Match *match = insn->match; + Match *insn_match = insn->match; + MatchCount *match = qemu_plugin_scoreboard_get(insn_match->counts, + cpu_index); + g_autoptr(GString) ts = g_string_new(""); insn->hits++; g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", insn->vaddr, insn->disas, insn->hits); - uint64_t icount = counts[i].insn_count; - uint64_t delta = icount - match->last_hit[i]; + uint64_t icount = *qemu_plugin_u64_get(insn_count, cpu_index); + uint64_t delta = icount - match->last_hit; - match->hits[i]++; - match->total_delta[i] += delta; + match->hits++; + match->total_delta += delta; g_string_append_printf(ts, - ", %"PRId64" match hits, " - "Δ+%"PRId64 " since last match," + " , cpu %u," + " %"PRId64" match hits," + " Δ+%"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); - match->last_hit[i] = icount; + match->last_hit = icount; qemu_plugin_outs(ts->str); - - g_ptr_array_add(match->history[i], insn); } 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 qemu_plugin_tb *tb) struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); } else { uint64_t vaddr = 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 = qemu_plugin_insn_disas(insn); - int j; - for (j = 0; j < matches->len; j++) { + for (int j = 0; j < matches->len; j++) { Match *m = &g_array_index(matches, Match, j); if (g_str_has_prefix(insn_disas, m->match_string)) { Instruction *rec = 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, *cnt); } } - } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_count); } else { - uint64_t total_insns = 0; - for (i = 0; i < MAX_CPUS; i++) { - InstructionCount *c = &counts[i]; - if (c->insn_count) { - g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", - i, c->insn_count); - total_insns += c->insn_count; - } + unsigned int num_cpus = qemu_plugin_scoreboard_size(insn_count.score); + for (i = 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 = 0; i < matches->len; ++i) { + Match *m = &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); } /* Add a match to the array of matches */ static void parse_match(char *match) { - Match new_match = { .match_string = match }; - int i; - for (i = 0; i < MAX_CPUS; i++) { - new_match.history[i] = g_ptr_array_new(); - } - if (!matches) { - matches = g_array_new(false, true, sizeof(Match)); - } + Match new_match = { + .match_string = g_strdup(match), + .counts = qemu_plugin_scoreboard_new(sizeof(MatchCount)) }; g_array_append_val(matches, new_match); } @@ -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 = g_array_new(false, true, sizeof(Match)); + /* null terminated so 0 is not a special case */ + sizes = g_array_new(true, true, sizeof(unsigned long)); + for (int i = 0; i < argc; i++) { char *opt = argv[i]; g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); @@ -208,9 +204,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } - if (do_size) { - sizes = g_array_new(true, true, sizeof(unsigned long)); - } + insn_count = qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint64_t))); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); From patchwork Thu Jan 18 03:23:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763603 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589679wrz; Wed, 17 Jan 2024 19:25:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1mbXGpBZhKsisK5nXaiZyyMsLeBb7vwZY35573bPmKz17uerf1kiOtAFnf5kdSJkZPgA1 X-Received: by 2002:a05:6214:19e5:b0:681:7709:610d with SMTP id q5-20020a05621419e500b006817709610dmr2848514qvc.20.1705548327636; Wed, 17 Jan 2024 19:25:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548327; cv=none; d=google.com; s=arc-20160816; b=xFBSk02i46MRrACWxd/nUz/x76qGtf02A2lUhbgcynNUwJRGkcgK+7Hz01If5+3C4P FmFFQNflEorek2jjS/a+LHxz6B2Op8qo9S3o7FgZ5Lb+f9SAid7FoeAjpx7QtRL6LBCb G9tYWVvaZa86jtJROOWFsgHoKMG71LM9vUEpLqEY8/ZGF162Cz0lFRgu58Ta0ZvoXbPC 54chTRFv8H9UX83/jx4vfttZEhq2MF8TJ1Kb08v39ObHDOP0E1eWjzZ47tZSWmJWayIk 8f9Pm2SxFoh0fAw6NTUJgHaeeiSNXtDFoEivI8V/fIM12e0Yl96xiqCD4bbcklEkKCtO qIJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q4Xlbv7w1QB06viMEvJrvyI5kfhMiq7AkgJexCqUX1c=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=T+FHtbxaJHEAU0/8H2zvIkw0AIvaViIr3G7R8gdghCFYAVcbirnmBMq41I2MQicTrJ aZthRDDJXfgUM2tn60S5zHNNRO7LH3i2GUWov5rzP75iJTumoCMssrLXLqoEYyCWqp7B 4cRdAtFJLS4/WHyHsoFni8h4DYSC1AhdYoPMKZ5zG0JR9xcVv33p7iTGjbeogfVaBRd4 KOpMOiizlYDO1GS8gMUnQhjvJAJSN68Voj6XcyicsZk9aSGxZ95fQeVhqvkgN4Ure2/M rHnFLcNKFR2RVNeMjY07qSUlnsdo6NM7V1R0EK3p4WA85rUbbgrgmu9tABCAvPDLehAs sfzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="stWR7/3G"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h24-20020a0cab18000000b00681778d1495si3451531qvb.47.2024.01.17.19.25.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="stWR7/3G"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = QEMU_PLUGIN_VERSION; typedef struct { - GMutex lock; - int index; uint64_t bb_count; uint64_t insn_count; } CPUCount; -/* 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; +static bool do_inline; /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; -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); } } static void plugin_exit(qemu_plugin_id_t id, void *p) { + const unsigned int num_cpus = qemu_plugin_scoreboard_size(counts); g_autoptr(GString) report = g_string_new(""); - 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 = 0; i < num_cpus; ++i) { + CPUCount *count = 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); } static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count = g_ptr_array_index(counts, cpu_index); + CPUCount *count = qemu_plugin_scoreboard_get(counts, cpu_index); g_autoptr(GString) report = g_string_new(""); - gen_one_cpu_report(count, report); + gen_one_cpu_report(count, report, cpu_index); 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) static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count = max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count = qemu_plugin_scoreboard_get(counts, cpu_index); uintptr_t n_insns = (uintptr_t)udata; - g_mutex_lock(&count->lock); count->insn_count += n_insns; count->bb_count++; - g_mutex_unlock(&count->lock); } 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 qemu_plugin_tb *tb) size_t n_insns = qemu_plugin_tb_n_insns(tb); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.bb_count, 1); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &inline_count.insn_count, - n_insns); + 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, } } - if (info->system_emulation && !do_inline) { - max_cpus = info->system.max_vcpus; - counts = g_ptr_array_new(); - for (i = 0; i < max_cpus; i++) { - CPUCount *count = g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index = i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); - } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); + bb_count = qemu_plugin_u64_struct(counts, CPUCount, bb_count); + insn_count = qemu_plugin_u64_struct(counts, CPUCount, insn_count); if (idle_report) { qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); From patchwork Thu Jan 18 03:23:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763609 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589799wrz; Wed, 17 Jan 2024 19:26:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPhMsDsE7KbHk1P13B4xmIPI9IAkqZkUOrW7i88WbmpUBqcjFpg8BvlGTMOvqfSMpWl6WC X-Received: by 2002:a05:6808:f0e:b0:3bd:9aea:143e with SMTP id m14-20020a0568080f0e00b003bd9aea143emr299470oiw.23.1705548364071; Wed, 17 Jan 2024 19:26:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548364; cv=none; d=google.com; s=arc-20160816; b=BrzPyEOLOF1h83FBuE4YywUGiSU8D9RPHT793IdD46jzlwBAKMP82v4SMUVGHE0c7h wbwDoYaRpWd8VxlAl0NGNeO8t32QAgoAfsfMWyqWalmFKT2GiVTkDWpsXA0G0nAvRM88 Ooo7mYisGhqAL3Om/ewB8M23Qu2d2gBN8NCnUaDYBHfWuiKWXmdh/7HCQn1fkj41mL/D /R45d3ejVIRfui4OL8Q2vzWJ9z+8OEQ0kNOe2+ZULj1SGD5k9ft0VmWKW1HpRj/ORlmg 0cxxyOdDaFmlXrTqm86bCvrEcBWrL3aAZLwYPhPxK9Sx6UH3/R+BEYAEukRL6NX57mmT 2QaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OpYndL8vLGdfYul3boxTKF+u6iZVN8VJoSivXt39QS0=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=dC/mz7PoztI33oHl01sviz7xb/Gbil39zWWF3fcDJh/6efvEgtUtpKqCKZUq8vW/7G d7uW9k/qOnY4cguZaL2lFiKWJ9V1aIz3Jldd6CWGMQ2V1hKACLi598V5Z4LUMShGKGdf gz+GhCwdg0uJhdYrUUFO3/z+JKdW+QvEid5/jgurkEwRoIen1ZhvbrrWiWDQx1/nkJNR sEgJrYo8+nnX0RcHFyhaYDVs95cpBgHQXYrd4ZBvzWegX7gT7ILVaDYqry5OpK4/b0L+ MsuNlwTTML/LsVfk6KsH5t4MXLKQK8XUkVNZBk0YIaoAIvCBE5wALWul6rR5j2V1AZqo UQiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nJHf9Dv2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i3-20020ac85c03000000b004297595bc29si13031561qti.488.2024.01.17.19.26.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:26:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nJHf9Dv2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier --- 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 = 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; @@ -43,7 +43,15 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) { ExecCount *ea = (ExecCount *) a; ExecCount *eb = (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + uint64_t count_a = qemu_plugin_u64_sum(qemu_plugin_u64(ea->exec_count)); + uint64_t count_b = qemu_plugin_u64_sum(qemu_plugin_u64(eb->exec_count)); + return count_a > count_b ? -1 : 1; +} + +static void exec_count_free(gpointer key, gpointer value, gpointer user_data) +{ + ExecCount *cnt = value; + qemu_plugin_scoreboard_free(cnt->exec_count); } 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; - g_mutex_lock(&lock); g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts = g_hash_table_get_values(hotblocks); @@ -63,16 +70,20 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) for (i = 0; i < limit && it->next; i++, it = it->next) { ExecCount *rec = (ExecCount *) it->data; - g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + 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))); } g_list_free(it); } - g_mutex_unlock(&lock); qemu_plugin_outs(report->str); + + g_hash_table_foreach(hotblocks, exec_count_free, NULL); + g_hash_table_destroy(hotblocks); } static void plugin_init(void) @@ -82,15 +93,8 @@ static void plugin_init(void) static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - ExecCount *cnt; - uint64_t hash = (uint64_t) udata; - - g_mutex_lock(&lock); - cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash); - /* should always succeed */ - g_assert(cnt); - cnt->exec_count++; - g_mutex_unlock(&lock); + ExecCount *cnt = (ExecCount *)udata; + (*qemu_plugin_u64_get(qemu_plugin_u64(cnt->exec_count), cpu_index))++; } /* @@ -114,18 +118,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) cnt->start_addr = pc; cnt->trans_count = 1; cnt->insns = insns; + cnt->exec_count = qemu_plugin_scoreboard_new(sizeof(uint64_t)); g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); } g_mutex_unlock(&lock); if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + 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); } } From patchwork Thu Jan 18 03:23:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763602 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589656wrz; Wed, 17 Jan 2024 19:25:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFb2P4kpzB9L23gUDE38vpxk9Kfq3GM5DtiY2pZ/21u71Ev9tlfaq5MCLRdjerGI52FJ2cv X-Received: by 2002:a05:620a:ec7:b0:783:692b:ce02 with SMTP id x7-20020a05620a0ec700b00783692bce02mr145710qkm.74.1705548318078; Wed, 17 Jan 2024 19:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548318; cv=none; d=google.com; s=arc-20160816; b=oqRXCIBFCNZB9o3wZybMPDIvy2KsW/vr9kn9To0MDhrOv6qNq/wWCTJEwut772iz7v 2Tpdxdf+wSErKUGTmttlX4s8y1rPn0/DIoMDPPyL/j2zZTe/gXbHP1ElXcfID756gAcD 2bZAdtV/yRPnFfrvFM4Ifggz8g5mGiVFFoA3pvaJ5wLqKVGpY82ctUWOAEpxkfxLPk+U Jj1rX4abZK/T9uSDeE3KbyANDtaEN9CaTt0RAiE8sP3S4qTt8POf9m9EfVfjOlYv+nQJ U5oVahvhYBeGomUaluubFFy89rR7EQ7ct3+lQ3GAWmt49Qkc30gDhwPSMQ0M6c9DbG0W 2jFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8IOrVF2ci3KA0n859H758KBpLzvdBx7y6KGSkBugi9k=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=f6eumQyzBC8sBBAaQNpDiT5LXZmozM5fOW0U06JWe1AGcuXJy2NkOwnagJ76LdWrEh F3g2mAZY2grR74OCTXU1rDM2fM+ro9eY/oa6T2pz6k15sHoNPFnhXzplWEN28kDde7jy k3TANURQMIj0NC61uCJ9IY+Wn3Y2bRH5sepFY+XqAhBDjJUZTR06JAtGeloo3pAO7vBP GucrRmoN0JIJnm1rC/HJ05m2VZZ7ouHd6/HQh7z7uCCGFUjoxHOggS2R3a4dB0/sOSVc oaMjkz3rBVTYcyyjlR27n2s1ItgxLiePrUh46Ar5+Sic6Sji3HCS+fquKLYozK0HFbTg etVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GR2MnKuP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f7-20020a37ad07000000b0078316faf794si12740573qkm.441.2024.01.17.19.25.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GR2MnKuP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; typedef struct { char *insn; uint32_t opcode; - uint64_t count; + qemu_plugin_u64_t count; InsnClassExecCount *class; } InsnExecCount; @@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) { InsnExecCount *ea = (InsnExecCount *) a; InsnExecCount *eb = (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + uint64_t count_a = qemu_plugin_u64_sum(ea->count); + uint64_t count_b = qemu_plugin_u64_sum(eb->count); + return count_a > count_b ? -1 : 1; } static void free_record(gpointer data) @@ -167,12 +169,14 @@ static void free_record(gpointer data) InsnExecCount *rec = (InsnExecCount *) data; g_free(rec->insn); g_free(rec); + qemu_plugin_scoreboard_free(rec->count.score); } static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report = g_string_new("Instruction Classes:\n"); int i; + uint64_t total_count; GList *counts; InsnClassExecCount *class = NULL; @@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class = &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + total_count = 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=0x%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) } g_hash_table_destroy(insns); + for (i = 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j = 0; j < class_tables[i].table_sz; ++j) { + qemu_plugin_scoreboard_free(class_tables[i].table[j].count.score); + } + } + qemu_plugin_outs(report->str); } @@ -232,11 +243,12 @@ static void plugin_init(void) static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - uint64_t *count = (uint64_t *) udata; - (*count)++; + struct qemu_plugin_scoreboard *score = udata; + (*qemu_plugin_u64_get(qemu_plugin_u64(score), cpu_index))++; } -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 = 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 = opcode; icount->insn = qemu_plugin_insn_disas(insn); icount->class = class; + icount->count = + qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint64_t))); g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } g_mutex_unlock(&lock); - 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; for (i = 0; i < n; i++) { - uint64_t *cnt; struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); - cnt = find_counter(insn); + struct qemu_plugin_scoreboard *cnt = find_counter(insn); 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, cnt); @@ -322,6 +335,13 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, { int i; + for (i = 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j = 0; j < class_tables[i].table_sz; ++j) { + class_tables[i].table[j].count = + qemu_plugin_u64(qemu_plugin_scoreboard_new(sizeof(uint64_t))); + } + } + /* Select a class table appropriate to the guest architecture */ for (i = 0; i < ARRAY_SIZE(class_tables); i++) { ClassSelector *entry = &class_tables[i]; From patchwork Thu Jan 18 03:23:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763606 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589726wrz; Wed, 17 Jan 2024 19:25:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOWmk1pyxyw7xEPzW/bO5RV8qpdUyVhMi/4PR0upaNXka8fTuKmlvyuRgNx1dlMM6EOeBH X-Received: by 2002:a05:620a:2119:b0:783:6d1d:6de5 with SMTP id l25-20020a05620a211900b007836d1d6de5mr141215qkl.110.1705548340167; Wed, 17 Jan 2024 19:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548340; cv=none; d=google.com; s=arc-20160816; b=00PNzZewk33xCL7YMMfYf9KnnQXvkST9kuR5bGSJHYAchgANwkUc6MEFUtnBNDHUdr sLwZTMlA0iO5LWu7W0WQvPyJrocu/J6JlinYzV1dp6nXoWZLoJOfSq8Y9X2zPtxPbqhG TpDRT8z7Hog5pFqbb389WKJFcUNHKYJ8yNUuETh4+AsQ6v1XO4HVAg1Z7ve6KhPCUVtr lYzzYmVXwl6j0K/gsvT/L7s6e3sPo1wRGmBYI8RpG3xX1xoxocPxkLHZEk2neXgets4s ki5RakFqfEJwGBgXRFbudWYZzv0i/qqP8SAdgEfEDd5yjEsLV7+ixXOf0Fjq4YjnwZLZ tE3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZLvxeFqnyu9l57+cwcakx7h5EhmFm40PDnmxlZb5fZM=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=fwCwVDlO8jFZ7Xbq0mBZWbavPAzP80/56T+lCHsmEu6hzq8ZfOTEUZWtycX3JiN24E Ctpex4Xu+yN/jmIH8g/zZT2FGtQzzRhhJoZ+5aUQd+Bax0CH+y/3U0hWs6eb1Cco2i3y rUP5qPzd/uPfoOXnOXcHwreD/+MSE+K7PSC3laV6lWxS6KDa8oKSp67ngXcndcPWwTYh 1nlq/f9pc1N2+/fivEboF9yHE47vQmwhFoO1AQCl7b0jKgbs+qk6QGlrTdmcs8NRMovq 87oQS3EX3lTmGi5VeZcfPwbe+330R5G4jRahoWGt9qaZeOCHWj0XM1dE+jXJ8+flwf16 EUrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GsmCWLWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p26-20020a05620a057a00b0078338894892si12740673qkp.571.2024.01.17.19.25.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GsmCWLWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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. */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 /** * struct qemu_info_t - system information for plugins @@ -311,25 +316,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; -/** - * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op - * @tb: the opaque qemu_plugin_tb handle for the translation - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time a translated unit executes. - * Useful if you just want to increment a single counter somewhere in - * memory. - * - * Note: ops are not atomic so in multi-threaded/multi-smp situations - * you will get inexact results. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op * @tb: the opaque qemu_plugin_tb handle for the translation @@ -361,21 +347,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_cb_flags flags, void *userdata); -/** - * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op - * @insn: the opaque qemu_plugin_insn handle for an instruction - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time an instruction executes. Useful - * if you just want to increment a single counter somewhere in memory. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -599,24 +570,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any memory access - * @insn: handle for instruction to instrument - * @rw: apply to reads, writes or both - * @op: the op, of type qemu_plugin_op - * @ptr: pointer memory for the op - * @imm: immediate data for @op - * - * This registers a inline op every memory access generated by the - * instruction. This provides for a lightweight but not thread-safe - * way of counting the number of operations done. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access * @insn: handle for instruction to instrument diff --git a/plugins/api.c b/plugins/api.c index 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, } } -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, imm); - } -} - 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 qemu_plugin_insn *insn, } } -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!insn->mem_only) { - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - 0, op, ptr, 0, sizeof(uint64_t), true, imm); - } -} - 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_plugin_insn *insn, cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm) -{ - 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, From patchwork Thu Jan 18 03:23:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763612 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589931wrz; Wed, 17 Jan 2024 19:26:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4b4AJkBrm9+yig1SUPzB7BjOUul89oouHXJs2p1aVmgec37+PuyH+S5+vOsnoZwAmoO00 X-Received: by 2002:a05:620a:25cb:b0:783:486b:fc89 with SMTP id y11-20020a05620a25cb00b00783486bfc89mr162013qko.27.1705548404731; Wed, 17 Jan 2024 19:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548404; cv=none; d=google.com; s=arc-20160816; b=mVPg0oW8f/WSrC7UUFbmIQhGkfcKULgcQ2M1Jxhc3tZCfPQas/nEOhuq7RHffY9dGq 6+X5l8vSldImlDCnGEZsMASU85is6w7wlSKOLaSbvusvPg0M0N6Bm/qIdXZspxkoDnsL bIhBvFB8hQ1X8WapJFpRZnbkVxkrPVIKd3Oofb0KUZRuaYS1g98XUhkp/4GcMb4NGy8u 8irj6dyHgcyMcLI5naFWI7CKuMLldlh4PlJp/CZH69rJaupwGqhl9/v3Y+gjhkqI01yG ZgzX5JUJWlLtWkpvMAepLmWW+owQgFD99mz00nJ71zWmoS6rPGXS9lYQQ3U230wbzNnp rhrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pjIwKEUqnfGsc/JPgZZdh73H3Cz5ZaisrsiAEjZH8J0=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=QHbH8FqdJsm3A96eG1LU06TFvxyeSUttiS6cqeOKvn7CfIrW/P/tIJrHirTk1kCYxh /at6NAwSpT0VqzpDeQa7QQA2AbHjHImBkX7vaVikdfL7ARIScRZoY0apMseHdxaS6y8w rFCl7BtXcYVftIW19oBbXnNi/w1TnIJWmqGNoOAYz2oolhKRivC4EhQOesenp84eQPzN DDwJa4YWDHEzxHd4ZXL1maVqEOCMM5Eph57DcSn0ZI2bsRf4x9jUYqeT0jqLIkEV+7vM vh5muXgiDRt63qmxRBMkCfRToJ1h1q7QWnBApkcyPF6Dyl8Ofl35K555bzjD65YjIXRS 65GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8BMsB1k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dt56-20020a05620a47b800b007831a811eefsi12853443qkb.51.2024.01.17.19.26.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8BMsB1k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - char *ptr = cb->userp; - if (!cb->inline_direct_ptr) { - /* dereference userp once to get access to memory location */ - ptr = *(char **)cb->userp; - } + /* always dereference userp for inline operations */ + char *ptr = *(char **)cb->userp; op = copy_ld_i32(&begin_op, op); op = copy_mul_i32(&begin_op, op, cb->inline_element_size); op = 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); } } @@ -138,9 +136,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( { if (!insn->mem_only) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - 0, op, entry.score->data, - entry.offset, entry.score->element_size, - false, imm); + 0, op, entry, imm); } } @@ -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); } 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(GArray **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_size, - bool direct_ptr, + qemu_plugin_u64_t entry, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; dyn_cb = plugin_get_dyn_cb(arr); - dyn_cb->userp = ptr; - dyn_cb->inline_element_size = element_size; - dyn_cb->inline_offset = offset; - dyn_cb->inline_direct_ptr = direct_ptr; + dyn_cb->userp = entry.score->data; + dyn_cb->inline_element_size = entry.score->element_size; + dyn_cb->inline_offset = entry.offset; dyn_cb->type = PLUGIN_CB_INLINE; dyn_cb->rw = rw; dyn_cb->inline_insn.op = op; @@ -504,11 +502,8 @@ void qemu_plugin_flush_cb(void) void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - char *ptr = cb->userp; - if (!cb->inline_direct_ptr) { - ptr = *(char **) cb->userp; - } - ptr += cb->inline_offset; + /* always dereference userp for inline operations */ + char *ptr = (*(char **) cb->userp) + cb->inline_offset; uint64_t *val = (uint64_t *)(ptr + cpu_index * cb->inline_element_size); 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_plugin_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_size, - bool direct_ptr, + qemu_plugin_u64_t entry, uint64_t imm); void plugin_reset_uninstall(qemu_plugin_id_t id, From patchwork Thu Jan 18 03:23:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763607 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589738wrz; Wed, 17 Jan 2024 19:25:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IELkgotxh3v673VlD463t5Kem55f93wOe1qfon0/WANuUsmd3WSvp2AAtHpG17qbyjBKyg4 X-Received: by 2002:ac8:5e11:0:b0:42a:dd9:5d0b with SMTP id h17-20020ac85e11000000b0042a0dd95d0bmr205066qtx.70.1705548345495; Wed, 17 Jan 2024 19:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548345; cv=none; d=google.com; s=arc-20160816; b=C6Rt4E0sgx5OaLD/MOt+ozOb0yAlWOUkADSJuYRVi5HX+qHPYEF14eAOfs7XQE5zHb YbvG6I7Rz/15guxG9TfUVUMFuXRbvSuDxlIU2VTbZkVqoVo2/6yuQ5aaJFIBqTMcngGn au6Nkzz0NDbD//MfufY9lB/ilZaODjWydZ/se4MA6jsiRVPulmh7M1pS9eNu6jt2LaIZ WQ5ASsC7h8SXrpEVm109CAQNAcvKgZVSvPOVVI9iZkBZrp15x4JvLo4Yh0OYUQkGL2CL UQCCrPopTt2u9QMXPcX417olO7q/eDhkjIJy8B2qh8zyU+bHu89kShsgehp18KJ6BjHE Wi+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gY1HvrcRK/jb3DOwoSe5cKTH6nvlDdjohKhPFmwO/ik=; fh=d0r+Gu6tYm59GLc5D/YBFjKMQqgN1JC6qfvckRTBdKU=; b=Tgv5kiRWP887PomccK3WMTrwcAsVvoKH56F42aQgcAvmb9uc5U51hLMEtayBSVGizK 4CfEilt5CCMUVebODqlEJTMv2jwshTI8CIy6AXFThRbnCeU79DBY0pOP85q/X9RQlBdY pvAF++DrW+J8A5SYAgiaahBqeAeWuETqUgeJa4/6Pq1cKApS4IpcwGssZxcaVHZi5DNG amQQZHaoSARMQgJyao0AdAR4BUIFyXwSRv6j9QO+HJCGW38apXp2Cuh1xanNk3cMES7A f6ImOXcp5y8Ba/j8FjU1R6YlVobt8TSgAofBcejo7SQVisaMXJ+d5GKy8yJpHrB3x11G L4+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CEuUsMTq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i11-20020ac85e4b000000b00429d5815307si10268371qtx.362.2024.01.17.19.25.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CEuUsMTq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Pierrick Bouvier Reviewed-by: Alex Bennée --- 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ée R: Alexandre Iooss R: Mahmoud Mandour +R: Pierrick Bouvier S: Maintained F: docs/devel/tcg-plugins.rst F: plugins/ From patchwork Thu Jan 18 03:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763608 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589780wrz; Wed, 17 Jan 2024 19:25:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJH/LJn35xt3dFlPKZ8AORoDdO3F7mjYsDLM3Ub8gOBgu3v6RC6kLJwU0ZV7bVA3jqVYiQ X-Received: by 2002:a0c:df07:0:b0:681:5629:c2c7 with SMTP id g7-20020a0cdf07000000b006815629c2c7mr178235qvl.2.1705548359339; Wed, 17 Jan 2024 19:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548359; cv=none; d=google.com; s=arc-20160816; b=TurIoWFMRrpcDSB7/U+/D8coluGLLZv3bJpdrgHtGoqeqsjnDSQjf1SWXDlMIHvx8t nDsk+E/q+qOKz00pIYcCiBWs7fc7D36+hgmUD4E95f5+eRhLbV3ttY5moCmsFYRz07tn aVK3nSdcVlRCZ6mbZbWnYtRI51VhzNXgzmUEy0mLORlYLKKNXdxGpnUnZFF7zJf+VJ1Y 9S8xUpfbmqTBPNzOYZ5fqSA9pBO7+gNtlTQ2GSMNvB/YIVTTPj84uF6O2Fx/l/t71Hbc tfo0kmhCRpa0gfJxQfig+vr+nXsIsBy0rNo6dICxppFxjHOWdEiTilhqPXuEcDWAJT6/ dKrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+unRKaCSDZUa7wMcF5VMrkBGXnAvyrlpB3hgAdHK8PY=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=R14cWHgXblFRjCBjJ6QyN9jY1Q1y27cR0/uJNEidNjDCTXKq6ykLh25mIPZAi/8cbf pUn1j/gYEvg0HonXTB/DNfEunHsgm4Bkn9X6gJyPIqnojAjZqA/nAguXVpQrPy2733RK fCywtb6mqk5cH/7iXpcwPpmQd0iNm4u3+4FdzkZrZo015bz4i5K8CFWuMyoDSoz9fgVU hHc3iipBJ2+RT0CkbHt9CnWlz6iRXgwx+nNpCFkRJT8iei55t4VkYXJYKiP4+5qFcgxV xW9z0akslKHh2T7ld/gtByRPJcPPL3YecJOIZCeDxgbUW+wfG2ECVPOvXL3AJhqdnbBQ v8iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QthVr5L/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o15-20020a0ce40f000000b0067a56b2ec60si12878048qvl.168.2024.01.17.19.25.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:25:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QthVr5L/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , 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 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org ‘g_pattern_match_string’ is deprecated, Use 'g_pattern_spec_match_string' instead. passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ 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 = 0; p < rmatches->len; p++) { g_autoptr(GPatternSpec) pat = g_pattern_spec_new(rmatches->pdata[p]); g_autofree gchar *rd_lower = 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 = init_vcpu_register(vcpu_index, rd); g_ptr_array_add(registers, reg); @@ -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, NULL)) { - 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); }