From patchwork Fri Sep 13 17:38:07 2024 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: 828216 Delivered-To: patch@linaro.org Received: by 2002:adf:a2d0:0:b0:367:895a:4699 with SMTP id t16csp366721wra; Fri, 13 Sep 2024 10:38:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbeN34bTb/Z3jzvi/s/XYgoncj35bSSeAZeWe+AklYRHHM5w4pKe/OsP5pjfvphVTupqzOUQ==@linaro.org X-Google-Smtp-Source: AGHT+IHZopqxFE+QKN9TYGOOJwAyp24oBqUogt6svPOLRh7L89Fr6JL/Mr9Ictq5Dwr3lqVLe3D1 X-Received: by 2002:a05:6102:6ce:b0:497:5eed:cd89 with SMTP id ada2fe7eead31-49d4f6b5350mr3818628137.22.1726249132486; Fri, 13 Sep 2024 10:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726249132; cv=none; d=google.com; s=arc-20240605; b=DITSPYAC12IybFINUVy5Z7BDwv9RST9LbPTJbqqxWhIjuHG8DFYEbvFL4gCepHLLfQ GyUWxp5jKjVxI8c/rqGomh4S4jYMyX1+DluqxQhOWcNcNeSi6j1qSzVRRfWRAG6Gl667 h0dfsb6LElJq0kxAIyVapDRt17iwD/KjOgQi1AdT+D2DpqG1uFzV+D38MsK5mxLS1A+8 QqzxLIy2k+G4Hh8jy5HPfdKHxzlwuBLnDCZwsqQbBSRypd07WoM9gJ/UkH1BKsViWtz+ Krj9BudRNXX4BCxtQJQkM+c2QH+MhCKBqP0C3alklAI3DVw9jCFu/hZwM9yjNxUmea5v +2Hg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=NGz5PDdfxAHM9W9xvRou3IwZ4GoE9mbAemCN1C/ecuY=; fh=veYuKP/VQ2lg3yE+0BF4Vbnt3cpYN7xL+rgPg8/dJjc=; b=F9kuxbbD0ss6GCpew+JHI/VjOMvj1lqB7M+mGb+EQthlLgARGFoXCio4qOhxNy7hgK LkM7onMSjGszcLEaz3gNKeX3d3nR40KhzCaw37PskRHaULTAegkGnB13hZRCxwMVbdSd pvdQkGOoFQAs08YC+R5NGXgZJ7v9wYBTDWkTx+1r4IKR8arC4RiOBfpPBfmbkpHPjxic byZ5Zr/dJ7X/gUdvX0d0+CFTpnReGnYEs1C12UvKDwaafvwI5SiyWkF7zxWM3R4gcVhE iDy+QCTYSkHVZW17FgUx987F3Mv8A3250Z+OF2z1e3Fntwy73fx7flXsb/CaMEFvnRKN p3lQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PRTDXtfN; 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 ada2fe7eead31-49c16dd1c30si2173953137.480.2024.09.13.10.38.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Sep 2024 10:38: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=PRTDXtfN; 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 1spAFN-0001R7-BG; Fri, 13 Sep 2024 13:38:17 -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 1spAFL-0001Jn-Jf for qemu-devel@nongnu.org; Fri, 13 Sep 2024 13:38:16 -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 1spAFJ-0007El-Oh for qemu-devel@nongnu.org; Fri, 13 Sep 2024 13:38:15 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5c3ed267a7bso2763449a12.3 for ; Fri, 13 Sep 2024 10:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726249092; x=1726853892; 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=NGz5PDdfxAHM9W9xvRou3IwZ4GoE9mbAemCN1C/ecuY=; b=PRTDXtfNoqYRnTgtnEJzQZFXcEJY0LQ8K6PqTShC0UW4bH40GHQA+0brWpBCLJEn5E N3eIh+/F2fEQN7v+sw0FjH7LFs57qSa2wJG8ROLLwZv77zeadnOYULNuTu+ZuWceWQMQ PRhRHV7cT0xeM1huIzbLN0+0P2k9DJN9LadCQ2Ccz6Ft9In8jMFCacn4GY9iH5u/A/HL gU4vPOOWmPYZPqrZ1P2VEN78uZa9WEJGmOltjhJzyjI5bh1jVNymuIg8Jw8mUfHPLqmO SWMMQxUieQYkPyOlb9FnSv591uml7QVWX49p3CsShan8eUKz9iLM76iGU+i5s+8FLLaN vPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726249092; x=1726853892; 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=NGz5PDdfxAHM9W9xvRou3IwZ4GoE9mbAemCN1C/ecuY=; b=RYasAKpx1U+q3X+SsGITx6Gtn1i2RO50A2RAqi/m6m3zAyQ3eiKz6h9CFme7qWg1Nr osi9mGSic5zIy2AIbRD+ltLaBhGkM5yWsLK/v4mGA/KJY1zd9JdyK5G8OuG4bwmXXAvo fzqVY0CClWXqB2uJbOar4xgg1qc4e0q//rFb7IA7h9NKJ93xXTY5Wax/NET1nr9L+9nM 4/GnnfpPkjG+g8S2q1Z8sSKMEfOUQaW5DdSoh1PcyBcBBpDUDA0+d1SLcRoQo3PSf5QJ 3mSnYxzHtM3wlYnhaZYbfX0Ch58KclczZIfY4kCzm7cfxNr25duGd86I9XUDH95jB6po kk2A== X-Gm-Message-State: AOJu0YxZOSd41Vvii5dSSIMJX5wSTioxp3bL88hNFCHZvaPCVZtr5dqg PFsL30VBhEcaE5jnUjIjIoSj3HiieKydFsdsYsn55rp5EgD2YpdIdYBhGXuIMZY50S2boL7EDOV FLZE= X-Received: by 2002:a05:6402:1ec2:b0:5c4:b23:fe6f with SMTP id 4fb4d7f45d1cf-5c413e14001mr5726490a12.11.1726249091714; Fri, 13 Sep 2024 10:38:11 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd467desm7752124a12.40.2024.09.13.10.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 10:38:10 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A9A635F897; Fri, 13 Sep 2024 18:38:09 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Elisha Hollander , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Subject: [RFC PATCH] contrib/plugins: avoid hanging program Date: Fri, 13 Sep 2024 18:38:07 +0100 Message-Id: <20240913173807.189747-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 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: -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 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 Although we asks for instructions per second we work in quanta and that cannot be 0. Fail to load the plugin instead and report the minimum IPS we can handle. Signed-off-by: Alex Bennée Reported-by: Elisha Hollander Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- contrib/plugins/ips.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c index 29fa556d0f..6f078689dc 100644 --- a/contrib/plugins/ips.c +++ b/contrib/plugins/ips.c @@ -152,6 +152,11 @@ 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 (max_insn_per_quantum == 0) { + fprintf(stderr, "minimum of %d instructions per second needed\n", NUM_TIME_UPDATE_PER_SEC); + return -1; + } + time_handle = qemu_plugin_request_time_control(); g_assert(time_handle);