From patchwork Tue Feb 6 09:24:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 770361 Delivered-To: patch@linaro.org Received: by 2002:adf:a31e:0:b0:33b:466b:cea8 with SMTP id c30csp195655wrb; Tue, 6 Feb 2024 01:25:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPu7gizY5d6uFc1McH57c/fMfTn+JzLUxpvU22SVTKWnUNJKe1ExNqVLnmrPNym7rq9i5W X-Received: by 2002:a05:620a:4115:b0:785:8c93:af73 with SMTP id j21-20020a05620a411500b007858c93af73mr2001325qko.20.1707211514136; Tue, 06 Feb 2024 01:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707211514; cv=none; d=google.com; s=arc-20160816; b=TpIKKko4LkkP8pGuLScGWD+q6AtKjPY2cdFJ2lYkiRvBBNnXQjO4luCNxHJ38HgP7G Q+X3JeEyormwlqSPVP4rSpVWVqd4jATr6bpkgTdmK/AHHezPXLSBBUIVA76GFl0GzWa2 ACH2Ux7n806uY20VtQIFeHnF0w8lQga3k9heRVJKCjI86rzXrPIhP9Q5LXJDRZOdBWhk iM+1ocw2oJu3/TXEWVtoqq1iChg9jCX7wFnm4HIo8l+bb49Emmr5n3HxN49L8e1zUkfU jdJn6SrBaEm98MtAwK+Dy2ZPghARkdvrCHDJCTd8FxMnEwsEfN2lopjxZM8yOpY+zKHv DvZw== 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=VikB749n6aEnxbtikli/1CKKNBXsXb3S0VGlIjoR0gs=; fh=vDuUjHJTSkt7EtXmBrqxzxpOsMSAo1H6SjdPJ/xzv84=; b=ooTHAEw1cigTzS/PSBXbLBbymyMPMOrrmgDaTFAmSf1qPCl2VoetwIcF77VEcLGQBm zXFn5AyqSVrvoaB6g7bDVfhF3KYPTkKdT4u8us6U6ND8d6mAAo7EF3A4W/hWLtT1LQaN 3Nr7vQiAOWHT2L+U03CfRnZmv517tOQUic/ZqFmIR2GmuFkWfYY7p2DG2XrYXcwHA8HA OpbQZ4f5uDgNu7s+4X1DOMrKsjUlYqXv/125aAmOG1waeOMaYyZDpz3t/3ctg+Be2IWM zo6FxTjchd05fR4xis7uPBgq4WVQJYteDj/MRP/2YF6Yqnq8rCFFmy8Ri3UktfuMVovs 3afw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hCfGneEk; 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 X-Forwarded-Encrypted: i=0; AJvYcCW8i+s58Rm82bBzZpzx1rKAKSiC7oUgOoDruPw6R6lzezhtajHwpOw/1hhcF3668j66fk9aXIqCGT4iYX7wP345 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v20-20020ae9e314000000b00783f21c1280si1844030qkf.507.2024.02.06.01.25.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 01:25:14 -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=hCfGneEk; 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 1rXHh2-0004bZ-QF; Tue, 06 Feb 2024 04:24:40 -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 1rXHh1-0004al-0n for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:39 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHgy-0004kH-FO for qemu-devel@nongnu.org; Tue, 06 Feb 2024 04:24:38 -0500 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-511344235c6so6670342e87.0 for ; Tue, 06 Feb 2024 01:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211474; x=1707816274; 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=VikB749n6aEnxbtikli/1CKKNBXsXb3S0VGlIjoR0gs=; b=hCfGneEkqee0A5Kiie4NPYqkeG/9QfnnaDqAlCkrud2rfYH9zpB15IhrT9n+A/WZG3 VTm4L6pUIZacLUc1IoYLDgvaPmRjUkNX2uO39gbX0i3Qhuki/ndncCxk9tH0cxCan1II jJLQJ9GmL5RE0bOpv0j46W24UaFUVSc85RsssKbayek4KEp/YFGq2lAU/rYTWmOG+ubq 32mTyS5++e9A9Dn4oVFEGGfvgnnEdo9vb7UOpiLDO1lWMWL8ymJudXCxFK6y13GP00Wh iOOyjf6ypb4w1VJk8A5agkWfwM6+JeUIEOe1vtMI5JjorHfanl/1AHXIf7fIeWzzEGHC tvCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211474; x=1707816274; 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=VikB749n6aEnxbtikli/1CKKNBXsXb3S0VGlIjoR0gs=; b=r8f5dTuZPwq6gqVFnJensTWzQvJ7eIFbVsEI5gxN+/3JNdCna1Ti1rrHm6VyCE1Kxo Wr8kkiXLCE8SWgzvpTX6FuzMQgXftmJYv+KoIXafraOuof31MN2rzSilmp6cZBMhmIr0 JhPEplFFf6iz8Me6eXarbP1+oynlaVUnYKPhyK4H8Me6VccmyhcAL+td0z1EnKJrO6nC vlKHHbcJ2ZAVP4YoHVxMFU/mrODPEMKXOdfzgKDTfZhsr8Z+NDaByeEIHKN3jT+HWMZ3 7bi5e8GJfgct6yk3w2uSET30O1QfqBILM/uK76oKhqBuVRAmC1OGuFXV8V6fODqfXxQv lfqg== X-Gm-Message-State: AOJu0YzMhs52BGC9MITGhpYXuXoS4974aa4al3ZpjMAYwzv1YSN0hCik dMz2cx9WW2dApY5ACpiezYTzqUgY+CgHzn8ulkOSACeYHSz6gdEZHyiZi3jX4TtdaHG/idgk2i1 1/ts= X-Received: by 2002:a05:6512:469:b0:511:486d:454a with SMTP id x9-20020a056512046900b00511486d454amr1304159lfd.39.1707211473941; Tue, 06 Feb 2024 01:24:33 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXff+ccV318jIqJRRGx92+IialFY6ycrI+7vfkiJkcCAeHtS0nNd1uyskMoiBt0X71kPYzp1yINxX0b6HDTrkuz5U0+DiVpJIhKK0LL4iy4v6//g35eOjPqSE2HPMI0Y1NdCgWDE0w7N7eWGgy8iuwCuSB3OJ/9YSQUJRmaEg6JvC7jFoROpjPIZevZynchHjaSvVE49W87Xo/lHgtcuaPXWak5FOn+s3hDHWAMKhsOjZWm6ozhdjv/sWP1For8137yymZbOPQLnSgAXB6vtpgrotH+/L96DUc8WuoW+zYU+px2dQyYalzs9b8E9/4yyoIfWJ9Bn7N4hvNENrTe79UzpR4IzQH2wg== Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c211100b0040fc5460109sm1312756wml.35.2024.02.06.01.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:24:33 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Alexandre Iooss , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Mahmoud Mandour , Marcel Apfelbaum , Yanan Wang , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 00/17] TCG Plugin inline operation enhancement Date: Tue, 6 Feb 2024 13:24:05 +0400 Message-ID: <20240206092423.3005995-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::135; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x135.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. v3 -- - introduce qemu_plugin_num_vcpus (how many cpus were initialized) - fix order of plugin init/idle/resume callbacks - scoreboard: - renamed qemu_plugin_u64_t -> qemu_plugin_u64 - some functions rename for scoreboard api - qemu_plugin_u64 has only value based function (vs address before) - various cleanup thanks to review of previous series Based-on: 20240122145610.413836-1-alex.bennee@linaro.org Version number: 3 Branches: base: plugin_registers_v3_20240122145610.413836-1-alex.bennee@linaro.org topic: plugin_inline_per_vcpu To: qemu-devel@nongnu.org Pierrick Bouvier (17): plugins: remove previous n_vcpus functions from API plugins: add qemu_plugin_num_vcpus function plugins: fix order of init/idle/resume callback cpu: call plugin init hook asynchronously plugins: scoreboard API docs/devel: plugins can trigger a tb flush plugins: implement inline operation relative to cpu_index 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: cleanup codepath for previous inline operation MAINTAINERS: Add myself as reviewer for TCG Plugins MAINTAINERS | 1 + docs/devel/multi-thread-tcg.rst | 1 + include/qemu/plugin.h | 6 ++ include/qemu/qemu-plugin.h | 151 ++++++++++++++++++++++++-------- plugins/plugin.h | 24 ++++-- accel/tcg/plugin-gen.c | 65 +++++++++++--- contrib/plugins/cache.c | 2 +- contrib/plugins/hotblocks.c | 50 ++++++----- contrib/plugins/howvec.c | 53 ++++++++---- hw/core/cpu-common.c | 9 +- plugins/api.c | 121 ++++++++++++++++---------- plugins/core.c | 104 +++++++++++++++++++--- tests/plugin/bb.c | 63 ++++++-------- tests/plugin/inline.c | 186 ++++++++++++++++++++++++++++++++++++++++ tests/plugin/insn.c | 106 +++++++++++------------ tests/plugin/mem.c | 40 +++++---- plugins/qemu-plugins.symbols | 16 ++-- tests/plugin/meson.build | 2 +- 18 files changed, 745 insertions(+), 255 deletions(-) Pierrick Bouvier (17): plugins: remove previous n_vcpus functions from API plugins: add qemu_plugin_num_vcpus function plugins: fix order of init/idle/resume callback cpu: call plugin init hook asynchronously plugins: scoreboard API docs/devel: plugins can trigger a tb flush plugins: implement inline operation relative to cpu_index 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: cleanup codepath for previous inline operation MAINTAINERS: Add myself as reviewer for TCG Plugins MAINTAINERS | 1 + docs/devel/multi-thread-tcg.rst | 1 + include/qemu/plugin.h | 6 ++ include/qemu/qemu-plugin.h | 151 ++++++++++++++++++++------ plugins/plugin.h | 24 +++-- accel/tcg/plugin-gen.c | 65 +++++++++-- contrib/plugins/cache.c | 2 +- contrib/plugins/hotblocks.c | 50 +++++---- contrib/plugins/howvec.c | 53 ++++++--- hw/core/cpu-common.c | 9 +- plugins/api.c | 121 +++++++++++++-------- plugins/core.c | 104 ++++++++++++++++-- tests/plugin/bb.c | 63 +++++------ tests/plugin/inline.c | 186 ++++++++++++++++++++++++++++++++ tests/plugin/insn.c | 106 +++++++++--------- tests/plugin/mem.c | 40 ++++--- plugins/qemu-plugins.symbols | 16 ++- tests/plugin/meson.build | 2 +- 18 files changed, 745 insertions(+), 255 deletions(-) create mode 100644 tests/plugin/inline.c