From patchwork Thu Jan 18 03:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 763598 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e5d:0:b0:337:62d3:c6d5 with SMTP id j29csp589460wrz; Wed, 17 Jan 2024 19:24:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRlsoroK2PuAzhiYIML9ExYdSGJdTrOEndLb7lPYqV1KoRNIj9m3HwQ5Ss/lV3wl8HhkpM X-Received: by 2002:a05:620a:4624:b0:781:deb1:44f7 with SMTP id br36-20020a05620a462400b00781deb144f7mr238424qkb.19.1705548271244; Wed, 17 Jan 2024 19:24:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705548271; cv=none; d=google.com; s=arc-20160816; b=f6pUceGTpmcQnCTtMnr1dfhwfSMBr1YD/f4BZ9ur8HnzSjv9psEKYQKTUJDDk6iE9I H6GL1gtmzxdDcsoBruVO2tZSjAhJblFSDZSojo3A4fdWw7YaPKAX2z58HiqXyvFbCdMm 9JvZsUhz1cXr48kD5KYiRk5TPyTwl9aYtwL0SNd2RhEB4oRyv2Z7/KKj61SXJXE3RGk2 iIEn48UYozrk+3CyBle/VZIFDg1+YnDomV/uhmmXCiSTlmXcyhbMuXuyxOsNsbhfRvSJ uKZbufDldyFjocRQrj50QFWweVF95b0HzWKfU0KzAASNKGK50fq58/FEfS1CEetWWwzd knwA== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=YFLIRk8cQqFeaeITkhRPAuwLDSg1W8/L30Om3YahACI=; fh=2e6Nkd059oxyN734d2Q7Nq9y1HEjPsJBCkEwQXCC3ww=; b=gHP5Vfje2DXyBcEEI6r0QXuaH9GiWKf2PjPvi+fqfAV/Bv1OGk40iXvRTTtPFAvtsw qIbwX7qAdum7lAy9vIL8kLNEfOjnpxQFCjxifp9z44Y0lxkqewZX7YYAfD05OYe1LF1O lOImQONCC3pr6lTC0xVoOZrZaa+VeKrJbUgZiev1cZEF0soykh3csPXow7qZL7GGlPta IhgkRHYDbEvnuCGLjN/wCAayDMPRaq2yDa76WpIsmgJW7RHzzfMnG8y/dkqL2JAkplbv gBnzvSVNHvLM9NBXwYvMG0FqwCeI2rsErHtij4A2GKyWl0oBf8d3620kus0N/R4iRHDX qUrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dq3a2AXk; 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 u15-20020a05620a084f00b007835c8089adsi7006125qku.248.2024.01.17.19.24.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2024 19:24:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dq3a2AXk; 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 1rQJ0v-0003WW-Eo; Wed, 17 Jan 2024 22:24:21 -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 1rQJ0t-0003WN-To for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:19 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQJ0r-0002Lb-Ar for qemu-devel@nongnu.org; Wed, 17 Jan 2024 22:24:18 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-337c5bcf79fso1015311f8f.2 for ; Wed, 17 Jan 2024 19:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705548254; x=1706153054; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YFLIRk8cQqFeaeITkhRPAuwLDSg1W8/L30Om3YahACI=; b=Dq3a2AXkeyG4KGL1mZAo+aq+p4AW/mB4H6uClneO7Z80JXrcVoywZq8Ds2U0dHqVZH 5oPuX9oZnH1XRiUUIIxE2irbVfD6RTZM91pqSppWQ7ek3nme7x24vSHrtL/x91maLu53 26eM8S3Dx/Z9/MYK/Cb0ua6fRs9Zr7VrtSW9i4HoOPFnK1wJEVw49AIebwti6OHwNwM3 KSy/FO8FxDdlpQ8STzfPuQa4UXgJdC6lTJn3roqcF1wGtjVzmU4+P8rSIq3dKHcDAlya nauYOBpadcylnnP0zdtQ5QzlahPf4oaPtrz6Y87PsuxysP/WwJ+5Pma9f8Xg6GEhip+L LXsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548254; x=1706153054; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YFLIRk8cQqFeaeITkhRPAuwLDSg1W8/L30Om3YahACI=; b=t3ANCsGoV8MdNIBnoXzGpjiomqyNN8MpsEfOsV/jZ+XdCh1kR1hUHpO+XjhmCGBIIX yZjDkMTo+TnlCHx1+bH26nUSufeceIjjbW7aS0l+bv5Re9uvPvIZKw71CLo4B6v1M98K Gt1hPHU9LvM4ttUt1x72kxIfkCplYOhIEseAh3I4CpXMcDknL169sfNKjtntahbEv5gd G2KsIF+3X/uVtDWRvvFILNQX9K55ft/KKlbI+o2FlOwSw4JE03TzxQ8umEbBKWM+cTb7 3pyNbEaMPdfk8Aw06jh51QjkEpulXwix51zs2gB52rwqZc6n2JISD9HF7L9/HRinAoqZ JSOw== X-Gm-Message-State: AOJu0YzWEjJtnUp1hJfzK3mi0MQ/vx8CW4l4lqWV/pNrH3keXntwDvVb ZBPg9PudZCJBiuWldNsxxuy85SXZOxS7DROcMHV8Z60//A0upRCeEAnpDU8cH0nk25yXw7AT/1d 5Jw8= X-Received: by 2002:adf:f14b:0:b0:337:bc4c:48a3 with SMTP id y11-20020adff14b000000b00337bc4c48a3mr99402wro.95.1705548254435; Wed, 17 Jan 2024 19:24:14 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b0033788e357e1sm2894292wro.108.2024.01.17.19.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:24:14 -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 00/14] TCG Plugin inline operation enhancement Date: Thu, 18 Jan 2024 07:23:45 +0400 Message-ID: <20240118032400.3762658-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x429.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 This series adds a new thread-safe API to declare inline operation inside plugins. As well, it removes the existing non thread-safe API, and migrates all existing plugins to use it. Tested on Linux (user, system) for i386, x86_64 and aarch64. To give some context, this a long term series of work around plugins, with the goal to be able to do basic operations in a more performant and accurate way. This will mean to add more inline operations and conditional callbacks. One final target of this work is to implement a plugin that implements the icount=auto feature, and allow QEMU to run at a given "frequency" based on number of instructions executed, without QEMU needing to keep track of this. Another final target is to be able to detect control flow changes in an efficient and elegant way, by combining inline operation and conditional callbacks. v2 --- Implement scoreboard API (cpu local storage), so plugins don't have to deal with how many cpus are used. Since plugins have been modified again, I didn't transfer any reviewed-by on those commits. Branches: base: upstream/staging topic: plugin_inline_per_vcpu Pierrick Bouvier (15): [TO_REMOVE] commit support plugins: implement inline operation relative to cpu_index plugins: scoreboard API docs/devel: plugins can trigger a tb flush plugins: add inline operation per vcpu tests/plugin: add test plugin for inline operations tests/plugin/mem: migrate to new per_vcpu API tests/plugin/insn: migrate to new per_vcpu API tests/plugin/bb: migrate to new per_vcpu API contrib/plugins/hotblocks: migrate to new per_vcpu API contrib/plugins/howvec: migrate to new per_vcpu API plugins: remove non per_vcpu inline operation from API plugins: register inline op with a qemu_plugin_u64_t MAINTAINERS: Add myself as reviewer for TCG Plugins contrib/plugins/execlog: fix new warnings .gitignore | 1 + Dockerfile | 23 +++++ MAINTAINERS | 1 + accel/tcg/plugin-gen.c | 64 +++++++++++--- build.sh | 18 ++++ contrib/plugins/execlog.c | 6 +- contrib/plugins/hotblocks.c | 46 +++++----- contrib/plugins/howvec.c | 50 +++++++---- docs/devel/multi-thread-tcg.rst | 1 + include/qemu/plugin.h | 9 ++ include/qemu/qemu-plugin.h | 135 ++++++++++++++++++++++------- mt.cpp | 44 ++++++++++ plugins/api.c | 74 ++++++++++++---- plugins/core.c | 112 +++++++++++++++++++++++-- plugins/plugin.h | 13 ++- plugins/qemu-plugins.symbols | 9 ++ run.sh | 22 +++++ test.sh | 34 ++++++++ tests/plugin/bb.c | 63 ++++++-------- tests/plugin/inline.c | 182 ++++++++++++++++++++++++++++++++++++++++ tests/plugin/insn.c | 106 +++++++++++------------ tests/plugin/mem.c | 39 +++++---- tests/plugin/meson.build | 2 +- 23 files changed, 846 insertions(+), 208 deletions(-) Pierrick Bouvier (14): plugins: implement inline operation relative to cpu_index plugins: scoreboard API docs/devel: plugins can trigger a tb flush plugins: add inline operation per vcpu tests/plugin: add test plugin for inline operations tests/plugin/mem: migrate to new per_vcpu API tests/plugin/insn: migrate to new per_vcpu API tests/plugin/bb: migrate to new per_vcpu API contrib/plugins/hotblocks: migrate to new per_vcpu API contrib/plugins/howvec: migrate to new per_vcpu API plugins: remove non per_vcpu inline operation from API plugins: register inline op with a qemu_plugin_u64_t MAINTAINERS: Add myself as reviewer for TCG Plugins contrib/plugins/execlog: fix new warnings MAINTAINERS | 1 + accel/tcg/plugin-gen.c | 64 +++++++++-- contrib/plugins/execlog.c | 6 +- contrib/plugins/hotblocks.c | 46 ++++---- contrib/plugins/howvec.c | 50 ++++++--- docs/devel/multi-thread-tcg.rst | 1 + include/qemu/plugin.h | 9 ++ include/qemu/qemu-plugin.h | 135 ++++++++++++++++++----- plugins/api.c | 74 ++++++++++--- plugins/core.c | 112 +++++++++++++++++++- plugins/plugin.h | 13 ++- plugins/qemu-plugins.symbols | 9 ++ tests/plugin/bb.c | 63 +++++------ tests/plugin/inline.c | 182 ++++++++++++++++++++++++++++++++ tests/plugin/insn.c | 106 +++++++++---------- tests/plugin/mem.c | 39 ++++--- tests/plugin/meson.build | 2 +- 17 files changed, 704 insertions(+), 208 deletions(-) create mode 100644 tests/plugin/inline.c