From patchwork Fri Sep 3 09:03:28 2021 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: 506479 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp824102jai; Fri, 3 Sep 2021 02:09:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuKcns6HlKlJpttsCqScIbJXjaZnFCZH+0QXD5Y6tai9iQo7i6p7j9jt6HDnksBZLqQZ1V X-Received: by 2002:a67:fb96:: with SMTP id n22mr1754216vsr.15.1630660160883; Fri, 03 Sep 2021 02:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630660160; cv=none; d=google.com; s=arc-20160816; b=JDbvqkNLVU5hoxo9UoGg1fQjPzwz6bpmfr5Kzfv/00jYu38aVOI7Zgm/BGj/W+xkJi v4LPo7FprodZPCeaPCgtIBpYJkj2llLsRHNvivdEXzs80YFvQhYSlCrTcox071U9qGYT +KHswVHPNDg6ngfssVxz0eyYjaTrmn+BxjwYvCXUYbapkAMWJ1n5Q1j3dTl2li7HsSrv 2s/XnK0tUmD9qILF++G1yKb/kRfq5pQY3pC7UPpeQO1OIzjLshdInJcJBtZCL82da9Op bHy3mx9w+5EqJp82Fo0BLWmiG2chIRnGANHn9RQKJ9mIOaKjcxzUxPB4Sos3z684MaUL d0EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=omwD0CvH7QKtlKqaBp+2tXe6lKOc5AVhGBgb958NX84=; b=IhpOwdT1gGQOoKcwS4pb7FdcwuO9ozZzXdTfaiT0cqsCpV2cLvUdJwC2EPWX38BLUn V5WVn7bR3fxIiNNiOib6xe5eutDVbvsx7FMpV6zv0KW7JRZtCKJaOsn6876Bo5DBsCmX C2oeRU+ua/wW03SgfWU8QiRGsk+q+EK7rgw2kpuJ0TGLgHGO1adM/KHoFBlUtCn+StMG E47mXv1nFVin2NorlSmxYtgnFW9NPo01lg80VnRyU+vieAxVwDUgz4+KukmIMSVp8TJE +MjeP/g5YzBfgkxxWj00RtN8DGCwWqAaTzjZ360SiWgCZy4pRHYMx74VcCUSZGqUItXG fSBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W30RGIQA; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w11si2121131vke.27.2021.09.03.02.09.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Sep 2021 02:09:20 -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=fail header.i=@linaro.org header.s=google header.b=W30RGIQA; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5CK-0003jP-0E for patch@linaro.org; Fri, 03 Sep 2021 05:09:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM572-00064n-Kn for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:03:52 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:41653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM570-0005a1-Vc for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:03:52 -0400 Received: by mail-wm1-x32d.google.com with SMTP id u15-20020a05600c19cf00b002f6445b8f55so3114097wmq.0 for ; Fri, 03 Sep 2021 02:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=omwD0CvH7QKtlKqaBp+2tXe6lKOc5AVhGBgb958NX84=; b=W30RGIQAW/jU/eKsCxBjChQK1S3oSIjb/C3v7WuLB24zHMxxr2bGYOfyXa2ONa7UkQ mPPeEfb0TaQRoJBFtpEsFNe/NgEoG58/DPmveKjbCLRwdWti+pwD7UoKMwpSgMwXYCI7 8NtFPETKLswrH3a0WXEOnqk4c4ebp/TNUWqQGmRzaIf2XgbCVauHSIaun4z/AeKY9iSR 38eb/lnZWLiLaNnDEfOFWR6CPMuxL8tymJA3+ARf45ERoTa8ybYdqGPABYAp2y7mUmq9 1uJwAepWM7hGkzxT36KmVxUTQdCg0lA4kJVGFHVsxwa8zJGIFmwUcc92MNkrls2z4NU7 eJXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=omwD0CvH7QKtlKqaBp+2tXe6lKOc5AVhGBgb958NX84=; b=E7G1khVzd1VhchA4hlA8GMXZtbOsoF2ar27h0CJU0lajBVGefiVfBxfoiLrNojj+sZ BDpmxLv/5eupdRLMFFwCqs2k24PBkfgPjKOuoX2EYtFcTSZR3i0exYTZrcRO35WFFUor TG4EDUBOgC5pv2o2BoAXNgoJq05hPfWm5vq5jnmYqodaAAaeRqkiaKtBWOcq3RqGqCht oN3dILDl4IA05ZAPqzqPd4pzatKbyq090jkH70PHTLTbxNu8A+EozmU9ZnUYi1RiFQZ6 2gclEQbtO+qZatgU5IswFI5NZBP0hKov1yLPif7KeR8u11XfQTw14Rcf7cWbogAtD61d PwGw== X-Gm-Message-State: AOAM530Id47wAliN1WnseMCtqhTrZgNQtepLL0l6Ayfu1K3XkK8QBxS8 xXGpgG09gHqw1BILMBY89PbgPa69owZGpA== X-Received: by 2002:a05:600c:35cd:: with SMTP id r13mr7287927wmq.24.1630659829707; Fri, 03 Sep 2021 02:03:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g143sm3789723wme.16.2021.09.03.02.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 02:03:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C0F531FFA9; Fri, 3 Sep 2021 10:03:40 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 11/22] plugins/hotpages: introduce sortby arg and parsed bool args correctly Date: Fri, 3 Sep 2021 10:03:28 +0100 Message-Id: <20210903090339.1074887-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210903090339.1074887-1-alex.bennee@linaro.org> References: <20210903090339.1074887-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Iooss , Mahmoud Mandour , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Mahmoud Mandour Since plugin arguments now expect boolean arguments, a plugin argument name "sortby" now expects a value of "read", "write", or "address". "io" arg is now expected to be passed as a full-form boolean parameter, i.e. "io=on|true|yes|off|false|no" Signed-off-by: Mahmoud Mandour Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée Message-Id: <20210730135817.17816-4-ma.mandourr@gmail.com> -- 2.30.2 diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 2d29a8972b..aa75b390b1 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -193,6 +193,21 @@ Similar to hotblocks but this time tracks memory accesses:: 0x0000000048b000, 0x0001, 130594, 0x0001, 355 0x0000000048a000, 0x0001, 1826, 0x0001, 11 +The hotpages plugin can be configured using the following arguments: + + * sortby=reads|writes|address + + Log the data sorted by either the number of reads, the number of writes, or + memory address. (Default: entries are sorted by the sum of reads and writes) + + * io=on + + Track IO addresses. Only relevant to full system emulation. (Default: off) + + * pagesize=N + + The page size used. (Default: N = 4096) + - contrib/plugins/howvec.c This is an instruction classifier so can be used to count different diff --git a/contrib/plugins/hotpages.c b/contrib/plugins/hotpages.c index bf53267532..0d12910af6 100644 --- a/contrib/plugins/hotpages.c +++ b/contrib/plugins/hotpages.c @@ -169,16 +169,26 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, for (i = 0; i < argc; i++) { char *opt = argv[i]; - if (g_strcmp0(opt, "reads") == 0) { - sort_by = SORT_R; - } else if (g_strcmp0(opt, "writes") == 0) { - sort_by = SORT_W; - } else if (g_strcmp0(opt, "address") == 0) { - sort_by = SORT_A; - } else if (g_strcmp0(opt, "io") == 0) { - track_io = true; - } else if (g_str_has_prefix(opt, "pagesize=")) { - page_size = g_ascii_strtoull(opt + 9, NULL, 10); + g_autofree char **tokens = g_strsplit(opt, "=", -1); + + if (g_strcmp0(tokens[0], "sortby") == 0) { + if (g_strcmp0(tokens[1], "reads") == 0) { + sort_by = SORT_R; + } else if (g_strcmp0(tokens[1], "writes") == 0) { + sort_by = SORT_W; + } else if (g_strcmp0(tokens[1], "address") == 0) { + sort_by = SORT_A; + } else { + fprintf(stderr, "invalid value to sortby: %s\n", tokens[1]); + return -1; + } + } else if (g_strcmp0(tokens[0], "io") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &track_io)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } + } else if (g_strcmp0(tokens[0], "pagesize") == 0) { + page_size = g_ascii_strtoull(tokens[1], NULL, 10); } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1;