From patchwork Wed May 21 16:42:38 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: 891528 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp2220481wrm; Wed, 21 May 2025 09:44:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNcyysSi3S5SBb0AwISwMzS9s8aRKpwLIW3fqHn28PqN/Bqz25wBWpQFlr9FEAJ2NHlpQWOQ==@linaro.org X-Google-Smtp-Source: AGHT+IF5inp5HZK6YbYj72Fb2ONvtUAb4dPckqPYG132Ygvl0M+FQfbEe88+LJH+wed7InQHHDzy X-Received: by 2002:a05:6e02:5e07:b0:3dc:757b:3fab with SMTP id e9e14a558f8ab-3dc757b4338mr75907505ab.6.1747845892090; Wed, 21 May 2025 09:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747845892; cv=none; d=google.com; s=arc-20240605; b=F9OZCjCpXexE0DGrabXk0PNE8+CVEl+CTs0GmYxU3WZeEdpYRik9uQK4phuMhl/UIN Azzb3h2QMssWWXSXwl3LOKLdd6BJFf2/qWhLBwuoK9wHw0RHtTkAjuVPss7eGFyDNan4 fVn4mmuwSOhHL1tmuu4MVK6J8wm2nykSElJTMsM2feIheKqB6qjf6xlENgaZU5FatOpG cpOOmqYnPMN29aEiQqegoZZALzGeNIlNp09TfYL1sG9g5/RnNe3DgcmrsCEIfMd/hVUL H/hZax7DmIAi8H2r4m4i/NMfvJz0nYUQc5wocsGps3I77kqAGNIsFq5ryylhs9qv1u0D N8ag== 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=VmQzX3BIbzz94t4XQwCRdZczcmOoQ3nURihzXuER/EE=; fh=bRO1MF9VSOWVIGjbYXUTHO3COe2aRRAcNw1LSvnzoWs=; b=cDtzkvW9xGNpYQoOus++jM0xIkXM4dLSXhaJbg7j+1pIBfUwYkMT7dSyFGjT1clZKo QbhzqrhAMUeaeQfM480TMyxZzBOQPZ2RMuhMMLlJNbeDdGwpoxquAUlclnzG5luO6pCP XTTa4r/97nnxFxDXiAUJzR4Dntsls4oWXpzzXC64HneyZvwezgGkmn1q+RitbjRUlCE4 zLEk7ArkEwbkghPfOMaIDmtV1EqnlX4KgQBXFUmHBcFd0AuhjDNOuPtjn65KvNPaozGM jYCnpbOl2niyu16PCJl+hUatkh84S1zZnoAmqwASja8VfvvlSo2/US9YqTFLAZX4yPqd GwDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tp6oX/IF"; 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 e9e14a558f8ab-3dc83ae25c8si21505425ab.102.2025.05.21.09.44.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 May 2025 09:44:52 -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="tp6oX/IF"; 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 1uHmX6-0000Ty-LZ; Wed, 21 May 2025 12:43:08 -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 1uHmX0-0000Q8-PF for qemu-devel@nongnu.org; Wed, 21 May 2025 12:43:02 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uHmWx-00069P-M2 for qemu-devel@nongnu.org; Wed, 21 May 2025 12:43:02 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-601968db16bso3399537a12.3 for ; Wed, 21 May 2025 09:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1747845777; x=1748450577; 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=VmQzX3BIbzz94t4XQwCRdZczcmOoQ3nURihzXuER/EE=; b=tp6oX/IF50czhCVvMvomGZBReVdcfK9rD5PXconXD3aKYX7x9XQqM6DavESJxZLSYx NtMxoGNpEcZdPWSwVhvNOrlsjB6qUq5HZ6qNUzr0TIW2IjGxn98biTSIeJ7ClAWxMJcR GoAJieCEcp5zcQZwBvInisTxsnvUBRyXlBH5BcYy2MqNMweFygj8kTAHrXXX4Z8rf+1M kFRnUgBm9EaypiQq6wjLju/Gx0DWgi3CsKi/A7ft5GjGzO5quCNabnuQGTAqvV3YzHZJ Z57xNooP6xdVzlODOqpYydtfgxZociVkrkRwAN9XM9c+hva4lqHeu1PhRGeryIU6jWz8 5sWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747845777; x=1748450577; 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=VmQzX3BIbzz94t4XQwCRdZczcmOoQ3nURihzXuER/EE=; b=iBDr+sWkDq1+iZGJRG9CLqbERw7XWcvWrh75goVuRH/iY5h+3FN9lSTZ2nx5Myn6Up AvZbEt/XUtOZpqD5xwH/gobmGbjp2MhxOe5SUVRsfzLj0C5P0vbIMY9tJxY8nLN5Tzbm GeOeZfKLqJ1Qyj6SsZ2T8ZbxCmeR+yStbFOxtZFRRu5jAWKXKzntx3QHkv3LKAJ2zdrY 8rQeuKG6WB6UMSH/SOiQUKrylXLIvYffilFXYIhE1XzAtON/Su/bjp4uNgYRP472qkkJ Gv4A1PA7jjFOMGM9OYqdLZXGULtNIKrVzFssuPgNBGpKR2XC2hfF+m7LIgKkux+mbqE7 MTdA== X-Gm-Message-State: AOJu0YxgPfPE8eFS/fghh+55+Z9xoNUoXgxnNIj49bnMOf4bAvVL6ewg 5XPhjak4+PG3g02Swllcrwk4rGW6Hj4rItaGT0lWH+v5v4NrbeLdZ0yahut+r9tqqTw= X-Gm-Gg: ASbGnctdnwF8UJ1od4Fw8CsVCT2ZT2mcSzDprA9YSdfVd8+nBkgCMv7arOz5SFQkdcg ygnQFg4if2SI/v+oSragOpfXeaDEoLWXcssxujvxB/rxD2yQDQcVWi70cBOUgywdjxS/Jg6NI6v 5/ZGAeygh7yIWmZn0t/lgl31MxvQg3SS9JUvpdqeZCYAuVmvwSX8f/hjboM2WqDNZKsvmSmOuT8 rPWDQd9fkm4EokJ+KOu7PrtwEdEqSdI9Q2kp+V/Zz9BCCxV6Rqas7wYJVQgZw+txJl6qyfIZ9bR qUAkBECxhjdg8PmNsA0eo1FnpQfRbNKucQYiNwtWiu+m9Mgya2Nb X-Received: by 2002:a05:6402:5248:b0:5fb:f4a5:7871 with SMTP id 4fb4d7f45d1cf-60090076e17mr19948396a12.16.1747845777355; Wed, 21 May 2025 09:42:57 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6005ae3918esm9074721a12.68.2025.05.21.09.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 May 2025 09:42:55 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CF02B5F9FC; Wed, 21 May 2025 17:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Paolo Bonzini , Akihiko Odaki , John Snow , Fabiano Rosas , Peter Xu , =?utf-8?q?Ma?= =?utf-8?q?rc-Andr=C3=A9_Lureau?= , Alexandre Iooss , Markus Armbruster , David Hildenbrand , Laurent Vivier , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , Mahmoud Mandour , Sriram Yagnaraman , Dmitry Osipenko , Gustavo Romero , "Michael S. Tsirkin" Subject: [PATCH v3 08/20] contrib/plugins: allow setting of instructions per quantum Date: Wed, 21 May 2025 17:42:38 +0100 Message-Id: <20250521164250.135776-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250521164250.135776-1-alex.bennee@linaro.org> References: <20250521164250.135776-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.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 --- v3 - error checking for ipq v2 - checkpatch fixes. --- docs/about/emulation.rst | 4 ++++ contrib/plugins/ips.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index a72591ee4d..456d01d5b0 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 eb4418c25b..f1523cbee3 100644 --- a/contrib/plugins/ips.c +++ b/contrib/plugins/ips.c @@ -145,6 +145,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); @@ -175,6 +177,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, return -1; } } + } else if (g_strcmp0(tokens[0], "ipq") == 0) { + max_insn_per_quantum = g_ascii_strtoull(tokens[1], NULL, 10); + + if (max_insn_per_quantum == 0 || max_insn_per_quantum == G_MAXUINT64) { + fprintf(stderr, "bad ipq value: %s\n", g_strerror(errno)); + return -1; + } + ipq_set = true; } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; @@ -182,7 +192,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",