From patchwork Thu Jun 5 16:26: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: 894191 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:ecd:b0:3a4:ee3f:8f15 with SMTP id ea13csp44482wrb; Thu, 5 Jun 2025 09:31:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8Xe5Eyw/wj4lJDB+1Vh0w/GchJpcADnwVI1VadBBPSSFoMBdsnzIDKUJErEgUUDhq1pFSfw==@linaro.org X-Google-Smtp-Source: AGHT+IEG1hpPrrbLzNGl7N0IMwFLnIlDS/giOQ7v0RslQ7/7ufauztfWFM5yrX3vLvsa36a/z/P7 X-Received: by 2002:a05:6808:1998:b0:3f6:a9ea:eab3 with SMTP id 5614622812f47-40905097472mr358027b6e.5.1749141071088; Thu, 05 Jun 2025 09:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749141071; cv=none; d=google.com; s=arc-20240605; b=hoKZvAp3wz8GSH6/rz+WcUW919eqgqsjOMR1uv/UbyU3LsRfeFmW9gAMo7Jm832Rqx WmRSMeQfg8K1h4JtBZWa3F4fDy8izlizu6KTqfxbYDqKwSu60NeeuVEnCYL3OmZWj8K/ 78k+AtwAMbH6MZkh5aws5HXw5Y+7iyP8YenIkSjZBym8IjuY03wnDddbLV4WsFQ/1bQg onaj+WPZtBnMTor/JV/iCOJlWjFxUrmK1PIZ3LyToriAm9bm1ijvUQ4xbHuKKvkAoCG+ VSQHA5eucknpDtRK0v37NQUCyX+LdC0+zw8kiplnjzyjTgGkqzQXHG+6ZXkRGcaWhM8N XgtQ== 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=1RYsWu2FLtSlw32TxI54Iy1CVKbOUEX/+7bcau3xMfg=; fh=OKPV2P4508qC/I56dRWB9cUXOgLlJvy5mUvS6JzYKt4=; b=HAz2Se3s1Q0dRa+qflMfE/TKpWJxVBsD/WS9prU6F0hotpN5empdx4xgfbhcAV1M1W ie4yQSeP6hsdgPPxN7UWASfsWAF9mGIbr0VzcFHbJAZk8KeEfGcPEzeNfr3bTqRNccQf Y1xPlrDydBFJGzdHPm2RwGwBiTgl3QhnvwUfQinAsVmD79JfmNdU6EoY4a27SobaX0op w4JyZC1JzSWEEj5+rqcmyxECCDIyAFYgCY9nZcWtKOlJmoIEBnpqk/yGw5NgRUbmdrYD 89iQqkIgvvtZ2ArckCDKjlWTwr4guBjBZqp76bxhFqVJt6RSD7iloIATjc3937sastq6 +ZEg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dyDN1xUE; 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 a1e0cc1a2514c-87e2a4ac5cdsi5112890241.92.2025.06.05.09.31.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jun 2025 09:31:11 -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=dyDN1xUE; 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 1uNDQj-0006zv-Lt; Thu, 05 Jun 2025 12:27:01 -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 1uNDQi-0006yi-4e for qemu-devel@nongnu.org; Thu, 05 Jun 2025 12:27:00 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uNDQe-0007vx-Si for qemu-devel@nongnu.org; Thu, 05 Jun 2025 12:26:59 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-606b6dbe316so2085756a12.3 for ; Thu, 05 Jun 2025 09:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749140815; x=1749745615; 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=1RYsWu2FLtSlw32TxI54Iy1CVKbOUEX/+7bcau3xMfg=; b=dyDN1xUEOlHmgMMBi/PLhp5QJeEl/GIO1LWdKWzwVHTzVGvqbEiQkKpZxWvwE8uHQO vEcZvQeB/DtX5ZMW/T4L1vm+70NIDNIC4tT8CqiH+nkQyzj4P8h4AxlWo3gXKWyXtGhD gpq/Le0GX6avOCc+G/DO/JHbRI4VPB1wUitMCdPkYhy1Zst1C2qg5z6C5kc0mLxSJwKX 2xH//DdV0QVsog16ZD7w/OkNtnUpD6SOvTl/FTdVt7Z7NtpaG00JK6Gi6bljGMWr9ik9 Cq7sZ1bRJcMxvHn3AsjiwMIYZWuAwQk0Y6cjzsBEN1URAuTDPEgaI1s8Yx8ry4jODzEE K/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749140815; x=1749745615; 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=1RYsWu2FLtSlw32TxI54Iy1CVKbOUEX/+7bcau3xMfg=; b=TPYaBYUGnT7tmN1I2Ao1quV27AggIWvRKUWMYFeV5TaW5eu+VFbzspXKLGmjLbgoXe 8U7Twc7cU5X2xaHyWt2l45kxhhV/WFS94dsz/qjXkS0KVmrjpaXo1gV/lHL4VHHk8ugq pjqQdY0/lxfQV8cgj5VO43z1ldBdw9FOOX1s6GF22/ywGydNVCUwQK1SzGDDVw5o6Wmz vh8oa+xTUDmus7l5NnjO5lcMYcliCcXM+Z69yCIXMONiBIm/Ma67YvjFg51maG1yXRuA H5lZ6SlC+/TCPgAAgP0Mnq7kMUx/cmufaqn7h4DPWNgutAvKoQk6UvwfsVnZmLBfUpZ1 0i5w== X-Gm-Message-State: AOJu0YyuvYKL20B3+kndQIcfDkTIGhCazouF8ax2DkU8io//BdzDUVGS 3A1mkKDRIggCzaHEgYZpO27bk7W9P+FspeFjGA4LZeyM90ls07oVE1vf9SNstI4Ym3Q= X-Gm-Gg: ASbGncvZ4HhY89zNdDQdVqc0bA/Z+4jDThMPiimlnMNUowZjpt8tqmjxDWc8MB55PvB SM3bGX1Eyiomc7ek52yIb9VZW8YNZjOx+Rn/DWvXtMV8CmKDEedOcyr/HbGbCYrosZ464EVH2Wi j3HztxGtuEvnl1Wxtb6DbJVR7QXgT3uyDr58furMC79oHK9ID6RM3gZXG6MSizPIsGJyUsz47Vx Rlc3o10ZRkS54qCK06lp80K5hXRgdy9jpjK3pOBb5xrZGTle4+Omio3ioq1q6QH7zB8BXkIp6ud 14e6NEbUljcqRvHYSQmOn1i4xIUlCNUjOhSMpMQRiOi9aEDbg2NzPwG/lT6Y48k= X-Received: by 2002:a17:906:7311:b0:ad8:a9fc:8146 with SMTP id a640c23a62f3a-addf8f5a697mr705689266b.44.1749140815089; Thu, 05 Jun 2025 09:26:55 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ada5e8780besm1293932266b.94.2025.06.05.09.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 09:26:54 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CF3E75F7F7; Thu, 05 Jun 2025 17:26:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 05/17] contrib/plugins: add a scaling factor to the ips arg Date: Thu, 5 Jun 2025 17:26:38 +0100 Message-ID: <20250605162651.2614401-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250605162651.2614401-1-alex.bennee@linaro.org> References: <20250605162651.2614401-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52a.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 It's easy to get lost in zeros while setting the numbers of instructions per second. Add a scaling suffix to make things simpler. Reviewed-by: Pierrick Bouvier Signed-off-by: Alex Bennée Message-ID: <20250603110204.838117-6-alex.bennee@linaro.org> diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c index e5297dbb01..d067971135 100644 --- a/contrib/plugins/ips.c +++ b/contrib/plugins/ips.c @@ -129,6 +129,18 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata) qemu_plugin_scoreboard_free(vcpus); } +typedef struct { + const char *suffix; + unsigned long multipler; +} ScaleEntry; + +/* a bit like units.h but not binary */ +static const ScaleEntry scales[] = { + { "k", 1000 }, + { "m", 1000 * 1000 }, + { "g", 1000 * 1000 * 1000 }, +}; + QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) @@ -137,12 +149,32 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, char *opt = argv[i]; g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); if (g_strcmp0(tokens[0], "ips") == 0) { - max_insn_per_second = g_ascii_strtoull(tokens[1], NULL, 10); + char *endptr = NULL; + max_insn_per_second = g_ascii_strtoull(tokens[1], &endptr, 10); if (!max_insn_per_second && errno) { fprintf(stderr, "%s: couldn't parse %s (%s)\n", __func__, tokens[1], g_strerror(errno)); return -1; } + + if (endptr && *endptr != 0) { + g_autofree gchar *lower = g_utf8_strdown(endptr, -1); + unsigned long scale = 0; + + for (int j = 0; j < G_N_ELEMENTS(scales); j++) { + if (g_strcmp0(lower, scales[j].suffix) == 0) { + scale = scales[j].multipler; + break; + } + } + + if (scale) { + max_insn_per_second *= scale; + } else { + fprintf(stderr, "bad suffix: %s\n", endptr); + return -1; + } + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1;