From patchwork Tue Mar 12 07:54:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 779681 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1898351wrt; Tue, 12 Mar 2024 00:56:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCiDaTNEo38Vv6OGYfzROnghmxB8cb9r6baMdJOR/APgs6gLnBoYmmhf5eADbAUBoBq4AdVHOgk38jzPzVrROm X-Google-Smtp-Source: AGHT+IE3L8EXQjbVyKlrgQB6+XdDr+LR2oGQoVnzdIIRELTTx6wWn9UWnvQVhq/6qIrDooyq3HpF X-Received: by 2002:ad4:4526:0:b0:690:d609:d2ff with SMTP id l6-20020ad44526000000b00690d609d2ffmr5131390qvu.41.1710230193256; Tue, 12 Mar 2024 00:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710230193; cv=none; d=google.com; s=arc-20160816; b=w9K33d9YbSxzWUxmbZN82wf7OYtaXCfxWeqK/XGvEEfjXL+y7IQHWhvBjU6XqYyxDH B3IplOQ/7ldi/6qU578hFGPtb2AxqT1spLt9/Km8ScPTTHeK5jFegSb3dZVuAoYtKw8j 0jRo2pL4SedU+UUyfHEVTicypKYl4X5yK3LE11ZU08M+S1PdO5lA7UrH4GzTrHeM+fJB t+xzYr3jzHFK6UNoQKX1tbcoHvZGgo03jocmJzFxWc3PT9rmZ0SZZc9dYUNAmeIkQ3fY bKoauF04UZfC7LUkiGcxiWtxD6y+v0D0p5b3Q1YLRNgIXG6/I0KA/an7WQQ+/sJRm8d8 AU9g== 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=GdadDDsYSdx5C71pz10Y8GnqMQs9L+4uC1BJhhVgUB0=; fh=V4SgTU7V4nf8OtmvRvW259BlAHhRyVi2BkDbVAQpFgg=; b=h9aBayO+oSNi/BKc1Ghk+8RqFtFTHufnJiSpk5Mb+fJdEFVx0QSCbQjBzGJ+RHyzf2 kXWmBH5tGm2eAuRWXoWc7RJm3MazsRxRW+Vogk5IgKnrHCBe6r9EVlyDx9N/aDMmvsZJ 97rhh29qISRB6zfyCS/mhVmXsgAN+LLvjpvgiqHFO5hSKn4iqkGz+Si5laB36GL1+E2u SuaA+Atl9gHqDDVGHsoQYiYKSuQNcus59hCS5BxbGcoEo1eGo5TrED/D2qz88qlTysAr z127TwLJ1x8Vgnt9RPce7KTAi1i3WQ5j/7f4doetVHwH4rQpF8v+r5FvL8OAfuPJf6zJ 1Y6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j9JYnajv; 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 u10-20020a0562141c0a00b00690b84b755fsi6939745qvc.469.2024.03.12.00.56.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 00:56:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j9JYnajv; 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 1rjwyl-0002JW-60; Tue, 12 Mar 2024 03:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjwyj-0002Il-LL for qemu-devel@nongnu.org; Tue, 12 Mar 2024 03:55:17 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rjwyU-0003d6-A1 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 03:55:17 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33e959d8bc0so1761578f8f.1 for ; Tue, 12 Mar 2024 00:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710230099; x=1710834899; 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=GdadDDsYSdx5C71pz10Y8GnqMQs9L+4uC1BJhhVgUB0=; b=j9JYnajv9GY6Fe7q0eD2sxXKqqgMIViKaUtOToWpcAn1n2Klpq1V2YJ1EhUPksEJDi /iMlHXAEFLTctFxQzgaad/aoGrlaFM55LXsEtCWPmizLsXKhv/L3309jhh1of5mpjNOs L1xiC0ZayY593dfbOSGd83nBWxmMNARG8HBwq422Q4/o6+kf/Iq9OjWvvveXbI7PdJ1/ U7PWbbYTPclyVjgQZp6uBzTuYtqQ2kTRuzWY658+0s94zeySdkfO7u8Iy0EezZfJM/X2 jXTa6GpfN+I6fqMozTEHxl1UVOTwx56gDHT1FIQ30ruIDibNT0FPxR5EHqRfXYUvRRIb lboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710230099; x=1710834899; 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=GdadDDsYSdx5C71pz10Y8GnqMQs9L+4uC1BJhhVgUB0=; b=KGndMJQNrwSBCGMbq73/DWCp9UB/flgh7V6/QmY5ueUbqVSK0YtDMgXlbTcsv01SrO 1muWs5wRrfft4Hkxq0dUgdqphW+cmj1pcplaW16EymanSWH+JoBin1iUn/jUvOrV7CFu Izdu2qHdkwXkd5QTP8J+CoJwEp3CPI6AKPcNFnZgkAwXvkRc2iSK1zUOVN5n8I1mhiwO 7Htssvv7GOF7MK2u5+iIgvkCxMTAYVUosQAhpql9A40Bb16AHlCBZoHIa7LOfAv+/yrU fTdOVUz7HmBuLbucJzrfkw/OCFl5paNeo4l4E+9kQc8J4em1P9pTHOUnrgHXAINnkgBk 04HQ== X-Gm-Message-State: AOJu0YwakgugnSDdRosGZ+AnJQ0FjhChuTRbN21xMY90kzx1Xa/KIaDK 1PlStSO9xBEO67soD3Ks0fFekMo0riUenFE6VXdKYReLPCD8bAgze3WM7pJaCLCq3GwN5Z0ZTLp tdhM= X-Received: by 2002:a5d:5222:0:b0:33e:67b1:f7c8 with SMTP id i2-20020a5d5222000000b0033e67b1f7c8mr5313278wra.37.1710230098978; Tue, 12 Mar 2024 00:54:58 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u12-20020a5d6acc000000b0033e7a499deasm6108795wrw.109.2024.03.12.00.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 00:54:58 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Alexandre Iooss , Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Subject: [PATCH v2 3/5] tests/plugin/inline: add test for STORE_U64 inline op Date: Tue, 12 Mar 2024 11:54:26 +0400 Message-Id: <20240312075428.244210-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312075428.244210-1-pierrick.bouvier@linaro.org> References: <20240312075428.244210-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x42b.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 0163e9b51c5..30acc7a1838 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -22,6 +22,12 @@ typedef struct { uint64_t count_mem_inline; } CPUCount; +typedef struct { + uint64_t data_insn; + uint64_t data_tb; + uint64_t data_mem; +} CPUData; + static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 count_tb; static qemu_plugin_u64 count_tb_inline; @@ -29,6 +35,10 @@ static qemu_plugin_u64 count_insn; static qemu_plugin_u64 count_insn_inline; static qemu_plugin_u64 count_mem; static qemu_plugin_u64 count_mem_inline; +static struct qemu_plugin_scoreboard *data; +static qemu_plugin_u64 data_insn; +static qemu_plugin_u64 data_tb; +static qemu_plugin_u64 data_mem; static uint64_t global_count_tb; static uint64_t global_count_insn; @@ -109,11 +119,13 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata) stats_mem(); qemu_plugin_scoreboard_free(counts); + qemu_plugin_scoreboard_free(data); } static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_tb, cpu_index) == (uintptr_t) udata); g_mutex_lock(&tb_lock); max_cpu_index = MAX(max_cpu_index, cpu_index); global_count_tb++; @@ -123,6 +135,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata) static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_insn, cpu_index) == (uintptr_t) udata); g_mutex_lock(&insn_lock); global_count_insn++; g_mutex_unlock(&insn_lock); @@ -131,9 +144,10 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) static void vcpu_mem_access(unsigned int cpu_index, qemu_plugin_meminfo_t info, uint64_t vaddr, - void *userdata) + void *udata) { qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_mem, cpu_index) == (uintptr_t) udata); g_mutex_lock(&mem_lock); global_count_mem++; g_mutex_unlock(&mem_lock); @@ -141,20 +155,34 @@ static void vcpu_mem_access(unsigned int cpu_index, static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { + void *tb_store = tb; qemu_plugin_register_vcpu_tb_exec_cb( - tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, tb_store); qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_STORE_U64, data_tb, (uintptr_t) tb_store); for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + void *insn_store = insn; + void *mem_store = (char *)insn_store + 0xff; + qemu_plugin_register_vcpu_insn_exec_cb( - insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, insn_store); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_STORE_U64, data_insn, + (uintptr_t) insn_store); 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_MEM_RW, mem_store); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_STORE_U64, + data_mem, (uintptr_t) mem_store); qemu_plugin_register_vcpu_mem_inline_per_vcpu( insn, QEMU_PLUGIN_MEM_RW, QEMU_PLUGIN_INLINE_ADD_U64, @@ -179,6 +207,11 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, counts, CPUCount, count_insn_inline); count_mem_inline = qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, count_mem_inline); + data = qemu_plugin_scoreboard_new(sizeof(CPUData)); + data_insn = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_insn); + data_tb = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_tb); + data_mem = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_mem); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);