From patchwork Wed Sep 18 21:07:12 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: 829424 Delivered-To: patch@linaro.org Received: by 2002:adf:ebcc:0:b0:367:895a:4699 with SMTP id v12csp36161wrn; Wed, 18 Sep 2024 14:09:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXXqJKk51TAcFJguVJkga8jfswddjbWf4QiZ5ZjgABDw5yPG2mkFwkmiYNEKgXcH4kkbpQuA==@linaro.org X-Google-Smtp-Source: AGHT+IGxU7afp/XgLoVFqQo2rBHR9CdOtNMWS30t7rLoIlIRAk5WasNpb4caQpExOnQgf//4kpL7 X-Received: by 2002:a05:622a:90:b0:447:e3af:273d with SMTP id d75a77b69052e-458602dde8emr304286931cf.15.1726693740820; Wed, 18 Sep 2024 14:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726693740; cv=none; d=google.com; s=arc-20240605; b=D3wlU5f9NO7pZcoed5VUgqqrkDNbroZVbm3Mhxe1zGbACbMUY1ckUUq0GQ8dhqRkH2 xz5a47SwhZnuVXwSHcUKt4/55cOJdMa5UypQTMdthgHH6An6CW/2rCA+9sFE3Y1UggDS tpphGyKG9LZHWlr5itzCCjipHUjZcnRWcdvNa9kR0Xv3iFFwAF7gRx8KhEzMTET4oil2 35UoglI/Fm+mwzXfKGVHWXxFS9t6B/0aBsNbwiY3DLN0xBJejWYzAZ54aSbIqXlUgwfT O2yhQwxopR0Dj41gmWe7BLdMOuLVk04eBPy2S9YEhB6nz+IAFqh13VIZ78Y6ubBkOwKG yEBg== 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=cJpVIU5QQnwL+VksdQ4VURK2afv6KY7pJOWQu7Phvmw=; fh=S1IK43iaucMvYL5N/JiU2n5eAKMOpkvzRWgzkE/gLmI=; b=JBZtFxJtyD1PBHyuRS2iDtP48MzVDql6sB3jyiepbDqq75EWEwzt60wZmOxypAcMEd 4598aPyMXUgAYsFDpnvvPDHyuuX+lXxqb3s5CnG8OOIGpYeC4Ehbtm251p290gh+3M+z ee5dJ0wNS40NeCG5TbWdwrAhdCLFCY2mduuSOdjpPKkT4SJfSgZx+ntpDOQt6lPEupwc YOlZNs911kcv3XxC8h7wTYjhAUL5K/RIBZBmAMMr1S0K8v5ZZy7IBOr87EZan3F35nqJ PGD9qT1I3HG1qW7U6VPQ8w49ZpdieisEHfE17afhVTsTW81aAUflOnSqp/K4Kti8x0F+ DI0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SWUvD0+A; 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 d75a77b69052e-45b1792edd3si2899061cf.581.2024.09.18.14.09.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Sep 2024 14:09:00 -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=SWUvD0+A; 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 1sr1tb-0005ad-MJ; Wed, 18 Sep 2024 17:07: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 1sr1tZ-0005QM-9S for qemu-devel@nongnu.org; Wed, 18 Sep 2024 17:07:29 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sr1tX-0001ey-Jx for qemu-devel@nongnu.org; Wed, 18 Sep 2024 17:07:28 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c42f406fa5so108497a12.0 for ; Wed, 18 Sep 2024 14:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726693646; x=1727298446; 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=cJpVIU5QQnwL+VksdQ4VURK2afv6KY7pJOWQu7Phvmw=; b=SWUvD0+AqGdL22pOh/W4tLpWRbF+KPSX+mWCJpLSwUeqSWIwrhhrWP/6kWx0Cwo742 JNxYDQU1ayVWTvkm97spYOtipr4Y+/BSmIFL2EC8rGxxgYtDCZb3oV81YX5K/hcnW0E6 fDV6KdmrJqu2KQmVCTUNx+472PywKPOCVQ6fCrUckg/MZOCC7pSf9HRNPIcTc2xXLwXN jYtY3N5HO+BJv6eyxWfoRaG4QwSt53vg0duc0/K7HowHkmW60uq1pTsOsqiKBIFhGBG7 1LjFNnCCyCXyola9aJ5hqYLBpRDaV3He4DLKJqkQW4cu1+iONfFFZx3roXWZqfe9YBzb 9SCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726693646; x=1727298446; 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=cJpVIU5QQnwL+VksdQ4VURK2afv6KY7pJOWQu7Phvmw=; b=rF1pJ21l4nlkFcg3nk9XeiDX/nLeJKSlZEoWYHh/ZcqNz3sr09JLn8A7fqcYAVhA0a wog3TBYvW7C8If70A7Qq711kAlfZ2SvlaQSYdRPLK5WKSxmK4UsDAsZu5cyc7YuABfdA AIkkebDcljN6vYSO39sP2rRZyl5DI5iBTNm63cRDp4Ra9pOrO7hvjf1qQEU6jXFmTAzm YHRjHVJDsHvR+9wWz7Kk8J4/HUNTaregwnfM4qjTjQR6BdzaKClqRT/cvvGdeR5uLYfP 4eHNPnBaNupd6sYg06K5TwwVEgF2nMPN0Zx/xWm/GUp1NuAt4HkZgFepLozh7DFpcT0v SSdQ== X-Gm-Message-State: AOJu0Yzsl6j9q4JRKyFg9LBnsnjnvESXMfn6qN/2Gunk+IxopqY/l2gN odHgG/3qrkhpNALtujMzjbLGPEowAdo7oqn0rg7SvNeH6GX6HcqcCV5fVGXmfUA= X-Received: by 2002:a05:6402:5d3:b0:5c3:c530:e99a with SMTP id 4fb4d7f45d1cf-5c41e1930c7mr29715024a12.15.1726693646069; Wed, 18 Sep 2024 14:07:26 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c42bb89d50sm5389238a12.78.2024.09.18.14.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 14:07:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 075ED5FC95; Wed, 18 Sep 2024 22:07:14 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Elisha Hollander , Richard Henderson , Pierrick Bouvier , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 18/18] contrib/plugins: avoid hanging program Date: Wed, 18 Sep 2024 22:07:12 +0100 Message-Id: <20240918210712.2336854-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240918210712.2336854-1-alex.bennee@linaro.org> References: <20240918210712.2336854-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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. Reported-by: Elisha Hollander Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Message-Id: <20240916085400.1046925-19-alex.bennee@linaro.org> diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c index 29fa556d0f..e5297dbb01 100644 --- a/contrib/plugins/ips.c +++ b/contrib/plugins/ips.c @@ -152,6 +152,12 @@ 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);