From patchwork Wed Mar 13 10:54: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: 780025 Delivered-To: patch@linaro.org Received: by 2002:adf:f741:0:b0:33e:7753:30bd with SMTP id z1csp112507wrp; Wed, 13 Mar 2024 03:56:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUthLf0h49YyZayXCcr519j0c10kpd4XsHB6X9SalvJg8biStACN1E11M+3V9JKCPRpxHGI2oIZd/Jcn3FC4Bzd X-Google-Smtp-Source: AGHT+IFUY8rMPjBLMZQoPLwDBpwtAsrvXOImV5DdfyJ2kvcUT1RMEkXq7G/WIj31NXVPrBnZ6iJ1 X-Received: by 2002:a05:620a:a11:b0:787:ec39:8210 with SMTP id i17-20020a05620a0a1100b00787ec398210mr10748124qka.52.1710327363047; Wed, 13 Mar 2024 03:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710327363; cv=none; d=google.com; s=arc-20160816; b=T03LZHNYPYycXM/+MoapkST04FOI9PlUvfLYOZSpXqAj1UGnI2m4K1Yiwl70fAQcgU 6TG9lAKtoaVwNwMXrjxsu9e3GGYVQSEioE/+/1J60gWeE5o6aiTComJoU7OXPPc85BJ9 30JnVzHXuTMDRv0d6kyfyhwmlLEHFckPu4DHgLROD+sqSDjHlmgAfbG6GupvZPMxPt1U hLT3166RxHG/UfSEPTZfTi97rJ0TDHBoiB2/YLadrQZH0mj+rUIvqKEP6pbZttVlhE/R yWvRO1aJcOsQAbuyYTPATNn0uA0vq9ov2YWjirQ0qZc3GyA2E3Z9JGbcu28AofWSsBbB vpeQ== 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=aeLIdO/x6mKNNGtYvUzEtvZN9YuH6++NOLOCo22Tmu8=; fh=SOx5jGRISimNYto+GAJnnbqozdA4y+bYXtSuueN6vdQ=; b=kBndpJ5a37iol5y8ABeRonIFMRFTJOvogYKLtFsADhBhea/JluTTGaQBVyQ7Tp+S6X x3VoSlEPwyxSKVAkcij7TicgxjQXS+FkobkxcFoxvGxrEPPzIefBEDbwv0+pWALX1sGw Rcrxl9SvIu8nnnVGNzX8HTqY+0Cw1vDKvquu3ZxjKTc3k2iKpCbbURKdqhVSvqFKvxja ycjoPEbvwsLRgokrRlvSTLXOGTgNEe3UBX223OlT9Ttj/LPRXUv6BZ3NmBez3+md6SB0 C6fhyg4avnADw7HLzkKJnc6Wi6+WwYFCwiBrutC36ohLGCQORYRCNMrDLsxDiwKeXUUR 0vsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hetS5v8i; 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 s23-20020ae9f717000000b007885c47dcddsi9230263qkg.24.2024.03.13.03.56.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Mar 2024 03:56:03 -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=hetS5v8i; 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 1rkMGg-0005Ao-TE; Wed, 13 Mar 2024 06:55:31 -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 1rkMGY-00058G-Ty for qemu-devel@nongnu.org; Wed, 13 Mar 2024 06:55:23 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkMGX-00078l-2C for qemu-devel@nongnu.org; Wed, 13 Mar 2024 06:55:22 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-513af1a29b1so3056430e87.1 for ; Wed, 13 Mar 2024 03:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710327318; x=1710932118; 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=aeLIdO/x6mKNNGtYvUzEtvZN9YuH6++NOLOCo22Tmu8=; b=hetS5v8iHVuclAy+B29FMxDLoIzDG6fsbVHGRZu5D+/BDDHE+VlwTTyx1cVXilEw9K 8uIRRSM/vY0KJLUpqmcjiwGkWZrchhKpZCVoMBeDEQBcn/3delaPbWTf2OBOiNZ+38GA CIOydDKi/cCfsgI3lVGmBK1rr0iFafiSZCNgdtp7D/duvMTjRIrapfw7UFVBopVn9DLQ 4rZyyJ3nx0JbqvZ68YdMJ4Y/laKZW40UxHD0OVuTptbkMtWAY6zajjxtU8YRuzSeWf6N GL4f00LbF8VHp5acp7rQXF8W5mLs8VT9NXNAiUfNXzWLTJ02DVvBN7+P4wq8n6vvEWFU JP0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710327318; x=1710932118; 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=aeLIdO/x6mKNNGtYvUzEtvZN9YuH6++NOLOCo22Tmu8=; b=efFhVfJgkmHGPld/9NGUciN+PfATADRPzAOzBdgpJiaeg35CIFSa+vucIbmiL06dCb s6cgRSbDn4+89KG3c9wtQpqAzIMu6hXR4ZbcXfcpte8/lFlvhROLsEHx3Rv2gkhXz5XV hCYBPPHJ+Gs18DSxq2EYNeI1aP9kpTBuaXJuS0FtSzZPuc6GJqr0V0be6NOOWwFhTi7S D+VxpV0W6zpCDxhz1Cb44A83D+gqcg4uLJ2IdS42MUC72NedUOqFiRkLf2Akc7oUywMa RtZ/fbpOxwczA7djVYbiq2vytRHuhLNcTe9K4aPNqxl8oNZRayHbZagQ4nRvs/7a0LXY LB1w== X-Gm-Message-State: AOJu0YxkAELZZM5ZEiVlR7b2u+jJabM6BRPkyGZN94l/fKoic1YfV1Fq 87cpDQvtMZxUmvON8XlNIit6mLTa2ffijnSbpahb+1qw/xttkPhb4VUy2g0ntkClCwmO+DVUUFv ZLBU= X-Received: by 2002:a05:6512:1052:b0:512:f317:f5c0 with SMTP id c18-20020a056512105200b00512f317f5c0mr10054000lfb.42.1710327317757; Wed, 13 Mar 2024 03:55:17 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id w17-20020adfee51000000b0033e1be7f3d8sm11390338wro.70.2024.03.13.03.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 03:55:17 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Alexandre Iooss , Richard Henderson , Laurent Vivier , Thomas Huth , Pierrick Bouvier , Mahmoud Mandour , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RFC PATCH 0/5] Implement icount=auto using TCG Plugins Date: Wed, 13 Mar 2024 14:54:59 +0400 Message-Id: <20240313105504.341875-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x12b.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 The goal here is to be able to scale temporally execution of qemu-user/system, using a given number of instructions per second. We define a virtual clock, that can be late or in advance compared to real time. When we are in advance, we slow execution (by sleeping) until catching real time. Finally, we should be able to cleanup icount=auto mode completely, and keep icount usage for determistic purposes only. It is built upon new TCG Plugins inline ops (store + conditional callbacks): 20240312075428.244210-1-pierrick.bouvier@linaro.org Example in user-mode: - Retrieve number of instructions to execute /bin/true $ ./build/qemu-x86_64 -plugin ./build/tests/plugin/libinsn.so -d plugin /bin/true cpu 0 insns: 120546 total insns: 120546 - Slow execution to match 5 seconds $ time ./build/qemu-x86_64 -plugin ./build/contrib/plugins/libips,ips=$((120546/5)) /bin/true real 0m4.985s Alex Bennée (4): sysemu: add set_virtual_time to accel ops qtest: use cpu interface in qtest_clock_warp sysemu: generalise qtest_warp_clock as qemu_clock_advance_virtual_time plugins: add time control API Pierrick Bouvier (1): contrib/plugins: add ips plugin example for cost modelling include/qemu/qemu-plugin.h | 23 ++ include/qemu/timer.h | 15 ++ include/sysemu/accel-ops.h | 18 +- include/sysemu/cpu-timers.h | 3 +- include/sysemu/qtest.h | 1 + accel/qtest/qtest.c | 1 + contrib/plugins/ips.c | 239 ++++++++++++++++++ plugins/api.c | 31 +++ ...t-virtual-clock.c => cpus-virtual-clock.c} | 5 + system/cpus.c | 11 + system/qtest.c | 27 +- util/qemu-timer.c | 26 ++ contrib/plugins/Makefile | 1 + plugins/qemu-plugins.symbols | 2 + stubs/meson.build | 2 +- 15 files changed, 379 insertions(+), 26 deletions(-) create mode 100644 contrib/plugins/ips.c rename stubs/{cpus-get-virtual-clock.c => cpus-virtual-clock.c} (68%)