From patchwork Mon Apr 28 12:59:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 885475 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp5165015wrs; Mon, 28 Apr 2025 06:01:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUWlOROShd9b8XfpF/EAriVJipKTDA+q6MEt0QWVR7xyLKGwlcxbiAQnfLQMzwP9YXp0TLgVQ==@linaro.org X-Google-Smtp-Source: AGHT+IFnKp1vO6NulLfn6G7MmJxn7Jvq3gmApZTXwLiT0qrsyKOFyYTnLsS4PX7d33msW8VnfekR X-Received: by 2002:a05:620a:390c:b0:7c5:79c6:645d with SMTP id af79cd13be357-7c9606ac6e6mr1664074285a.11.1745845317037; Mon, 28 Apr 2025 06:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745845317; cv=none; d=google.com; s=arc-20240605; b=Y6QWuTu52MFsiHZrWzDZnGQ+WlI6UF0SkylwQMUemcb3UiMWdTZphKZ/ecHbC2LT+u mw+ZDDzD8DG7F6FS7R8Qi6QV4wMUsRtKwzk2xMoMsDyWrn9BrnuYEh9A5rZBr68W75LN XN2YmzhPol15ghe2x2L+mQoUa6+J4cojQyrRWmA9JPl84Bl8ddiPsM8eIYRQR8Kvm9K1 09zQrDemtgO44MVSS0taWZMWlBZfxekNiqTmoad09yg9JpmPp8RX7APekeCJhrO2XP69 Xd5jpLJhVpbN6h23hEY86mdK95rYndyoiRqFbv85gkx8b+VGOkYNnZf4KpR10agiGPQ5 7wPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=djoQOHWyk0AtirIrodM8UGPqfENNxGNaKjJ0HgISDiU=; fh=CRxZ/er3+VXA5mJQYxYBLkuBdEcLSBKdQEqlxuayHY4=; b=gDg9A2r3p+KdBoz0j6ujWc47A9i5slem3yTQkcgbIA5VYo5kCPYnJN/959WX4Yqz2y THNIXf7oiU9cpHgBLSZz4DHSZQWac42cAli/tEmoTKf0ORkf1NLFanl/+qHv2TasTDyS opimWGFF3/e/g0hnUmPC4CAOt1q7Jm1DGnwGr2LENY0E010TeQuesdBdDE+yEegSszC3 rIN1FzDdx5suztA1IJKLlaSz/RnkU0YXgWw5uRGVjNyAeTB041XhVqLGHtFTLbHMLQwf A2VG74KC3GjHyPRVkKIonRPYH7oHkyLf5M5iZyX0QhhCNjfWJc4UIBWkH3AZ5yvClIY/ G4AA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ir1c84ex; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c958ee1ae7si986991485a.640.2025.04.28.06.01.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Apr 2025 06:01:57 -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=Ir1c84ex; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9O5H-0008Ag-Tz; Mon, 28 Apr 2025 08:59:44 -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 1u9O54-0007uP-V3 for qemu-devel@nongnu.org; Mon, 28 Apr 2025 08:59:31 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u9O50-00037W-1T for qemu-devel@nongnu.org; Mon, 28 Apr 2025 08:59:29 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ac6e8cf9132so920334966b.2 for ; Mon, 28 Apr 2025 05:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745845164; x=1746449964; 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=djoQOHWyk0AtirIrodM8UGPqfENNxGNaKjJ0HgISDiU=; b=Ir1c84exYpMhLrW/0q8LgRysAfnCZ3aHUINXrsTQf6kEqHsriqufU7UzZcuZVm7+Mt uF2PWdVyCGcsEBBnluTbDdjYAzxrT2s4ZMBos4YhOstNuijw8WL0syTgnmbE0tizU9H+ Ym0sCuqneUPAcaFOoFLO/CboAQFtrQpjeetbOkozDkwtPSSCvK7DZadgYHSLNGfpbz49 PYhnH6txI0F6bLR6+GE2iIAuq67D0bZSHStQreRMiNmDr/s1BcGtDiHjtIs7Zg13YBI1 3anDf0bNtIR5KaxxoKlPs5gXzlJ1u1HM/MjSr1+uk/kHXdptm4Oo2c0J7QOptVTeO5K0 e9Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745845164; x=1746449964; 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=djoQOHWyk0AtirIrodM8UGPqfENNxGNaKjJ0HgISDiU=; b=B3hAl396CBy+2+7cIAKYupD3dZNLnd3WLnMBesh9JSeQlUBdd3AYXw8nJLcPvOxEOo DThgxQzs8PnmPaXQ3yRTRFl4H41h3qMdF4cfQxAAiF9fRquV7qLW7S6fQQATeI2Pip71 8mHKO/fkWKl+IXKygDxkEcaJJaHz6mTEyXtOqcJTriwhlcWLgqyCbjnSRuE5XVwHtTcy dbs83BATXgg/Vn2a3Dd6Hrd9JZGisrDzU0e5IfkQGDyM0jLm4IpnQLr8FY5aJsxAzUX5 CUMRw2ITksuk67APDx1gbWYrAezKVaIbBw923CFWFGPON6zQB5QqDAMrOfVdf3VZ7XR5 ThDw== X-Gm-Message-State: AOJu0Yx9xHRf2C3aTgLI+fWCdCffFoPh8MKJXa2wf54ozf1s39T/swQg LNMWycVBKFdA7QMkaLoo3ine1yE0oc7PAWVXp3vbqTrNCv97WbseFXO4+sMtmEc= X-Gm-Gg: ASbGncvjeisPQZbfSBP1pVwXfdZPrg/RIiVNGcGc5pAjL6ceTAhMRR+rB8fBzTXDFku Bb30J1MB23cEMbziMbd1S64sc5wYGAVo9aZrSCKkz8vcWGHcuVX+7ozg+nAD+srBQmz+bTNEB88 89Qlu3vw6b3aWrUk0U4fJjVWYhpcSN4yHk8D5+7FaWI8SK7iMqWzkwyIFIfUP6yGLYB79A8mdIh jANFuBRqONu0lBnGx3RbYm6/99vXCCD13fwAaFG9+ZDBD1ZCWbUCykHHFCGSbSFo37mmEkHKPHv xpZm5Cvh7r1XgOq3q2nEPzTGE39pDYET4ZH2Ar1p7WU= X-Received: by 2002:a17:907:3f9b:b0:ace:672d:c7c9 with SMTP id a640c23a62f3a-ace73a6bed7mr1109878466b.26.1745845164287; Mon, 28 Apr 2025 05:59:24 -0700 (PDT) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ace6e4e70bbsm632156866b.63.2025.04.28.05.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 05:59:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B1C2C5FAED; Mon, 28 Apr 2025 13:59:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Alexandre Iooss , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , David Hildenbrand , Pierrick Bouvier , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , Peter Maydell , Mahmoud Mandour Subject: [PATCH 5/9] contrib/plugins: allow setting of instructions per quantum Date: Mon, 28 Apr 2025 13:59:14 +0100 Message-Id: <20250428125918.449346-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428125918.449346-1-alex.bennee@linaro.org> References: <20250428125918.449346-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 default is we update time every 1/10th of a second or so. However for some cases we might want to update time more frequently. Allow this to be set via the command line through the ipq argument. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- docs/about/emulation.rst | 4 ++++ contrib/plugins/ips.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index a72591ee4d..b607183d13 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -811,6 +811,10 @@ This plugin can limit the number of Instructions Per Second that are executed:: * - ips=N - Maximum number of instructions per cpu that can be executed in one second. The plugin will sleep when the given number of instructions is reached. + * - ipq=N + - Instructions per quantum. How many instructions before we re-calculate time. + The lower the number the more accurate time will be, but the less efficient the plugin. + Defaults to ips/10 Other emulation features ------------------------ diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c index 1952e0866d..d83124d71c 100644 --- a/contrib/plugins/ips.c +++ b/contrib/plugins/ips.c @@ -147,6 +147,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { + bool ipq_set = false; + for (int i = 0; i < argc; i++) { char *opt = argv[i]; g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); @@ -164,6 +166,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, break; } } + } else if (g_strcmp0(tokens[0], "ipq") == 0) { + max_insn_per_quantum = g_ascii_strtoull(tokens[1], NULL, 10); + ipq_set = true; } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; @@ -171,7 +176,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime)); - max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC; + + if (!ipq_set) { + max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC; + } if (max_insn_per_quantum == 0) { fprintf(stderr, "minimum of %d instructions per second needed\n",