From patchwork Fri Oct 5 15:48:50 2018 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: 148197 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp614815lji; Fri, 5 Oct 2018 08:52:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV63LWEgcB2Sl7Sp+psofqIeXBJ9bgkhvs2wsuqfKRg4lC0jY2sfUTQKwxE6IEO62oS9Y8ycW X-Received: by 2002:ac8:7397:: with SMTP id t23-v6mr9740533qtp.4.1538754760147; Fri, 05 Oct 2018 08:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754760; cv=none; d=google.com; s=arc-20160816; b=WKpAg4h+bwlX6rqE+FUfLkMLt3JeN1zqpihS50feO7026pjaomQ7RzrvTDq8ginB01 rewCxZIfPjJii42bs7PnPdLhxPfphO2yPz24wBL1kVTc2pznA56gyhhvtLq0P3wrUcmB Y03Numx8fVOlX7H+YblCiwyE7fn679LginHPtw55t+1MSbSqP4mUBbjEA5uhsYFvsma+ uqpXjWguWwbuTB4gHgzdbv4B58l0dK2+IzoVtg1aPr6Ukd3G1S6I+U3MpKRTGHO1rTvN FH0akrAi64kXdrmI5cy7ktIJPoddCgLofr3zKE9XclElKd1fd2Y+xS/+2YEfuhKZEjBQ vLLA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=sUT0fHuC8tC38e4sWf5saxV3jwW/ZdmpfK9ZIOC4/NLIYyOc9f7XqPBoNy2yQ2QEFV FsoDVC3Dw+zC8DRfPyj5RWWDSfa2B1CuA6tDkhWYNeLWWoUKuPL20kqKd6uZBVo7hSkS F7udrgSTuCQjHjPKYwL6Q1ysY+NU6jcEfYtlpyNyjm3QCO0k2NXaYbMMBF9uZ5rLfhjW gucsCi450c4stMPuP7K/+VM9OCAUyCdHyVVrbdPKsHsB+igI7n5W19DCet8bcpTyI4Yq Ow38EONkMZ/ec8f8t6J54zByizVm+cjjpWdpOznxfYWqQ+ZfasrSYQDML7nsYb9m81X/ VoDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W56GmmE9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h16-v6si419658qta.340.2018.10.05.08.52.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W56GmmE9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SP9-0002IH-I2 for patch@linaro.org; Fri, 05 Oct 2018 11:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SM6-0006XV-TG for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SLz-00065Z-Gn for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:29 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:52742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SLv-0005ze-MZ for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:21 -0400 Received: by mail-wm1-x333.google.com with SMTP id 189-v6so2313543wmw.2 for ; Fri, 05 Oct 2018 08:49:14 -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=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=W56GmmE957Z9OYZkUztYcIrfFmhChuRMZucfj7c2MKDbD7Ebcyl+VS0eMLLZJEi+gS LT+DkQM8SQyc7eoZuWJo1uw8UBfYQ0VHnHW9VriJUTFhbG7oirQPVbAMqnTD9BEnOM1c rlbvXEhNiaEaUXwzvHZiqLpfxgAYA0ujL1VmU= 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=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=tOKU0NQSbL8xR+X2AeR147HWmvS4obqkAImMrsbkVdMD/4jAXeLHWJgfvQeZ4gEkpX cA3ujY2Hm4B4qDaqu/2o9qT6XVJ/TcP93Kl9g1avCFN3f/1md9WuNhEJ+UiL4hWF+QnX TeV8cwjk+zkOggX7HHSFLxIOl3UO7fYiTyOGphxNyOR1MFbltjevuNGQ7G85I94Lmjjk SweQ+k9rFpff3BtAr/aSCPrEIJFEhaHplL2FqsIvpO7jdYofBesWSJ2bW9t/RUeDOawZ GiRgBvPtdSSubIrAbFsG8FbQmwoFs30nqkZnJoB32EvjD5frQ1jZ3hzkINtVpiEFcgG6 /fXw== X-Gm-Message-State: ABuFfogD7te+YwFL9vf4tUbKxlLvByc+anMwyxLS912gg2R3X+i0FRYs jiqTt9i1uXPXVdNJLqg7IfxeRg== X-Received: by 2002:a1c:2384:: with SMTP id j126-v6mr8228763wmj.124.1538754552898; Fri, 05 Oct 2018 08:49:12 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e7-v6sm9219087wra.37.2018.10.05.08.49.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C5F743E032E; Fri, 5 Oct 2018 16:49:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:50 +0100 Message-Id: <20181005154910.3099-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [RFC PATCH 01/21] util/log: allow -dfilter to stack X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The original dfilter was patched to avoid a leak in the case of multiple -dfilter ranges. There is no reason not to allow the user to stack several dfilter options rather than push them all into one mega line. We avoid the leak by simply only allocating the first time around. As we are using a g_array it will automatically re-size as needed. The allocation is pushed to a helper as future patches will offer additional ways to add to the dfilter. We also add a helper qemu_reset_dfilter_ranges() so we can be explicit in our unit tests. Signed-off-by: Alex Bennée --- include/qemu/log.h | 1 + tests/test-logging.c | 14 ++++++++++++++ util/log.c | 23 +++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/include/qemu/log.h b/include/qemu/log.h index b097a6cae1..8ed932ec24 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -116,6 +116,7 @@ void qemu_set_log(int log_flags); void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); +void qemu_reset_dfilter_ranges(void); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/tests/test-logging.c b/tests/test-logging.c index a12585f70a..fbddd70ebc 100644 --- a/tests/test-logging.c +++ b/tests/test-logging.c @@ -43,6 +43,8 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x10ff)); g_assert_false(qemu_log_in_addr_range(0x1100)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000-0x100", &error_abort); g_assert_false(qemu_log_in_addr_range(0x1001)); @@ -50,6 +52,8 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x0f01)); g_assert_false(qemu_log_in_addr_range(0x0f00)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000..0x1100", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); @@ -57,26 +61,36 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x1100)); g_assert_false(qemu_log_in_addr_range(0x1101)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000..0x1000", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert(qemu_log_in_addr_range(0x1000)); g_assert_false(qemu_log_in_addr_range(0x1001)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100", &error_abort); g_assert(qemu_log_in_addr_range(0x1050)); g_assert(qemu_log_in_addr_range(0x2050)); g_assert(qemu_log_in_addr_range(0x3050)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0xffffffffffffffff-1", &error_abort); g_assert(qemu_log_in_addr_range(UINT64_MAX)); g_assert_false(qemu_log_in_addr_range(UINT64_MAX - 1)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0..0xffffffffffffffff", &err); g_assert(qemu_log_in_addr_range(0)); g_assert(qemu_log_in_addr_range(UINT64_MAX)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("2..1", &err); error_free_or_abort(&err); diff --git a/util/log.c b/util/log.c index c0dbbd4700..c6c197cbb3 100644 --- a/util/log.c +++ b/util/log.c @@ -149,19 +149,30 @@ bool qemu_log_in_addr_range(uint64_t addr) } } +static void maybe_allocate_dfilter(int size_hint) +{ + if (!debug_regions) { + debug_regions = g_array_sized_new(FALSE, FALSE, + sizeof(Range), + size_hint ? size_hint : 1); + } +} + +/* This is only really used for testing, usually dfilter stacks */ +void qemu_reset_dfilter_ranges(void) +{ + GArray *old = debug_regions; + debug_regions = NULL; + g_array_free(old, TRUE); +} void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) { gchar **ranges = g_strsplit(filter_spec, ",", 0); int i; - if (debug_regions) { - g_array_unref(debug_regions); - debug_regions = NULL; - } + maybe_allocate_dfilter(g_strv_length(ranges)); - debug_regions = g_array_sized_new(FALSE, FALSE, - sizeof(Range), g_strv_length(ranges)); for (i = 0; ranges[i]; i++) { const char *r = ranges[i]; const char *range_op, *r2, *e; From patchwork Fri Oct 5 15:48:51 2018 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: 148199 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp615537lji; Fri, 5 Oct 2018 08:53:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV60xCFBEdn4AqhC1ZO0NA2GC32xDMqxavDTOhUFQkXjIRupY6wZ6pH9ijB6J8om8MIVQO41Q X-Received: by 2002:ad4:4202:: with SMTP id k2-v6mr6732146qvp.164.1538754798275; Fri, 05 Oct 2018 08:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754798; cv=none; d=google.com; s=arc-20160816; b=rM9fcbDc2cCCi5XUMtWyni8j76w0fslRPnB3D9vQKstYtzj4ZA771b7ERPvhwc7g3e sScc2WvSYdeEp829rEZaIZ7hcsNhWOTnyjdGQrN/n0ECrd2QTMbcHwppk0eRMKAp+s9j mJJCzyF7B96hLaTTuoWkZZcTioAs664P+Y0u+cxGb+84bQqlWSX233gySxEZ4brNMEQV 35npOGPwQ0DgylAHgl4iiigayqZWOxAlRlwQ16Lg8ZVE2la7dvMb6HLacij8XbfUkyro FgPzEQMimJrbXo/EJFHCbY0uIKsY/tcLoIISJBqARDjqxSyCyb0Rj6SkmYJCrfojLYn2 AtJA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=D1FbLX910so6SaKCOSuPws2+nJ0jbCkyT6j7dOftgSf6r3R8lQS3ub3c7HFy3Cp7He EkKXYIcxwScPQ7zyxqP/Z85im2fFwfrWSwvGc0bIHbrWImQlYex6Q8thGy7aGWEukL1w 2OBD2SevTsQhrFGQojkPwpQSqKxykXGa0UfYFhO6jyE6mkUa9OOFqZNnFwocZLR7uXrb 4dL7YerY25Ai1gQpXKUwoihfntOVtxYsjHx+/V4bYt1km0DzmsUQOXGEcl1o/P0LJzXS mMIaF1Ik65NfO3iIoAEmblyqgbMV8nz1jhveIYo2xn1SsizvF0s6jlCYYZNkmDSdqfqI NtBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PzdxG7Rt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r31-v6si1400618qtd.29.2018.10.05.08.53.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PzdxG7Rt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SPl-0002W2-DZ for patch@linaro.org; Fri, 05 Oct 2018 11:53:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMA-0006aV-BI for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006CU-IZ for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:34 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00060C-2n for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: by mail-wr1-x432.google.com with SMTP id z4-v6so14054148wrb.1 for ; Fri, 05 Oct 2018 08:49:14 -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=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=PzdxG7RtgFdQV+lAy6c2Gd31i2Xg7aiYFdPmcc1ubvepEcbTk4kiORmLn64oUPwgOS piFAlIo2kJXCVZs3CHpCJ8UkhL8B27wUqzm8+Zi9gzn8HGdgGp8DCnr8SsNpkiD6T+iK LUwoMbLysDanYLDCRnRDdVNDkzo0spQ53SKyQ= 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=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=DAfZZqLZvUnxE3XmMhFGwQ68I34nf2rSkHflJCu+ofvIc0QwVmzFtJjOLpZUoHiNkU V/5L5P3j0Fpd3hGVLwXZWxVPwLaV4+Vu7BuLVvRu4iVUUWMMstbsHSuuC7eYWfDoFpn8 7lf3EGknyzlUorv/0/qJwUxNVKBcak+pVcLASWy60RCNLar3yuBtz/UoXrJb86DpWw9e xBB9zKknGxuOYXvMl80fV8prwlS5UghVsnzZjfrUZRB4XrNrd4o2VJM8sfuZ42IR02X+ K4g2JVKZMLHm7HN4rkdIpf+7xkhrVOAtcublG9ABq2PRjKJ4FzEagKlNXmR7tKAZaBR1 HxJA== X-Gm-Message-State: ABuFfoiIdz4qEmWWjNkrZxW7hn6t3BYCbMs+yLlwNuHDGWLWL+rCZjKA +6yKX1MiyaV8t0gfiaYekl1EEw== X-Received: by 2002:adf:8022:: with SMTP id 31-v6mr9279849wrk.16.1538754553687; Fri, 05 Oct 2018 08:49:13 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a205-v6sm2287543wmh.19.2018.10.05.08.49.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D92593E0370; Fri, 5 Oct 2018 16:49:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:51 +0100 Message-Id: <20181005154910.3099-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [RFC PATCH 02/21] util/log: add qemu_dfilter_append_range() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to add to the dfilter range as we go. Signed-off-by: Alex Bennée --- include/qemu/log.h | 1 + util/log.c | 6 ++++++ 2 files changed, 7 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/include/qemu/log.h b/include/qemu/log.h index 8ed932ec24..f915b5bd91 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -117,6 +117,7 @@ void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); void qemu_reset_dfilter_ranges(void); +void qemu_append_dfilter_range(Range r, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/util/log.c b/util/log.c index c6c197cbb3..cc79a146d1 100644 --- a/util/log.c +++ b/util/log.c @@ -233,6 +233,12 @@ out: g_strfreev(ranges); } +void qemu_append_dfilter_range(Range r, Error **errp) +{ + maybe_allocate_dfilter(1); + g_array_append_val(debug_regions, r); +} + /* fflush() the log file */ void qemu_log_flush(void) { From patchwork Fri Oct 5 15:48:52 2018 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: 148204 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp620420lji; Fri, 5 Oct 2018 08:58:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV61OR9ZtH92ndKmaQBEbxLZkWb1J5hOmcH1D6cvUkKVzYXN7JoWPnk1+6ADpnxYjyUjL8Aqc X-Received: by 2002:ac8:f57:: with SMTP id l23-v6mr9970665qtk.158.1538755093860; Fri, 05 Oct 2018 08:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755093; cv=none; d=google.com; s=arc-20160816; b=qDAb93SQFC+UtyVQTWeuqdDVm5ATYFJP4QokmPhLiIn3KeA/6TqtJjk0F0179+jiXe BObUwHrkUgG8IplPMFcIU43fRLr2riot0kB4DmA9Ey17lni23+Bp2ab4yNNM1pn8Z28w GseSvYF32YpQ0geNha/asmV2W2We2MAns9szFKiXuqTqxPw/YXj5MRTPbMYzng4kbdLN uM5GVahX7vcfCCb0VsW9Cjwrn1SKVl/Vx1YDAIkzUCxwci1m4EDw9WMovJt1Bjl/UBRx pZXj88yUzyXqPqYktsJTUVE8/M7/HSMVdl+zbreOAqQ8lrHLjcweg+pc1W9/JmU7xDtP b+3A== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=9PaHLO4QvMOVEhvzt3qos7UmOXADa5a3nvimofpCjDk=; b=KJ6sTSF0QqoUq6/R0juDy3dG1eYTqZmZED/6l5W8VaeapD2I7HOI46FcoIe+yLWXwR 2ekRvQB1YIaslJcYiElc7PpbznkOWSq3C/Ce/Omwzk2/QMKbr0fpfEd8WrtW+Az+fMxC WEx7+uggO76HaAZRyFT4jz82NUSJP0CEZ82EqaECmQtOQzPE/7AeN+uAyyXrhTYBN7/t ifAWRXEJ2cjEMM+luwoVf3eUSPxBfdC7LkXT5WGVkq1q5WFUlooD/ZzXhpUY5+V84UXy OS+C4+u3UOlLXEZ1YQ3jjqc1tBw4yalwsCkidj7HdQH1vEbSqA3jGuKCbE7eKw1Dfxh/ 25Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UyuolF6N; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 3-v6si5825997qvx.161.2018.10.05.08.58.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UyuolF6N; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SUX-0000Po-9n for patch@linaro.org; Fri, 05 Oct 2018 11:58:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SM9-0006ZC-EN for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM7-0006B4-Na for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54217) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM7-00060v-Ci for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:31 -0400 Received: by mail-wm1-x344.google.com with SMTP id b19-v6so2315953wme.3 for ; Fri, 05 Oct 2018 08:49:16 -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=9PaHLO4QvMOVEhvzt3qos7UmOXADa5a3nvimofpCjDk=; b=UyuolF6NkrgrMgBFA5ifcoRu/w0HCiPsD/HCwLh9L2Ht4VDSSPxbnE2GDI3mPtf5kC E+HHSZku1F/3IJtdY1tcLoR61kPLc/FxXPhtRynbVNH2guZx8Y3j2WfZmIuLw06eYHeU SrLZBWFk62kGo4Bp7edFOIGT2mQHYyhSZ74m4= 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=9PaHLO4QvMOVEhvzt3qos7UmOXADa5a3nvimofpCjDk=; b=jEadUUgbGKHwsmYhpsVs+5ta6joNPEEmdo0s9rDIcM1Sn0CJ9htxvc65JPttQ5hBZS YQ3IMRnX9YJww+LYe3cTgZT0b43T6259fpuGQ9bzZx/63DHtsDUeaL5RhcnMlfRJnD2X CmbbQq2DakXZxNu6Cpi/M+QRjHs6XrAV+QboKD73IJhTHUc2dhL0oQrNdHdmm3pcTh+o q5rL+epJEo63LZebMq/eWexP6y50TjOMPnNH/y559Z+sAQkQXuCADA2DyvzQhR1wt7ik NvL3jAyiUmLV+1UXQDkOo9qjtFdYKymDMgJqIzmkakDEYSgAcszSK1om7hT2j7RNwHic CM3g== X-Gm-Message-State: ABuFfohjgax51IP6ZsbA5+j+mz6xGkinsEhHEIC6EOc24LsBWdMncuj1 7rDRTSnME83mA6leIUYMommo7w== X-Received: by 2002:a7b:c259:: with SMTP id b25-v6mr7938258wmj.138.1538754555344; Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k25-v6sm14087216wre.18.2018.10.05.08.49.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id EBB5A3E05CF; Fri, 5 Oct 2018 16:49:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:52 +0100 Message-Id: <20181005154910.3099-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [RFC PATCH 03/21] linux-user: add -dfilter progtext shortcut X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , cota@braap.org, Pavel.Dovgaluk@ispras.ru, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When debugging you often don't care about the libraries but just the code in the testcase. Rather than make the user build this by hand offer a shortcut. Signed-off-by: Alex Bennée Reviewed-by: Laurent Vivier --- linux-user/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/linux-user/main.c b/linux-user/main.c index 923cbb753a..a68674d0de 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,6 +28,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/range.h" #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" @@ -51,6 +52,8 @@ unsigned long mmap_min_addr; unsigned long guest_base; int have_guest_base; +static bool dfilter_progtext; + /* * When running 32-on-64 we should make sure we can fit all of the possible * guest address space into a contiguous chunk of virtual host memory. @@ -222,6 +225,11 @@ static void handle_arg_log(const char *arg) static void handle_arg_dfilter(const char *arg) { + if (strcmp(arg, "progtext") == 0) { + dfilter_progtext = true; + return; + } + qemu_set_dfilter_ranges(arg, NULL); } @@ -423,7 +431,7 @@ static const struct qemu_argument arg_table[] = { "item[,...]", "enable logging of specified items " "(use '-d help' for a list of items)"}, {"dfilter", "QEMU_DFILTER", true, handle_arg_dfilter, - "range[,...]","filter logging based on address range"}, + "range|progtext[,...]", "filter logging based on address range"}, {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, @@ -796,6 +804,12 @@ int main(int argc, char **argv, char **envp) qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); } + if (dfilter_progtext) { + Range r; + range_set_bounds(&r, info->start_code, info->end_code); + qemu_append_dfilter_range(r, NULL); + } + target_set_brk(info->brk); syscall_init(); signal_init(); From patchwork Fri Oct 5 15:48:53 2018 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: 148194 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp611975lji; Fri, 5 Oct 2018 08:50:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62cT5Tz2CJ0GB92CqNWgNMyleyYjlk9w76lBsQmcrK/7dlHEe65RsI1gzM6IVpy7ZMf3g5j X-Received: by 2002:a0c:ab4f:: with SMTP id i15-v6mr6198159qvb.190.1538754607998; Fri, 05 Oct 2018 08:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754607; cv=none; d=google.com; s=arc-20160816; b=flAbxAhAgCykEp3oaU6zIuz3qhRuGHh+EpC3gFydPKVY0hG6sZtZQgHz/flX0Y9L8T GS7YSgrfpXbm9SM8TyF61oJ5L6BRfJqvdmVCiqTzR9OaNGwmOuUCf0654E2K5s64+Iw6 gdk15dfPzV12ueqF3RflbXIqiVgkEA9+OsbLYry/XepLbYXp4feZyJqgZKxZ1Klj1hKH J3ecb0R4ZTlkSizbMQT0MIoz+ACgLdGBxeEiAf0hBeZ7Nz6DEOZySew1q/VbLGqDUFPj XgpUpHoHE01MfcdHTdn+V6CSsBH8klTorBhN1BRoKFejKt0ZlSiVpiR4yl/Bur0diXEs pXCg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=x/pfIyq+zKnBKvaDMmwFphUlcVq1DV3Vl6QOikvINow=; b=hGYKGy2STabAGU0B1mgca39WMoGtB5rzSJFQ4J++5HFmKiMg7jtO4PHbRRoquSboiM TLpuCmeuxIPVGsgaZstwPO3XPnpUTAMv69M6iaSxnwleoVDHtOF+dOsxyBceBV0Kd3e3 l9LkDCjJHbfDDnmLDQIuWdKXa2dDL6z1/bFoITETwom8eh2Iy6axPvda05rYWvfy3ygZ Vkezb7S6lnrg4snPwoAlCGyLsjdrZJ9PmZG+FDT+lxVyurb3kwX9c7jdSvxbWyCxrPWt POw5Ch8qK6Wl7dP6J+hw5Spaa9UpeUcoKcMsw5fa98Bn4WFpwa74bW3ha+3BBiRjxLev b8Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KIdbz9EH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v190-v6si1661094qkd.287.2018.10.05.08.50.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KIdbz9EH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMh-0006Zy-EE for patch@linaro.org; Fri, 05 Oct 2018 11:50:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SM7-0006XZ-5K for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM5-00068t-0g for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:31 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:33760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM1-00060k-DK for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:25 -0400 Received: by mail-wr1-x436.google.com with SMTP id e4-v6so14082237wrs.0 for ; Fri, 05 Oct 2018 08:49:15 -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=x/pfIyq+zKnBKvaDMmwFphUlcVq1DV3Vl6QOikvINow=; b=KIdbz9EHfziSO1zKCZy8ozcrqeA8i6Gpx82vNDmV5SW9gBcGdHR3LTWR0wXzrKCtFO 5psLw1k8Y8auNIQmKIZ39x67ziank6BW2FU7J3CGRO+0hpvbq8ReplVHB/nCZ1mqKBhR 2ADlJ7590i+3BoCfEzEYKD6uzGTAT2wQCxPm4= 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=x/pfIyq+zKnBKvaDMmwFphUlcVq1DV3Vl6QOikvINow=; b=gXkoz3zQqoCRW4UcMCH7cNO3Bsz7BAt18BxOsK6wMarS2YbLiIExc32AXXsdFaejqm H7oqD0BP4KyHqjBuRKaoFO51fZbUvPAkYQJX49dfowOkofYPU/9VSYuEZ0+RF6+jpKUu wjUcL94vT1mDic2s2NEaSsergRx8Ln0kpWdVNa/EFwH7L+Jt/UfZI0V1ilzM0hi8ZuLw NMepCtxJ/LeQhBkqLCo31snWEF1usC/KXtlBQ/k4gQHcOU1FdHWqA09szLSVM3+4/aDB U4jjNcEdGVu6IdYb7nM+YG8WuXqSlWLGeZ6a8yGSyJcrSxRrCIU4qroUZMznmZhMtl5i 5cyg== X-Gm-Message-State: ABuFfoi4lBwUKVWfLKluKx92c8Nr0Dimg5at6rESK2Tw+plK7UwwEj/t 3p5OmZlRKoea2S/KSMPMiPGk7Q== X-Received: by 2002:adf:92e6:: with SMTP id 93-v6mr9253451wrn.124.1538754554525; Fri, 05 Oct 2018 08:49:14 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b5-v6sm6910802wrr.94.2018.10.05.08.49.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0A69A3E05DE; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:53 +0100 Message-Id: <20181005154910.3099-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [RFC PATCH 04/21] trace: enable the exec_tb trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , cota@braap.org, Pavel.Dovgaluk@ispras.ru, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Our performance isn't so critical that we can't spare a simple flag check when we exec a TB considering everything else we check in the outer loop. Signed-off-by: Alex Bennée --- accel/tcg/trace-events | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index c22ad60af7..618cc07738 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -1,10 +1,11 @@ # Trace events for debugging and performance instrumentation -# TCG related tracing (mostly disabled by default) +# TCG related tracing (you still need -d nochain to get a full picture +# as otherwise you'll only see the first TB executed in a chain) # cpu-exec.c -disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR -disable exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR -disable exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" +exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR +exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR +exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" # translate-all.c translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" From patchwork Fri Oct 5 15:48:54 2018 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: 148201 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp617747lji; Fri, 5 Oct 2018 08:55:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UPj7c3YI4eMZVYpBvY0j/BVqn5H95cj3Yw/qb4q88EgHd5ohFeo6FVraHFbtGk1vgQQfs X-Received: by 2002:a0c:d48d:: with SMTP id u13-v6mr9796574qvh.165.1538754934233; Fri, 05 Oct 2018 08:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754934; cv=none; d=google.com; s=arc-20160816; b=CW+AARdUpzEMOtuDJ75B6eWzYYDU121603BaRcNBwZPpqzrrjj4fPGJAyQlGs0cRW+ cPBeSyV26+7ixp+3OTDgJU3eqziXOiL/Bu6ynbJVmO0vb2IAvucVos3/6CeJWT2bq+uu 2Zl1THayw2dD0S0EXjbUtnRfPqt6W7KcV4/05d43ANY35pajSZqkdYAxPJn8g/13+uJX JkXqDeeRN3nddtBAg2bOFOwgONvL286brQbMV/sUbXefs3Pb4Ndl+fU+7hg2ZqXQ/QAa JWv+Bv1jlmDb/sPg3+5d7kWXazEIes0Xmvmjb8izBWbcfiaVGEE7VTHb7Zcqul8QdOdg /xwA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=znBkLF/pP22QwDF/F5LZVNqJW7q436G96f2f5pLIsVw=; b=Pi3ekZinSQ3mG38BgDi0ZOok6FLbC9Cb8wWDFvGOMO8Ta96gtOJjM/BTH9FvS4Cj8n 7951sazYJMj+pw6lDzxG6qxgSVneZDPlGvw5pD8HeWVpwbXJPXjx6B8Es4AK4NHxzX36 WckTHWxHSEMSWPWU6PZVmBWbT6dpmlh2NhTtXWKUdR6rY3IczYOgGW2rO7gmKyu8Hpfx NP43dSqsPrBnJMHZsiXOKTuWmnXriCsodzEOaz9A8WM8m+PO4B+SYyHLmO7VgZW0gnf2 WfbxAYM+Y56q8PZI3+PV+kKj4MUhJajw3vYDV5UE4xLg64aWYswXmOJMhKc7zcpczX/L 010g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gEwoakq/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r1-v6si5775857qtm.169.2018.10.05.08.55.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gEwoakq/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SRx-0005do-HW for patch@linaro.org; Fri, 05 Oct 2018 11:55:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMB-0006am-4Z for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006Dy-AY for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:34 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:52744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00062l-Rn for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wm1-x335.google.com with SMTP id 189-v6so2313796wmw.2 for ; Fri, 05 Oct 2018 08:49:18 -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=znBkLF/pP22QwDF/F5LZVNqJW7q436G96f2f5pLIsVw=; b=gEwoakq/FoTCkskmLvvmmpZBocxLZEh1tpDCuNw16EB/fforN7jnetn6Z1MGv5zHtQ s4jq7NZrSfvLUf0yhZYPq/WUsBE5bYVEZQywIi6IQlgIYmHmnTl9DLEkhgSSvku0PMU8 4+1YLAPjCfczOOAfRRPkc+51FeOp3lU5NwbwU= 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=znBkLF/pP22QwDF/F5LZVNqJW7q436G96f2f5pLIsVw=; b=ABt2PQoR4+jia7RtRbs9+J6zk7u7Ow1t0WLdgdqFHkF2lsZRO10ReipsDNoj8qAZXg 3TcFUCymDKGa0l4eGKbYdNxuMHkgU/TZ1mXeaO2M0tDF+U23nzeXc3+zHv1Ms9KzK6gj 0PBqFBUxY1OH3FsXOyBoe3zQgqYs8W9GacCBZ+DMC6Fp9dy4RFY2gH3fFwJhhlK3I/gq Zd/4kLNJ3p6GMLTJ+wbNNe9dBXuKx6Zq0094wl6GNzGux4YEr+Wbp16ESpZbWPW2r7rG c1SGV/2NpGzmYZUIoDlvGcZ8FF2q9VEOkIwap+8UD4o9iMCv3cDqglWQ5sjKWUdaF7zU LWEQ== X-Gm-Message-State: ABuFfojilid/glhT5LVHXqIn6oChuku8SIJ7Sn8RQZBcrJbxtb01aNm6 9dtyCAnZiehBxkD5BkWiffhg4g== X-Received: by 2002:a1c:2081:: with SMTP id g123-v6mr8228942wmg.144.1538754557842; Fri, 05 Oct 2018 08:49:17 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g3-v6sm8152343wrw.81.2018.10.05.08.49.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1E0AE3E060C; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:54 +0100 Message-Id: <20181005154910.3099-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [RFC PATCH 05/21] trace: keep a count of trace-point hits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When working via the HMP to dynamically enable trace points it would be useful to know if trace points are currently being hit. As the cost is low we can simply increment a counter as we consider if we are going to trace the event. This cannot be precise as we don't take care to use atomic accesses but it is usefully indicative. Signed-off-by: Alex Bennée --- scripts/tracetool/backend/simple.py | 2 ++ trace/event-internal.h | 1 + 2 files changed, 3 insertions(+) -- 2.17.1 diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py index c2fd1c24c4..eaa19a1032 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -81,6 +81,8 @@ def generate_c(event, group): cond = "trace_event_get_state(%s)" % event_id out('', + ' %(event_obj)s.count++;', + '', ' if (!%(cond)s) {', ' return;', ' }', diff --git a/trace/event-internal.h b/trace/event-internal.h index f63500b37e..8ab3a29941 100644 --- a/trace/event-internal.h +++ b/trace/event-internal.h @@ -37,6 +37,7 @@ typedef struct TraceEvent { const char * name; const bool sstate; uint16_t *dstate; + uint64_t count; } TraceEvent; void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state); From patchwork Fri Oct 5 15:48:55 2018 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: 148212 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp628026lji; Fri, 5 Oct 2018 09:04:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TYJK22k3XgnQd9jaB2nHTjJUkes+lH+59mJHc6lGkeu/uB2VdekuN1xYj6ooGbfQKT/ao X-Received: by 2002:a37:8b02:: with SMTP id n2-v6mr9821028qkd.157.1538755466628; Fri, 05 Oct 2018 09:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755466; cv=none; d=google.com; s=arc-20160816; b=QkmjvIrLLkpd87bkk8Ici25bg586NXcw0Num4h28XEdkVPIt2GrN67NkrE1WYC70Hs NeFWmQse++eShX/kVoAyGqmvg4lsWdF5FBsJGsg93YuBxpTRHTn1wr4kvUi6fiVAuA67 ASQNr2n46neBO8OtNP8/nlHWKaF70AwmaG0i5XvWvz8TKjkuz51nfA7OHfq3pOHzj4kF GkTcyFZz4Bad1r3uFytDldpMbNxDldcSQeNzdOqmEiyI6YUxQXY1TkvopcVv/EgoJUqZ vJvH9NJjo+GkyqNCRfpqvcMhRz6iRa8UCMsie/I4t0MEjxLgc7V4QyzgnPJ2r6S212nP 8k7w== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RwClpaYeTsig0GSvhAXa5GcqWP8NR/goGqm80e/f6TM=; b=oi/EwFAdP/0dy3+orEbh5dHzP3d+m0B+MJb6AyX9ZwBm7fgmYgtd0FT5357cKeBCDb GStUztH0HxnfjmwwnTzajVD3Q6onc8mYNPtMNqxDdB1wYZDixQMgknLIl4q/RjujSFua W25MHUyc71KZuYiJrvpHCdhCKhHaAGfC5qBjjVrofd91thWKwX40B/dSLjOV9gMgjr4q r5igZjp3dbBo+g8chGmB46d4kEe3dPgt9O2f2q+K5Z3Lk/fIEtPvy5emaZ2t53t4kPK9 s6J1y2GElNag7XVjaI6MZeoy+BAcXl3ZwhlQcd+3vvZI5dR5F64bpp7BaC/rQzMFwudD H/RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="h5tLD/aD"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e27-v6si876638qtm.339.2018.10.05.09.04.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:04:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="h5tLD/aD"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SaY-0005eN-3H for patch@linaro.org; Fri, 05 Oct 2018 12:04:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMF-0006fK-Es for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006FS-RH for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:36456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM9-00062Q-C4 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wr1-x435.google.com with SMTP id y16so14055736wrw.3 for ; Fri, 05 Oct 2018 08:49:18 -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=RwClpaYeTsig0GSvhAXa5GcqWP8NR/goGqm80e/f6TM=; b=h5tLD/aDMCpZZOhXI+A4YNCoDDWN+YUlpA6QCd7vNJDVByE+836swYrqY5wQ9AN8C2 TQ7TEJKctvgp505HiGSwVmBqcFK79ouMSfe7E67yKsRL7AbQ9Uw+lQcmoyoOxxouUiDY hOh0jXIPset7Z5EMae9djtH38oiroe6VgC+n4= 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=RwClpaYeTsig0GSvhAXa5GcqWP8NR/goGqm80e/f6TM=; b=cj6mxzRiEMzcGq2kiljldEdE/TZMBQtTljuvwB4C1QC5PbHhO47UkCuRmXzdxY+xOx acq7aOzG9+w/7D3zDz8Ikk+zlC3uYoiR9RpxHkanC9bp+UDVnFg4+V9KLQ3Xne9GItHz tMSFRGVd33IFiKlZBk5exhypgu0zvawGlIOf9yM1HFXdtfSfcB9X5T33zxDFQbfJ0Y3o Dj7YbrzupQqRsfgXaQZ7mI+J1wzRFwPXCpjNt/SGO1sAybRjuNBWojBfQId0Lx2gZj3A TTgtzwR3lzZXw5Ynli6WhgT9Yg3bIYaFAZuYK65eQD0cyWQ7S7iTXldQo+aCRDOzgSYE QBgw== X-Gm-Message-State: ABuFfogb+mWMQw7/ubtNm/HOLZKMZJ4w4Ui6qbwtX50QhjybwJzuxToQ IYxBtOEO5le6qIoSPxbDbA3Wpg== X-Received: by 2002:a5d:6883:: with SMTP id h3-v6mr8696067wru.108.1538754556965; Fri, 05 Oct 2018 08:49:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d18-v6sm1617281wmb.33.2018.10.05.08.49.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3386D3E0615; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:55 +0100 Message-Id: <20181005154910.3099-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [RFC PATCH 06/21] trace: show trace point counts in the monitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , Markus Armbruster , "Dr. David Alan Gilbert" , cota@braap.org, Pavel.Dovgaluk@ispras.ru, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now we have counts for each trace point we can expose them in the monitor when the user queries what trace points are available. Signed-off-by: Alex Bennée --- monitor.c | 5 +++-- qapi/trace.json | 3 ++- trace/qmp.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson Reviewed-by: Dr. David Alan Gilbert diff --git a/monitor.c b/monitor.c index c4677b502b..d8229cd2b0 100644 --- a/monitor.c +++ b/monitor.c @@ -1421,9 +1421,10 @@ static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) } for (elem = events; elem != NULL; elem = elem->next) { - monitor_printf(mon, "%s : state %u\n", + monitor_printf(mon, "%s : state %u count %" PRIu64 "\n", elem->value->name, - elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0); + elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0, + elem->value->count); } qapi_free_TraceEventInfoList(events); } diff --git a/qapi/trace.json b/qapi/trace.json index 799b254a18..b9184b0d18 100644 --- a/qapi/trace.json +++ b/qapi/trace.json @@ -33,6 +33,7 @@ # @name: Event name. # @state: Tracing state. # @vcpu: Whether this is a per-vCPU event (since 2.7). +# @count: Current hits on trace-point (since 3.1). # # An event is per-vCPU if it has the "vcpu" property in the "trace-events" # files. @@ -40,7 +41,7 @@ # Since: 2.2 ## { 'struct': 'TraceEventInfo', - 'data': {'name': 'str', 'state': 'TraceEventState', 'vcpu': 'bool'} } + 'data': {'name': 'str', 'state': 'TraceEventState', 'vcpu': 'bool', 'count': 'int' } } ## # @trace-event-get-state: diff --git a/trace/qmp.c b/trace/qmp.c index ea99b00956..cce8198091 100644 --- a/trace/qmp.c +++ b/trace/qmp.c @@ -102,6 +102,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name, elem->value = g_new(TraceEventInfo, 1); elem->value->vcpu = is_vcpu; elem->value->name = g_strdup(trace_event_get_name(ev)); + elem->value->count = ev->count; if (!trace_event_get_state_static(ev)) { elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE; From patchwork Fri Oct 5 15:48:56 2018 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: 148202 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp618236lji; Fri, 5 Oct 2018 08:56:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV622QSV+hu3YVcxHLB3mbajxsdhQSiwa5m/ZCIJnmBraPcsELMGPnXLbHF8gXVv9aHVWM362 X-Received: by 2002:a37:3142:: with SMTP id x63-v6mr9384923qkx.31.1538754963619; Fri, 05 Oct 2018 08:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754963; cv=none; d=google.com; s=arc-20160816; b=FQ5T0Sjqb4yPNEmmt1zdg3Hm+I89+mC/YkTi1lvp6T7MluEyC6H54YjoqAt0jvTHHb QWXUyDGZC6xe8yctZga9hkBL6iWqARKs8LAtp37GU7uWwMsoEu/5r0xO1GqeV58+bDkN rk6nIVau20PK4YqDN8me7BVxmjSm2/CugCK/GnUh8Sn3rla5Ak5cKCDSBl4UpIldw4Gz ETW60l9XEOYV45hOAoh1lC1L8H/FSTvKzbP7yrzo4c31eiEplMEvUfVZ+4G1GvrVfzCt jyasig3nRrUhiWbl2ka3JxVzdEKu9nBDEY5zyxjCLmZJVUXEbFCcHY8i/CjCPqlL/0bL WEmg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bLpx1jC232NRFw8QVwC+x1aV+JfpOl9ciTf5Gki7OCE=; b=YJQz2JDntr5PB+QMXuKlxPQCTD6QPUF8AVirsFNvGN6ULldY6pl2QicSg1fDXoO46x LpZ5ivknc7c+J7yJHAi/Vbrr/xD4sOPPQhtD2PrfbKDKz9fcY0Z+wwDhO9TokZutzlCx 1gB+JCHylt2dU/3CPlO5ZDNqWM2G2AWrddcbutDFOkDkEPvwmE5PaS06OSm7omHd/gHS REWe4YTqlHqmjRnSAnRyAL8aHDPz08eNnG0cZlsAxj9sO7YG2ZYbdwpxZJG5INYc63j/ uGuDw/DeNdFlUN3S0CdOKpgzZP962z+22027yaeoHswjDKyXag3IpL98jiCyq1FaoMb2 jBQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cvOid4wX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o32-v6si757836qtf.75.2018.10.05.08.56.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cvOid4wX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSR-0005kc-1Z for patch@linaro.org; Fri, 05 Oct 2018 11:56:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMB-0006bn-Nw for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006Br-6D for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:35 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:56268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM7-000637-MH for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:31 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 206-v6so2310015wmb.5 for ; Fri, 05 Oct 2018 08:49:19 -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=bLpx1jC232NRFw8QVwC+x1aV+JfpOl9ciTf5Gki7OCE=; b=cvOid4wX/fTBLJzvJSx8sPFwia6ThGsZ9FazJAcox88OS/F9hPgtfVO/hB4hFohDpp A3Mz1AUojFWFRUc+kzgNxkk6Bne/7jLOmKxaIs/j5hstkC40cZix3V1XZSFXrglbuqpl 9Lw/WLPNcpowjcAj3LFPYRJMcl8bkZHlZLt+o= 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=bLpx1jC232NRFw8QVwC+x1aV+JfpOl9ciTf5Gki7OCE=; b=qsVayUJ1YW8JLtGv0iStwtFRHZ/KhFZkWcbxOpAR9X1S3YKDZYHC83j8+z5atYGywE MFWEH3WrRQYM2SM55JeKoLp5KafHtezvEEOr3vnDqypdqOpaDpqQLA1b3iG7tgc0HUvU vsO41/tVXKKiyVY0JXxbCxo31q547LlmCq7MWNca05BlcftpO+atW+qKjIZLc2zny8E3 pHEOe+zfUaKKplR7wx+FhqMGLp3kkGRV7QyEaDRWs4bLieh/SdL141X4G0hRMkp3zvqm 8se4mc1CwHGXxhjiFX44DfWjSgcC9AIiLhuZv5lI38fPurA5x3xMevIAZO+fu2qRyNHm np/Q== X-Gm-Message-State: ABuFfoiuk2XAEzniUbVmTdGeB9FaD/Equfq4MMIMbwzst7nLPcsMxV9i 4Pv2lfuJc4HZlBWf3vJspsc+9A== X-Received: by 2002:a1c:9355:: with SMTP id v82-v6mr8150952wmd.128.1538754558717; Fri, 05 Oct 2018 08:49:18 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v1-v6sm7440400wrd.24.2018.10.05.08.49.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 477A33E0631; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:56 +0100 Message-Id: <20181005154910.3099-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a Subject: [Qemu-devel] [RFC PATCH 07/21] accel/tcg/cputlb: convert tlb_flush debugging into trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , cota@braap.org, Pavel.Dovgaluk@ispras.ru, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Given the range of costs for various SoftMMU TLB operations from deferring work for the currently running vCPU to bring the whole emulated machine to a stop for synchronised updates simple counters are less useful. Instead we log events via the trace infrastructure and we can then post-process the data in a range of ways. tlb_flush_self - the vCPU flushed its own TLB tlb_flush_async_schedule - work was scheduled and the vCPU kicked tlb_flush_synced_schedule - exclusive work was scheduled on a vCPU tlb_flush_work - scheduled work was done tlb_flush_work_complete - scheduled work was completed We can use the difference between the work being scheduled and tlb_flush_work to calculate the latency introduced. Signed-off-by: Alex Bennée --- v2 - add tlb_flush_work_completed - removed tlb_debugs at the same time --- accel/tcg/cputlb.c | 72 ++++++++++++++++++++++++------------------ accel/tcg/trace-events | 16 ++++++++++ 2 files changed, 58 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f4702ce91f..f1d4f7da44 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "cpu.h" +#include "trace.h" #include "exec/exec-all.h" #include "exec/memory.h" #include "exec/address-spaces.h" @@ -138,7 +139,9 @@ static void tlb_flush_nocheck(CPUState *cpu) static void tlb_flush_global_async_work(CPUState *cpu, run_on_cpu_data data) { + trace_tlb_flush_all_work(cpu->cpu_index); tlb_flush_nocheck(cpu); + trace_tlb_flush_work_complete(__LINE__, cpu->cpu_index); } void tlb_flush(CPUState *cpu) @@ -146,17 +149,22 @@ void tlb_flush(CPUState *cpu) if (cpu->created && !qemu_cpu_is_self(cpu)) { if (atomic_mb_read(&cpu->pending_tlb_flush) != ALL_MMUIDX_BITS) { atomic_mb_set(&cpu->pending_tlb_flush, ALL_MMUIDX_BITS); + trace_tlb_flush_async_schedule(__LINE__, current_cpu ? + current_cpu->cpu_index : + cpu->cpu_index, cpu->cpu_index); async_run_on_cpu(cpu, tlb_flush_global_async_work, RUN_ON_CPU_NULL); } } else { - tlb_flush_nocheck(cpu); + trace_tlb_flush_self(__LINE__, cpu->cpu_index); + tlb_flush_global_async_work(cpu, RUN_ON_CPU_NULL); } } void tlb_flush_all_cpus(CPUState *src_cpu) { const run_on_cpu_func fn = tlb_flush_global_async_work; + trace_tlb_flush_async_schedule(__LINE__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_NULL); fn(src_cpu, RUN_ON_CPU_NULL); } @@ -164,6 +172,7 @@ void tlb_flush_all_cpus(CPUState *src_cpu) void tlb_flush_all_cpus_synced(CPUState *src_cpu) { const run_on_cpu_func fn = tlb_flush_global_async_work; + trace_tlb_flush_synced_schedule(__LINE__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_NULL); async_safe_run_on_cpu(src_cpu, fn, RUN_ON_CPU_NULL); } @@ -174,15 +183,12 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) unsigned long mmu_idx_bitmask = data.host_int; int mmu_idx; - assert_cpu_is_self(cpu); + trace_tlb_flush_work(__LINE__, cpu->cpu_index, mmu_idx_bitmask); - tlb_debug("start: mmu_idx:0x%04lx\n", mmu_idx_bitmask); + assert_cpu_is_self(cpu); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { - if (test_bit(mmu_idx, &mmu_idx_bitmask)) { - tlb_debug("%d\n", mmu_idx); - memset(env->tlb_table[mmu_idx], -1, sizeof(env->tlb_table[0])); memset(env->tlb_v_table[mmu_idx], -1, sizeof(env->tlb_v_table[0])); } @@ -190,25 +196,26 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) cpu_tb_jmp_cache_clear(cpu); - tlb_debug("done\n"); + trace_tlb_flush_work_complete(__LINE__, cpu->cpu_index); } void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) { - tlb_debug("mmu_idx: 0x%" PRIx16 "\n", idxmap); - if (!qemu_cpu_is_self(cpu)) { uint16_t pending_flushes = idxmap; pending_flushes &= ~atomic_mb_read(&cpu->pending_tlb_flush); if (pending_flushes) { - tlb_debug("reduced mmu_idx: 0x%" PRIx16 "\n", pending_flushes); + trace_tlb_flush_async_schedule(__LINE__, + current_cpu->cpu_index, + cpu->cpu_index); atomic_or(&cpu->pending_tlb_flush, pending_flushes); async_run_on_cpu(cpu, tlb_flush_by_mmuidx_async_work, RUN_ON_CPU_HOST_INT(pending_flushes)); } } else { + trace_tlb_flush_self(__LINE__, cpu->cpu_index); tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(idxmap)); } @@ -218,7 +225,7 @@ void tlb_flush_by_mmuidx_all_cpus(CPUState *src_cpu, uint16_t idxmap) { const run_on_cpu_func fn = tlb_flush_by_mmuidx_async_work; - tlb_debug("mmu_idx: 0x%"PRIx16"\n", idxmap); + trace_tlb_flush_async_schedule(__LINE__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); fn(src_cpu, RUN_ON_CPU_HOST_INT(idxmap)); @@ -229,7 +236,7 @@ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_cpu, { const run_on_cpu_func fn = tlb_flush_by_mmuidx_async_work; - tlb_debug("mmu_idx: 0x%"PRIx16"\n", idxmap); + trace_tlb_flush_synced_schedule(__LINE__, src_cpu->cpu_index, -1); flush_all_helper(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); async_safe_run_on_cpu(src_cpu, fn, RUN_ON_CPU_HOST_INT(idxmap)); @@ -268,14 +275,10 @@ static void tlb_flush_page_async_work(CPUState *cpu, run_on_cpu_data data) assert_cpu_is_self(cpu); - tlb_debug("page :" TARGET_FMT_lx "\n", addr); + trace_tlb_flush_work(__LINE__, cpu->cpu_index, addr); /* Check if we need to flush due to large pages. */ if ((addr & env->tlb_flush_mask) == env->tlb_flush_addr) { - tlb_debug("forcing full flush (" - TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", - env->tlb_flush_addr, env->tlb_flush_mask); - tlb_flush(cpu); return; } @@ -288,16 +291,19 @@ static void tlb_flush_page_async_work(CPUState *cpu, run_on_cpu_data data) } tb_flush_jmp_cache(cpu, addr); + + trace_tlb_flush_work_complete(__LINE__, cpu->cpu_index); } void tlb_flush_page(CPUState *cpu, target_ulong addr) { - tlb_debug("page :" TARGET_FMT_lx "\n", addr); - if (!qemu_cpu_is_self(cpu)) { + trace_tlb_flush_async_schedule(__LINE__, current_cpu->cpu_index, + cpu->cpu_index); async_run_on_cpu(cpu, tlb_flush_page_async_work, RUN_ON_CPU_TARGET_PTR(addr)); } else { + trace_tlb_flush_self(__LINE__, cpu->cpu_index); tlb_flush_page_async_work(cpu, RUN_ON_CPU_TARGET_PTR(addr)); } } @@ -319,8 +325,7 @@ static void tlb_flush_page_by_mmuidx_async_work(CPUState *cpu, assert_cpu_is_self(cpu); - tlb_debug("page:%d addr:"TARGET_FMT_lx" mmu_idx:0x%lx\n", - page, addr, mmu_idx_bitmap); + trace_tlb_flush_work(__LINE__, cpu->cpu_index, addr_and_mmuidx); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmap)) { @@ -330,6 +335,8 @@ static void tlb_flush_page_by_mmuidx_async_work(CPUState *cpu, } tb_flush_jmp_cache(cpu, addr); + + trace_tlb_flush_work_complete(__LINE__, cpu->cpu_index); } static void tlb_check_page_and_flush_by_mmuidx_async_work(CPUState *cpu, @@ -340,35 +347,36 @@ static void tlb_check_page_and_flush_by_mmuidx_async_work(CPUState *cpu, target_ulong addr = addr_and_mmuidx & TARGET_PAGE_MASK; unsigned long mmu_idx_bitmap = addr_and_mmuidx & ALL_MMUIDX_BITS; - tlb_debug("addr:"TARGET_FMT_lx" mmu_idx: %04lx\n", addr, mmu_idx_bitmap); + trace_tlb_flush_work(__LINE__, cpu->cpu_index, addr_and_mmuidx); /* Check if we need to flush due to large pages. */ if ((addr & env->tlb_flush_mask) == env->tlb_flush_addr) { - tlb_debug("forced full flush (" - TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", - env->tlb_flush_addr, env->tlb_flush_mask); - + trace_tlb_flush_self(__LINE__, cpu->cpu_index); tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(mmu_idx_bitmap)); } else { + trace_tlb_flush_self(__LINE__, cpu->cpu_index); tlb_flush_page_by_mmuidx_async_work(cpu, data); } + + trace_tlb_flush_work_complete(__LINE__, cpu->cpu_index); } void tlb_flush_page_by_mmuidx(CPUState *cpu, target_ulong addr, uint16_t idxmap) { target_ulong addr_and_mmu_idx; - tlb_debug("addr: "TARGET_FMT_lx" mmu_idx:%" PRIx16 "\n", addr, idxmap); - /* This should already be page aligned */ addr_and_mmu_idx = addr & TARGET_PAGE_MASK; addr_and_mmu_idx |= idxmap; if (!qemu_cpu_is_self(cpu)) { + trace_tlb_flush_async_schedule(__LINE__, current_cpu->cpu_index, + cpu->cpu_index); async_run_on_cpu(cpu, tlb_check_page_and_flush_by_mmuidx_async_work, RUN_ON_CPU_TARGET_PTR(addr_and_mmu_idx)); } else { + trace_tlb_flush_self(__LINE__, cpu->cpu_index); tlb_check_page_and_flush_by_mmuidx_async_work( cpu, RUN_ON_CPU_TARGET_PTR(addr_and_mmu_idx)); } @@ -380,7 +388,7 @@ void tlb_flush_page_by_mmuidx_all_cpus(CPUState *src_cpu, target_ulong addr, const run_on_cpu_func fn = tlb_check_page_and_flush_by_mmuidx_async_work; target_ulong addr_and_mmu_idx; - tlb_debug("addr: "TARGET_FMT_lx" mmu_idx:%"PRIx16"\n", addr, idxmap); + trace_tlb_flush_async_schedule(__LINE__, src_cpu->cpu_index, -1); /* This should already be page aligned */ addr_and_mmu_idx = addr & TARGET_PAGE_MASK; @@ -397,7 +405,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *src_cpu, const run_on_cpu_func fn = tlb_check_page_and_flush_by_mmuidx_async_work; target_ulong addr_and_mmu_idx; - tlb_debug("addr: "TARGET_FMT_lx" mmu_idx:%"PRIx16"\n", addr, idxmap); + trace_tlb_flush_synced_schedule(__LINE__, src_cpu->cpu_index, -1); /* This should already be page aligned */ addr_and_mmu_idx = addr & TARGET_PAGE_MASK; @@ -411,6 +419,8 @@ void tlb_flush_page_all_cpus(CPUState *src, target_ulong addr) { const run_on_cpu_func fn = tlb_flush_page_async_work; + trace_tlb_flush_async_schedule(__LINE__, src->cpu_index, -1); + flush_all_helper(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); fn(src, RUN_ON_CPU_TARGET_PTR(addr)); } @@ -420,6 +430,8 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, { const run_on_cpu_func fn = tlb_flush_page_async_work; + trace_tlb_flush_synced_schedule(__LINE__, src->cpu_index, -1); + flush_all_helper(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); async_safe_run_on_cpu(src, fn, RUN_ON_CPU_TARGET_PTR(addr)); } diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index 618cc07738..0d2b1c47ac 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -1,5 +1,21 @@ # Trace events for debugging and performance instrumentation +# cputlb.c - SoftMMU TLB flushes +# +# There a numerous different functions for variations on flushing by +# page/mmuidx and other critera. However we use common events and tag +# them with the appropriate line number in cputlb.c +# +# - setting to=-1 indicates work scheduled on all vCPUs +# +tlb_flush_self(int line, int vcpu) "cputlb.c:%d cpu %d" +tlb_flush_async_schedule(int line, int from, int to) "cputlb.c:%d from_cpu=%d to_cpu=%d" +tlb_flush_synced_schedule(int line, int from, int to) "cputlb.c:%d from_cpu=%d to_cpu=%d" +# The following are the workers, usually running from a async work queue +tlb_flush_all_work(int vcpu) "cpu %d" +tlb_flush_work(int line, int vcpu, unsigned long data) "cputlb.c:%d cpu %d, %lux" +tlb_flush_work_complete(int line, int vcpu) "cputlb.c:%d cpu %d" + # TCG related tracing (you still need -d nochain to get a full picture # as otherwise you'll only see the first TB executed in a chain) # cpu-exec.c From patchwork Fri Oct 5 15:48:57 2018 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: 148200 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp617693lji; Fri, 5 Oct 2018 08:55:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV60tHckxd4vTnsHcSHM0ufkLNlrKVaAntjPJl8Z+G5t3DDpj9aYy3iA+5TryEHUyZbxmoufE X-Received: by 2002:a37:bbc1:: with SMTP id l184-v6mr9747309qkf.111.1538754931314; Fri, 05 Oct 2018 08:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754931; cv=none; d=google.com; s=arc-20160816; b=O4YsE87ujDH6N4iKJOEI3w7mQFPbwPox1ozW6dZ69tW2kcjh8bECydJfPO8Cp4TVE/ EyKjODg413qKxb+K8z5/Wm9KDUQW2sCjIsg8SdIerasFIIaE1ydAfdnW+/vVCDH+9JLG EkzK8sL2EiP0ONJrbJVbKrpt2XkQdF1fCk6dOcbXvC+UdiaovMqQqqxQnc1XU2JP2SG6 yTjekkDQnPw+r9sfLVyQK3lQOjlDH9mea1Yck55tomvlGwYnh+sqkc2z9K4zMz9zcTxt IiWh+cg6pSVfMMWRA+9/xUBqBGeHflwL3+oMaurFZNi49v4ruZHmK+oCj/XCVvLH/e8N P2XA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=YMcYHFt4aPfyzdgpiXu+ijwKbSBzrDfmAxe8xFefia4=; b=egsY5MVRSEuWZMTZu0aQfBGh2x4OIZGAGvzknABkavS3gNP8WCYxKLq0zhdpFtZzea sjtpGBBHuymMvaSwIOrDQr3EPi4B/PI1MN43AcQhKgTFR17KSDjm7XHa38osGO0GC3NM itO/4eFoEjDJ64sxI3zvdhuBAhPprfYSnJ2nicA+nBOk2WUHvANNPIv2k4eYnYEg/9hs AZUX9zC1Gu0d83QqqoaqjW4QvjEk2y6QJ65KaosepjRtofrC+U4ML1YpE0hL5v0TVBxs pawOOLrfgDtnJlAS0tTT1pnWM0cw0rYfhNXNfZ6QDjIFbuAZVOvXKqgdtkuG09Z/ppNx +Ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eKhMWyRi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r2-v6si75511qvc.136.2018.10.05.08.55.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:55:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eKhMWyRi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SRu-0005bV-Og for patch@linaro.org; Fri, 05 Oct 2018 11:55:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SM6-0006XU-St for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM1-000667-Hp for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:29 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:43521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM0-00064G-MV for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:25 -0400 Received: by mail-wr1-x436.google.com with SMTP id n1-v6so14042960wrt.10 for ; Fri, 05 Oct 2018 08:49:20 -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=YMcYHFt4aPfyzdgpiXu+ijwKbSBzrDfmAxe8xFefia4=; b=eKhMWyRiLcRbYth9TNBLks3DT9TdXPh2Rm+XD438+P3Zd+p2kWGkH9VX+IW/cFXJuK kblD3hzdmiRKygJmsEJAcZGo4wUONwwijZMkektrAXVsjuJclDbMK3lV0hcIsnol7P35 xs7hyK080Km22RnEVKQb4yxsbLjeuo30eBsFs= 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=YMcYHFt4aPfyzdgpiXu+ijwKbSBzrDfmAxe8xFefia4=; b=lBjiF0f01TuiLGA/BNkrn45QTFnIBSoVexAjHR++Ucke0f08NuLaBEzUuwdwsAAtpE hSXs/+p1+BZizciGE47q9xyd6V/ZM9Mn1FHe5KhnO65Rd0S4dfmS/uHGNsqVFGe04+DP s7wZmAxUzg1TAZXZAgFctsed8JgBZr//WOcjpOG4pPLYuW4U1/8Xm2eIPDfrtH8vS1yo VbUDwW5FzFvR6kuSeXBPD+hJWcPqayscrQ2KE9seiOVMlNX2gR2zFGKfsXPAoNwZa8oW CRaz2FcikkyEB5LRv+xm/QNob5CgcU1WzPkGru5lGWLPi//XU8xU7c+O0YXp5L37OxJW 3yBg== X-Gm-Message-State: ABuFfohA68qmAjvN/ZkcQo6DoCuDw7xy7V2/nzPRFi+ij3/8Jghe978L VWUYmf01DHouWm3xfUHmJVFNDA== X-Received: by 2002:a5d:618f:: with SMTP id j15-v6mr9459578wru.198.1538754559957; Fri, 05 Oct 2018 08:49:19 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y203-v6sm1499594wmd.1.2018.10.05.08.49.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5B8B83E0632; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:57 +0100 Message-Id: <20181005154910.3099-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [RFC PATCH 08/21] accel/tcg/cputlb: convert remaining tlb_debug() to trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , cota@braap.org, Pavel.Dovgaluk@ispras.ru, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The last remaining user of tlb_debug() is the set page code. We can convert this to a trace event and remove associated logging machinery. The DEBUG_TLB define remains to enable self-check code when debugging. To avoid overly long lines in trace events I've split the event into tlb_set_page and tlb_set_page_attrs. Signed-off-by: Alex Bennée --- accel/tcg/cputlb.c | 27 +++++---------------------- accel/tcg/trace-events | 5 +++++ 2 files changed, 10 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f1d4f7da44..abdc4c5d25 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -34,31 +34,16 @@ #include "exec/helper-proto.h" #include "qemu/atomic.h" -/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ +/* DEBUG_TLB turns on internal self-checks, actions are logged via + * trace-events */ /* #define DEBUG_TLB */ -/* #define DEBUG_TLB_LOG */ #ifdef DEBUG_TLB # define DEBUG_TLB_GATE 1 -# ifdef DEBUG_TLB_LOG -# define DEBUG_TLB_LOG_GATE 1 -# else -# define DEBUG_TLB_LOG_GATE 0 -# endif #else # define DEBUG_TLB_GATE 0 -# define DEBUG_TLB_LOG_GATE 0 #endif -#define tlb_debug(fmt, ...) do { \ - if (DEBUG_TLB_LOG_GATE) { \ - qemu_log_mask(CPU_LOG_MMU, "%s: " fmt, __func__, \ - ## __VA_ARGS__); \ - } else if (DEBUG_TLB_GATE) { \ - fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \ - } \ -} while (0) - #define assert_cpu_is_self(this_cpu) do { \ if (DEBUG_TLB_GATE) { \ g_assert(!cpu->created || qemu_cpu_is_self(cpu)); \ @@ -124,7 +109,6 @@ static void tlb_flush_nocheck(CPUState *cpu) assert_cpu_is_self(cpu); atomic_set(&env->tlb_flush_count, env->tlb_flush_count + 1); - tlb_debug("(count: %zu)\n", tlb_flush_count()); memset(env->tlb_table, -1, sizeof(env->tlb_table)); memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table)); @@ -629,6 +613,9 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, assert_cpu_is_self(cpu); + trace_tlb_set_page(cpu->cpu_index, vaddr, paddr); + trace_tlb_set_page_attrs(*(unsigned int *) &attrs, prot, mmu_idx, size); + if (size < TARGET_PAGE_SIZE) { sz = TARGET_PAGE_SIZE; } else { @@ -644,10 +631,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, &xlat, &sz, attrs, &prot); assert(sz >= TARGET_PAGE_SIZE); - tlb_debug("vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx - " prot=%x idx=%d\n", - vaddr, paddr, prot, mmu_idx); - address = vaddr_page; if (size < TARGET_PAGE_SIZE) { /* diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index 0d2b1c47ac..82705632f2 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -15,6 +15,11 @@ tlb_flush_synced_schedule(int line, int from, int to) "cputlb.c:%d from_cpu=%d t tlb_flush_all_work(int vcpu) "cpu %d" tlb_flush_work(int line, int vcpu, unsigned long data) "cputlb.c:%d cpu %d, %lux" tlb_flush_work_complete(int line, int vcpu) "cputlb.c:%d cpu %d" +# +# TLB entries +# +tlb_set_page(int vcpu, unsigned long vaddr, unsigned long paddr) "cpu:%d vaddr:0x%lx paddr:0x%lx" +tlb_set_page_attrs(unsigned int attrs, int prot, int mmu_idx, int size) "attrs:0x%x prot:0x%x mmu_idx:%d size:%d" # TCG related tracing (you still need -d nochain to get a full picture # as otherwise you'll only see the first TB executed in a chain) From patchwork Fri Oct 5 15:48:58 2018 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: 148208 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp623631lji; Fri, 5 Oct 2018 09:01:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV63jOa6xZl8W4hVyRVsmjcK/BelUl8elOMPWwVDN1k+HBp4bCRjYSIwTymS3+PNCB2u8oLjP X-Received: by 2002:ac8:1a13:: with SMTP id v19-v6mr10289096qtj.183.1538755272189; Fri, 05 Oct 2018 09:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755272; cv=none; d=google.com; s=arc-20160816; b=DcMsBhZw//nv4ZogBLo3eHgSeqEFbBTn6xKEYTLcbLzt/0T3VeO/wnQabe0BbeFEtl xlOYPyOkzWKFCt3/1KBBe4BFpkcz3ajsj9akT/xaU8bnsoNxYVmgEcy3waOXNVseLvQW KFhJPp4zSoBNj7l7X2rojN8VDTHRvf934m6S9qAqJ2L07U5BOpFHBPmgL45B27+H/B6V tXZml632nFCF6Eyh+RZ+eHa6MNuHcB9FG8SlG3cwbgKR2EpU3eEgVBLQmbWI15Qftj0m xqlryT6suVWLOdg+7zAnmEzgAewAlgxR+H9U7QcZurRxmJ1Gmn5HN4acvKzj6J+tFxqC bpBQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=w8gM7VL+X/yF2wQLvNV3izfa85PWeYk7XF0I+Hzlb3g=; b=BF6PtbKtcgGnB8hPNrQrNhRVH2l7JkccsNY2AwsnPv+JBaIi5351tK5ymyxaVEC0vx sirXOkz5HnUJGT6lLJGmAkTakMSGR9kyClDBvYVYCs7oMaoT5y9O0BNsoknN5P1PHsfK lVKQ/1K9PpwSRP98Hpyc+2sucVFlq0WfQxoRGhzDPZYTsb89Npi8BcjPNnV9EyBZ88I+ TiN3vZXVB6ujImP9wjxz+ngJSS+c1FJmp/vHy0XHfhm2nS35O+AxM39+3XFo7VThS1VO qRyOGqnEnWN+4qPHeYUPNHIpO5qzyiUSPTYJzC4wwEn3sffkzAtVZZQ2eISNQK4A2W4J biFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WF9z9ef+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u9-v6si1075190qvr.57.2018.10.05.09.01.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WF9z9ef+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SXP-00032Z-4Y for patch@linaro.org; Fri, 05 Oct 2018 12:01:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMA-0006aK-5P for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006Cb-Ia for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:34 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:43510) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00064t-2g for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: by mail-wr1-x42a.google.com with SMTP id n1-v6so14043033wrt.10 for ; Fri, 05 Oct 2018 08:49:22 -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=w8gM7VL+X/yF2wQLvNV3izfa85PWeYk7XF0I+Hzlb3g=; b=WF9z9ef+0P06Hm6YT5dhQfsN1RdTbFfIOFURg2FSJf7Vb62SHPq3rqlGlv+AmFpiZl Lb5zoYF0R+G/lcBAp9KDxOWTcM4Uf77GNXi9exHKcyEwehjmn7g8WdP7kMLrEJceEBze wmpRkpDrfWLKMcnZHlUdSVG4iHNlljUCg+9Ys= 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=w8gM7VL+X/yF2wQLvNV3izfa85PWeYk7XF0I+Hzlb3g=; b=CCb1P+nQHU1HkgVtiJAT05cIkcfaxwmilWr1ltN6hc5ZpOqtTHev59/8iGaqcXI2mZ Dn3RzraKSQQxc6OBSlTNYpalopBHpIV76qyU816TtldLcYamEW7PLCA6ZD4OVjdo47pe 6zd8HihsGCBFGbVqe8hmixQxU4r5FmTtATIuQNw1ugACQL/+JPg1jKk+7Bp/mEp1+RCm WSXWRFBEe7S5OMGItByvO2FE7XdV5rFpKk/d+S/XeR+dXLU74hRFYDmwbiDa11ebUQI7 DBOtNZH1wdn//dQH+ITmtAW2HGLPQgxzMVDJffKZtD3yEfp6Nl79kmDB3alpThRtr9sZ 8L9A== X-Gm-Message-State: ABuFfoiAZl1q6vNxNZWXKhnAuZz8b9rV5UIRzIiiaBIuKSgv3NEvhEe1 U+2SlnBtx7wITue4gQRp8U3ItA== X-Received: by 2002:a5d:5701:: with SMTP id a1-v6mr9209209wrv.289.1538754561195; Fri, 05 Oct 2018 08:49:21 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 90-v6sm7096634wrg.86.2018.10.05.08.49.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6EE673E0634; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:58 +0100 Message-Id: <20181005154910.3099-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [RFC PATCH 09/21] trace: suppress log output of trace points X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , cota@braap.org, =?utf-8?q?Alex_Be?= =?utf-8?b?bm7DqWU=?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When multiple tracers are enabled and you want to save to binary we shouldn't assume the user also wants to spam the log. They can always override it manually if they want. Signed-off-by: Alex Bennée --- util/log.c | 3 --- vl.c | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/util/log.c b/util/log.c index cc79a146d1..5759bf571f 100644 --- a/util/log.c +++ b/util/log.c @@ -56,9 +56,6 @@ static bool log_uses_own_buffers; void qemu_set_log(int log_flags) { qemu_loglevel = log_flags; -#ifdef CONFIG_TRACE_LOG - qemu_loglevel |= LOG_TRACE; -#endif if (!qemu_logfile && (is_daemonized() ? logfilename != NULL : qemu_loglevel)) { if (logfilename) { diff --git a/vl.c b/vl.c index a867c9c4d9..795e025445 100644 --- a/vl.c +++ b/vl.c @@ -2908,6 +2908,7 @@ int main(int argc, char **argv, char **envp) Error *err = NULL; bool list_data_dirs = false; char *dir, **dirs; + int maybe_log_trace = 0; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; @@ -3985,6 +3986,19 @@ int main(int argc, char **argv, char **envp) } trace_init_file(trace_file); +#if defined(CONFIG_TRACE_SIMPLE) && defined(CONFIG_TRACE_LOG) + /* If the user has both log and simple tracing enabled but hasn't + * defined a binary trace file ensure we enable the right logging + * flags. + */ + if (!trace_file) { + maybe_log_trace = LOG_TRACE; + } +#elif defined CONFIG_TRACE_LOG + /* with just CONFIG_TRACE_LOG we enable unconditionally */ + maybe_log_trace = LOG_TRACE; +#endif + /* Open the logfile at this point and set the log mask if necessary. */ if (log_file) { @@ -3998,9 +4012,9 @@ int main(int argc, char **argv, char **envp) qemu_print_log_usage(stdout); exit(1); } - qemu_set_log(mask); + qemu_set_log(mask | maybe_log_trace); } else { - qemu_set_log(0); + qemu_set_log(maybe_log_trace); } /* add configured firmware directories */ From patchwork Fri Oct 5 15:48:59 2018 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: 148209 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp623650lji; Fri, 5 Oct 2018 09:01:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV63zYYVPxUgTrfobNKOap5pLj8CKMhbAlSfXvXwYyP3veO2t3xMTW/RaMQv+3+tAegze3laz X-Received: by 2002:a37:5ac2:: with SMTP id o185-v6mr9666386qkb.115.1538755273132; Fri, 05 Oct 2018 09:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755273; cv=none; d=google.com; s=arc-20160816; b=x/Vuut/qDb2FVh9B8Io1DaLK9QjPKU2l5rFKk/4QgVRiDe9N3d12IkLMTYcyqpdwuj zD/44dA1vEl8BQcylsOn0t8z82u7XXJT0/qODtN4toEXm/MWQz0expS8EZxat7C4mwOO p1Tzfj1L0dsgZcRPLLnosuFjcJj7GxGKUIc4KjaRXUmR/8cMsrjOKwvQdk6QCwidqZKk csyzWMqYUNG7BzB+30kJ28I1onwFZGjChelMEXra6wMJZH/bZ+aN8zSRbgqNEphrJs37 DXJf24MEFnOsw1hnaHAfFSLySBdGuWtvykAgotlJu7a+yZS+hokYf8eCcgcoxWO1WS93 1f5g== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=SN4jT9SwigzPCMSYeuvVx6C0flfiliEjnaW2VCVhVso=; b=oVou7AW8Pj+HV4fyozBbNFb640pxjx1DDFPbv1ec4TFwz2hAtdKfubJsyPKMHeE7Sb 04b1Kku0M0etHIfJVrc/J0PlehLPqG7U0pTusvQ+lfdeZcCDGpBeHawoUMqegQNQkIPR 7pGlCTQN0wPnt6S1o0fB4VGSLsdNz4nF0MNObmg1eGU2VW6629VpYMWdi6vWyNqhN+qB /kWlr8EQ+zX9rH2DYi89+oJXR2d66BJnp4sU5rgJdc4F8jQ48QaOD54YGTLfF6fWMTTK LPAIKF1yk0RVFS6GuhqIDGo40m4jxf8e6qDtr+CaD8vvZXCYAiMB4WDtBTJrYhYQb68l NNpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KHdnp1LT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m54-v6si1616925qtc.111.2018.10.05.09.01.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KHdnp1LT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SXQ-00033v-46 for patch@linaro.org; Fri, 05 Oct 2018 12:01:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMA-0006ai-LT for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006Cm-MT for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:34 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:32859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-000655-7V for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: by mail-wr1-x444.google.com with SMTP id e4-v6so14082628wrs.0 for ; Fri, 05 Oct 2018 08:49:22 -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=SN4jT9SwigzPCMSYeuvVx6C0flfiliEjnaW2VCVhVso=; b=KHdnp1LTMTlH/B6ZuqS1nuCRC4bk+cSRB5lrOYHnbsFbkixNYZQrxQIPCKBUW1TBl1 1F2V7CUTbECZMFxGkpSsDzBQmvNvrshty0pSS10BoX+KPF3mClMcY2UK2gQAzDeGUkDy HqVMNvOXuPXnNwa9yI08cZtFGXh35j7mF0GIY= 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=SN4jT9SwigzPCMSYeuvVx6C0flfiliEjnaW2VCVhVso=; b=e+zdYVJkrMZnSwMJIUF7UTl6DVwmibeDIS3p+3KVQ0OpHQJyuozpdJDNuezDOSnOLQ NLH3dLMHGgV/gLoTZvTyiZvko6PCh+OhSRKFPPmoFbI9a7iNLJj5JYBhlHTFSPUjWP3M x8Jtl6vXER1MGfaR9QZ5DN7FpNLWZ8zLt6TwEldLAewspUgNzbLKFGB8vsfOIPjf4RH7 A/lldECLTk5JaPxNPZIiOjwVSGeOFWu1lltCv64DgMTobtUkkJ9dlVUkraZ6NIqGSem0 vbkVnyvRB92XohGQWFeUL4WMRB2SVpB2Z93b+YicR3NbvYngGrXns3h1GbQadpbElHwT OU1A== X-Gm-Message-State: ABuFfohXUUJzQwlKHdDcPBpMxfzI7fm9S7I6w4AulGmn39r8BH9il+Je h7xbVBayMy+qJOrf8VtquDKkdA== X-Received: by 2002:a05:6000:111:: with SMTP id o17mr9104672wrx.279.1538754561981; Fri, 05 Oct 2018 08:49:21 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l70-v6sm4876889wma.0.2018.10.05.08.49.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 823FE3E063B; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:48:59 +0100 Message-Id: <20181005154910.3099-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [RFC PATCH 10/21] qom/cpu: add a cpu_exit trace event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru, =?utf-8?q?Andreas_F?= =?utf-8?b?w6RyYmVy?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is useful for tracing cpu_exit events where we signal the CPU to come back to the main loop. Signed-off-by: Alex Bennée --- qom/cpu.c | 3 +++ qom/trace-events | 4 ++++ 2 files changed, 7 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/qom/cpu.c b/qom/cpu.c index 92599f3541..5a77ff6acd 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include "trace.h" #include "qapi/error.h" #include "qemu-common.h" #include "qom/cpu.h" @@ -111,6 +112,8 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) void cpu_exit(CPUState *cpu) { + trace_cpu_exit(cpu, cpu->cpu_index); + atomic_set(&cpu->exit_request, 1); /* Ensure cpu_exec will see the exit request after TCG has exited. */ smp_wmb(); diff --git a/qom/trace-events b/qom/trace-events index 5d86fbf019..1162dd86fe 100644 --- a/qom/trace-events +++ b/qom/trace-events @@ -1,5 +1,9 @@ # See docs/devel/tracing.txt for syntax documentation. +# qom/cpu.c +# cpu_exit events +cpu_exit(void *cpu, int id) "cpu:%p id:%d" + # qom/object.c object_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)" object_class_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)" From patchwork Fri Oct 5 15:49:00 2018 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: 148213 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp628796lji; Fri, 5 Oct 2018 09:05:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV61TlcK613xM1PV47Pas2QxlAXEQLoZ2iT6Ykazv1G7/bHc2YgrZiL33rJAPqgCVFqaGpeiz X-Received: by 2002:ad4:5252:: with SMTP id s18-v6mr9823024qvq.96.1538755501155; Fri, 05 Oct 2018 09:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755501; cv=none; d=google.com; s=arc-20160816; b=LY00Z5+yxcB8nJBm11e5vMax13YnKgXNdXvq5kPf+iW5h9goaQh57qZi6nE7qTxd3L 6KBmgK3PiOyuhX6SUi03fJX6fn4OFgrg9rGUvBCwAsuQPRLeUM3NcK68QUytvL/FnuDB dokgD6sGRcWs1O779PuyZ13tbs+NuEsrvmdU98Ln2igibneFxmJizHrZf/aB+wYM58nf HeUBXAeiZCLjqf3NmKmu7hQFkhkQOW1DuaWEs8Mo/CdQmR/qXmkIZnUjhTGc5UyUMS9T vzaf7UCCUg3an4Aw2qSwLbB2Y3KvZpmJgyWBgTP+aqo6CzhYTuHOQKVRZHFXVQrJSBsS QFiQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=FZGK1pX/0lWiGdcNEkGvPFwvqa10Iu+WxjAabnC7X4I=; b=V+9l/zhYSR8mQ2mgGlqvFkp7KQhZV8MBnFBTSPoXGusMU+tKHqp3gce8IA/kcHar3P 77+lEJbvVXH4RGsi/l0qvl0wSLVtySm4dm4qAE7yeELx9nmvphdE4igcQ0q+dG7pt99Z cB6iIK4L72CDMn2dYLZqHnwkPVhcrxDDn7DOZC89iLA3OnjkhdQm5wX3buuMjrYoAHDk UppTlHN//WeYFVmo9iPZQ6/l7bnQIN/hr8wMU1z+CCcmlzyYPOwPrWqmDNQ4y0ZE9tSO +nKLAofFwCEPmruzQk0pPm4RZpZrCJfTiSA/p42MM9zOpBhaWWyWUipLPKsVpykpBRsS tQFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DHDRI1bv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b190-v6si5865013qkc.304.2018.10.05.09.05.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DHDRI1bv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8Sb6-0005iG-Jf for patch@linaro.org; Fri, 05 Oct 2018 12:05:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMF-0006fL-FE for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006F4-LU for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:52743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM9-00065z-76 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wm1-x333.google.com with SMTP id 189-v6so2314139wmw.2 for ; Fri, 05 Oct 2018 08:49:25 -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=FZGK1pX/0lWiGdcNEkGvPFwvqa10Iu+WxjAabnC7X4I=; b=DHDRI1bvqoNhG6gDIDAvocvXUfX+gpqLHrSXs0aCxH5isB6/yF+FTsj1lV4mySyaDr jO6Yc7vDlfzinKueNEYpqFjxMS9g1nC+9CaO2KvlLEukmJ0RV/vF2qg6VEW9S2xqcEOD ITL33sB/Yw+mhwzv7OA3icK9+WkMNqUTuSUus= 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=FZGK1pX/0lWiGdcNEkGvPFwvqa10Iu+WxjAabnC7X4I=; b=P0NUifSVliPJTq/xceqLVeW5DMXLb+ml2ioT2FCRROg1p+TJbMk5vz3VIavHVwzf7i +URLO/EUX8l1/FDktVtaCACQfUt8r35RgG9U6mY8CJGgcETa//zFljR6cRTvvAD2DpDL iJwqDp1M1DzurnZHDHB158cL2h/npkbgHXLdD8HxqNrwKjkFYfHfOWQTGTPU/qAsV2YW aadWr62crmsWnlhigGru4P7EjJvpYcCyuFULhJsZFnhlcQzTGghLu+qYNacsgeIP3ocf fl3G4vo9tAe+PlLFFe8LmOrvVWLunTKu2zutfaNQUluZXzIRkL4e2EzN5wmDbna8zNsE GnEw== X-Gm-Message-State: ABuFfogZACwubf4tuSj5morGUH3FSDoKDYOZd351jH7nlasZ2cngoLpf 2/eJVN3ArD80hlNtEgNVUmXV3w== X-Received: by 2002:a1c:845:: with SMTP id 66-v6mr8845296wmi.61.1538754564760; Fri, 05 Oct 2018 08:49:24 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h82-v6sm1675625wmf.14.2018.10.05.08.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:20 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 95B9F3E064A; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:00 +0100 Message-Id: <20181005154910.3099-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [RFC PATCH 11/21] trace: expose a plugin fn pointer in TraceEvent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We'll need somewhere to stash this later. It's up to the generated code to do the funky casting to what it really is. Signed-off-by: Alex Bennée --- trace/control-internal.h | 6 ++++++ trace/event-internal.h | 3 +++ 2 files changed, 9 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/trace/control-internal.h b/trace/control-internal.h index c7fbe2d3bf..d734576948 100644 --- a/trace/control-internal.h +++ b/trace/control-internal.h @@ -80,6 +80,12 @@ static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id); } +#ifdef CONFIG_TRACE_PLUGIN +static inline uintptr_t trace_event_get_plugin(TraceEvent *ev) +{ + return ev->plugin; +} +#endif void trace_event_register_group(TraceEvent **events); diff --git a/trace/event-internal.h b/trace/event-internal.h index 8ab3a29941..3895ee9883 100644 --- a/trace/event-internal.h +++ b/trace/event-internal.h @@ -38,6 +38,9 @@ typedef struct TraceEvent { const bool sstate; uint16_t *dstate; uint64_t count; +#ifdef CONFIG_TRACE_PLUGIN + uintptr_t plugin; +#endif } TraceEvent; void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state); From patchwork Fri Oct 5 15:49:01 2018 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: 148198 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp615382lji; Fri, 5 Oct 2018 08:53:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62nShdm1vBNSAUolz9dtwivW4sdTBVDQr57CcW5XR1hQ1UwydhX4jxTCHO3+A+CiXjHNFBp X-Received: by 2002:aed:3c93:: with SMTP id d19-v6mr9873451qtf.5.1538754788152; Fri, 05 Oct 2018 08:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754788; cv=none; d=google.com; s=arc-20160816; b=ut/oV+wXp4XBXBtYs0jOacikKV0FSS8c8pHtAzQD5beJKqfUZ4FazsfG+7Xk2+GDCH uCa/lUfMqJ0inZa4zy0qk53RaLKqJxGD27NQ23ezTyD7GnI02vSOL6QSpLMIrtlZyAnf 6MoXa0uHXwQESwe8TKkIr0yaJSoSO9bZ7Q5S0aGS2P6yLK/eOzcL1Na3qz3UvuupdGrV bf6Y0cu/k79qLVW7yuJHuHkI8QiEbH6RWC4lTSvKgE9vVfQf4yphllFpu2rXdr5eOxv6 tDbyuk+Kgb+tKfhJLHilUO8L/SofnSIEUCAohBZ9YZpIXYfZCRJ4fzU3oWKkW7Pbm5qo /BDQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=GjGP0EM9heu1MZGg3W+sxz/ZmZ1i65YzU86L6brQu3Q=; b=fmZkaTnZIQOSgsXNgiBFX7W4XHIl/Ly/y7UamOakoYS8NfCcY0d8K/tdYiDVU+3v0e /0rsRTc34ai+kj6Zy7tRufnCccXFE2EJH3HPn2CoTgrTwMTXuSidp/RFCkL2l9DuEc/+ km8lx4YEVp9Wnxh4YnUqXXNLnsRnH6KcZAQq+9NtSOvVrIscvaaDTfkDZWaDc9fa1TnK eCf0BWya2Cr877fhRkS5drsYKoiSabmkdCOYYk+VU4/o+fKxBCnHlDnR7c8OBQO2AlQd ZzdLBBPK0NKI8mx6DoQxmuj+Vdo5p1K2a7MZWo2DWgVJjJwRbo2ro79alozbYBY3yHUg unBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fwWPi6LD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d2-v6si5893170qtk.102.2018.10.05.08.53.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:53:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fwWPi6LD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SPb-0002JT-J2 for patch@linaro.org; Fri, 05 Oct 2018 11:53:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SM9-0006ZA-CU for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006Bd-5R for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:43517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM7-00065p-NX for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:31 -0400 Received: by mail-wr1-x431.google.com with SMTP id n1-v6so14043191wrt.10 for ; Fri, 05 Oct 2018 08:49:24 -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=GjGP0EM9heu1MZGg3W+sxz/ZmZ1i65YzU86L6brQu3Q=; b=fwWPi6LDvSAQmqTvmDviweUG4sArJknVKmbELUmnuUOikWDuAeEnA2Hb7DdQT+8+oA 8a9Gpl25vEA5YWsOOmkb09+obVhptICTII2wZu8u5+IW2xOy9Bh5cQjMNmGB8mBzukbZ zSH1ZehtXTw8UQhDCNN2ARGOAH3pgOjlkVRyg= 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=GjGP0EM9heu1MZGg3W+sxz/ZmZ1i65YzU86L6brQu3Q=; b=fFsVPU6COKWhcgM+pXgmAIjARYEwzvQtxwa8qWAWQP/TM85ludHiX762HROcInmVNp f9uBu6ZBpIIkBp4NNAAT9OtLBmer+B1qean9eR+uqtoYl+rOTQLa2suc4YeBRSWZCc12 lLwQCC/t3bFUkWqQn5ACCtBMLbVTP2R7SCOOlzN113tUUCsP0iuzw39yOx/G1OI6gB2c FdA1b6ag2LrzbUrcX9ADjIMQPG6YfQfLKxmLdRowDHZoN5LJDZkoln8z6sQ/TJ1xQcts wEgpMkGXlt97kUx9W4IuYg7vf1cUiPM1kE+O7ca7WbdyOfBi6byR73e45IGZ4J5+LP+P EkSw== X-Gm-Message-State: ABuFfoiqubrgTR9UBpdWVCLF+JRESuoh0DpUGcKDm910C+aWjn14n5FC Qr2fJq7serKqJ+fgWEBD+LJhqw== X-Received: by 2002:adf:ab13:: with SMTP id q19-v6mr8426790wrc.62.1538754563928; Fri, 05 Oct 2018 08:49:23 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y125-v6sm1716470wme.12.2018.10.05.08.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:19 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A7B213E069A; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:01 +0100 Message-Id: <20181005154910.3099-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [RFC PATCH 12/21] configure: expose a plugin to the trace-backends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We also enable gmodule support for use with plugins. Signed-off-by: Alex Bennée --- configure | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/configure b/configure index f3d4b799a5..87d71bbdcd 100755 --- a/configure +++ b/configure @@ -3513,6 +3513,9 @@ glib_modules=gthread-2.0 if test "$modules" = yes; then glib_modules="$glib_modules gmodule-export-2.0" fi +if have_backend "plugin"; then + glib_modules="$glib_modules gmodule-2.0" +fi # This workaround is required due to a bug in pkg-config file for glib as it # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static @@ -6793,6 +6796,9 @@ if have_backend "syslog"; then feature_not_found "syslog(trace backend)" "syslog not available" fi fi +if have_backend "plugin"; then + echo "CONFIG_TRACE_PLUGIN=y" >> $config_host_mak +fi echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak if test "$rdma" = "yes" ; then From patchwork Fri Oct 5 15:49:02 2018 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: 148195 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp612083lji; Fri, 5 Oct 2018 08:50:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV61FdmrAt/S9pgsms7ayQpFIA52jyNKOu9H3p3Y+51EVoi587D4o/YSccMRDOBudMrtKwubA X-Received: by 2002:a37:35c8:: with SMTP id c191-v6mr9743528qka.100.1538754612810; Fri, 05 Oct 2018 08:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754612; cv=none; d=google.com; s=arc-20160816; b=exB3FS/spzVkZCI7BK41Z8XaZ2ItmRi2p2MEvxF3g4A55o4U9JZlW8ByVswnJWrg/p oodQBWEF37/E3yW00Sjm+XKoTtR0JxIxaXDWE/NKsGuYzwfaG7tceqC0L8N15vHTMf22 IgR/81AAmI5Y12O3Vg6x/mIHvPMvxrkxF7xmZs0K7hQVY/e/iJm9JzaxS7qxxPhiFElf tFanSxezN6qoa1PcxEZyH/jb6E172FCURlqx0syLSRKUPsmmV5iuXUCx1sCoeJs9VIGN 7peGzsMok2brNuAlJ1MYhaint8yforxP5sn/Ip/BrdIl2rRNJ1FU+l8wd4+EDFnVIwjZ +RfQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=i1vJunQw7MNq50ByKJBr61IK9UuEhy5zaG0SGPvH7PNfDz7gqmu4jZwym7r77w2U+v 9SYYNcZQU5YLeweaC5f2iew7AJaw+lh0V3ZYjKlbp6LJgmJxdaZjrASHMgc2SNdYjqPe UsI8kTRAz4XHultkh1EWRp5Cq0qFknzzHmcD6gNQnZiaJA02mqoKjAotiNak+/vDGyut BHAQGg8+oaTBoXVSq1SbScq7kCR1IZ8YSkDZDteu7f/1acYpQ6tVbbqzR8GMGYDJJRlZ PDogfT5SVtCixUoesqBdPm0ga4a2ivjBuPuhiwfie8lUEVefuVDruKHwGyJdcd0QgF4f x6dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SYRxlTRo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z127-v6si5722963qke.342.2018.10.05.08.50.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:50:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SYRxlTRo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMm-0006m1-7i for patch@linaro.org; Fri, 05 Oct 2018 11:50:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMB-0006b4-8W for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006E4-Bj for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:35 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:41147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00067X-No for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wr1-x431.google.com with SMTP id x12-v6so14041395wru.8 for ; Fri, 05 Oct 2018 08:49:27 -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=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=SYRxlTRoK/I3rjb2TR75agKeR83w4siHPLDgff4Qr+W95LcCHTWM9FYNe9JHSMjOEj p9JHxjf7kbUCkBUJb487jdETG25FqSytUBsn2DrAc5iM5ynMU1JU+PY9itbcyxT0N8dF KtqjxdGtm9FuMVET19SQ/tX1+bh2h6bwrq8Dw= 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=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=SrudnCgG9R3T5kWX9uAbLmHVwwTTn1ymy3AgX1iKMbmSBZ6H6Vlhg+Fig1fjV5M90+ 759Lu4cdYPYnfyGGAHIfmnaudhu6/Q39aucJGDozhNlTsaXh6hZSQZsv2hN1b0pnM6xd 0HtOgTPHtrKeFxj/BZykoFVaaWxFRbVdwD3wxxmQR7EOQdiDRlerXHYUTSAGBx99i8nc z+gU2Km7WTFKpu0GjO0RwQ7czfaFivdybT/ZPgMrzWyccmRSgMTTMrm26XdDJ4608iZD MED95NKK8eTCkAFSnh3lUEVTLrC4JHMHqdFf+gIHsRWTdNZBnLNrfvfnroyg/bOVQXAO 7s0g== X-Gm-Message-State: ABuFfogg4vEA02MP8TaLBnBlSyrusNc0K5QPp+lCaqitcWYH9mYHOWNJ iP3PM35mNK5F4pq0ABGMz0gJug== X-Received: by 2002:adf:f50b:: with SMTP id q11-v6mr8848542wro.246.1538754566687; Fri, 05 Oct 2018 08:49:26 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w4-v6sm15206221wra.83.2018.10.05.08.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B9CB23E06DC; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:02 +0100 Message-Id: <20181005154910.3099-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [RFC PATCH 13/21] tracetool: generate plugin snippets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- scripts/tracetool/backend/plugin.py | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 scripts/tracetool/backend/plugin.py -- 2.17.1 diff --git a/scripts/tracetool/backend/plugin.py b/scripts/tracetool/backend/plugin.py new file mode 100644 index 0000000000..d96b2df00a --- /dev/null +++ b/scripts/tracetool/backend/plugin.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Plugin backend. +""" + +__author__ = "Alex Bennée " +__copyright__ = "Copyright 2018, Alex Bennée " +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Alex Bennée" +__email__ = "alex.bennee@linaro.org" + + +from tracetool import out + + +PUBLIC = True + + +def generate_h_begin(events, group): + for event in events: + # prototype for plugin event + out('bool _plugin_%(api)s(%(args)s);', + api=event.api(), + args=event.args) + # prototype for plugin fn + out("typedef bool (* _plugin_%(api)s_fn)(%(args)s);", + api=event.api(), + args=event.args) + + +def generate_h(event, group): + out(' if (!_plugin_%(api)s(%(args)s)) {', + ' return;', + ' };', + api=event.api(), + args=", ".join(event.args.names())) + +def generate_c_begin(events, group): + out('#include "qemu/osdep.h"', + '#include "trace/control.h"', + '') + +def generate_c(event, group): + out('bool _plugin_%(api)s(%(args)s)', + '{', + api=event.api(), + args=event.args) + + event_id = 'TRACE_' + event.name.upper() + cond = "trace_event_get_state(%s)" % event_id + + # Forst the pre-amble, bail early if the event is not enabled and + # if it is but no plugin is enabled let the reset of the events proceed. + + out('', + ' if (!%(cond)s) {', + ' return false;', + ' }', + '', + ' uintptr_t fp = trace_event_get_plugin(&_%(event)s_EVENT);', + ' if (!fp) {', + ' return true;', + ' }', + '', + cond=cond, + event=event_id) + + # We need to construct cast to the correct fn pointer to now call the plugin + + out('', + ' _plugin_%(api)s_fn plug_fn = (_plugin_%(api)s_fn) fp;', + ' return plug_fn(%(names)s);', + '}', + '', + api=event.api(), + names=", ".join(event.args.names())) From patchwork Fri Oct 5 15:49:03 2018 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: 148206 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp620578lji; Fri, 5 Oct 2018 08:58:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Dhmis7dQODip6u1s9g9ygbsfBQqUeDpebetdhnawmWF3xZocfUQA2LX+UCiaZuFLzDDLs X-Received: by 2002:ac8:2b78:: with SMTP id 53-v6mr10255213qtv.255.1538755103592; Fri, 05 Oct 2018 08:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755103; cv=none; d=google.com; s=arc-20160816; b=AfDwxVB+U8W3yfMg2eyIPzyIKHjlRKcjYNXn9MZOlVvmCShzvgVsMexCg1u8lIXZ/f Nb07aKiq9vE9NdhZdYWQqFD8Rj+L94Vp3+SoSEOP45uS6Z7bW7IZ1QF5bsOc5hFnGy6K ufn5iGPR8rEbD7ezSXvNsIeF2uo3r75e1XBtFrcPmXLPJjoiloyAL/ONKVNZlF5f28oA DKPBIzu6l3oB7uvOThuuJu37cIAWGvzDZrBGdnZpwOivX504sKd0XfUHSXBzf/VKQDHi 1TUejnWQCV01/k43s8PrzAO9t7Y8P8ECd8P0XqjyPxcqZRfDp+99Xy3p+D8WLqVEzxp4 7trA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=CSyyGIpdIo/1QHsx/c6muSCJsLQTSUi76xVf3LhjqPQ=; b=zw7L9anIQas5wpAtfQw/84JmGp6HPVqdIX48/b55y3qf6ry7GiChaG2Tnd+Pp/kA09 USmT2IKxGMYHiwm2w+NZiB25fZxCajydpg4DAMX/yxlUb73R7wiFNZQZDVxyZZLiYjmq KpiI9bjsCLUfEkYOPRAwyzRgM0I12Xndb8yw4OtVlMop6JCr6QQ6qzGwgcts607RXzqY k2nSBK1OmS6eI+pJ/NT7k17BXhVJPltwXluWlf5oiQjAaN8lsCjwuLkzgDZOD0rRTDJQ WcG6jYuGMthxhezAoh70cop8+w8cZjrCgMk0kAZw1KInfxTBh0RWMzvEQUCHqI+wb+dm Hiqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GZls9IzR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y35-v6si1044504qty.161.2018.10.05.08.58.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GZls9IzR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SUg-0000XH-PC for patch@linaro.org; Fri, 05 Oct 2018 11:58:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMF-0006fM-Fj for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006Ft-Uw for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM9-00066X-AT for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wm1-x343.google.com with SMTP id 143-v6so2304750wmf.1 for ; Fri, 05 Oct 2018 08:49:26 -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=CSyyGIpdIo/1QHsx/c6muSCJsLQTSUi76xVf3LhjqPQ=; b=GZls9IzR1pQJDLPov7ccz4StWutX1Hqea/jlRyIwJjmFhxzyEa4/8yq6C/kutzXzNS W8whXd8n37bpXdGFw2RWmByPcpauXAHLCJkbfScYRnpBRswT7UPnYrkefSIL9twhAHhW osj5z8DQ0XvcfV9d+SlCkbcprqX8f7lkmW8lw= 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=CSyyGIpdIo/1QHsx/c6muSCJsLQTSUi76xVf3LhjqPQ=; b=rjgcmEbVlE1oAYaTbVamEFpTdN9fPa9Efu52CFQjWqMPDUxRk5/3PmJjpIHQi/J3ge MriR5rEHeo7IDhq6Z4uCfIN69/s/1tDhQOtuqYduQW2EhbgxfBHfiJpOXuQNeS/7KfX5 Hq94ioblUtf5jCxBJU+9LCsit4xugQNXwYY8hpoQFuden8qTbYeCQNKLYVYgRc+fA+by v5mMYv1NUtL7LBUxSGzVssb+i219ZQ6y/b7SL2Dr0HON/6XqE76IuhhWlp13Qu/BAfqq ryCnIrZR+N7Z7nzBUII9EQlWATfRcqjJS703nGkX8B2zmSlhuIan4wf7vcjkcw7akxke ElsA== X-Gm-Message-State: ABuFfojcnYhbW3amn1SZlVmavrv3j9m0Ekuhm++mvNg6fqmPXrVhLE1h ir/Hdebp2H1BvdFauAbp2RwScg== X-Received: by 2002:a1c:9fd5:: with SMTP id i204-v6mr8596286wme.88.1538754565876; Fri, 05 Oct 2018 08:49:25 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u191-v6sm2598725wmd.31.2018.10.05.08.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D316B3E072C; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:03 +0100 Message-Id: <20181005154910.3099-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [RFC PATCH 14/21] trace: add support for plugin infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel.Dovgaluk@ispras.ru, cota@braap.org, Stefan Hajnoczi , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk This patch adds support for dynamically loaded plugins. Every plugin is a dynamic library with a set of optional exported functions that will be called from QEMU. Signed-off-by: Pavel Dovgalyuk [AJB: moved to using trace point API] Signed-off-by: Alex Bennée --- ajb - moved to tracepoint interface (bind_to_tracepoints) - now in trace/ and include/plugins/ --- include/plugins/plugins.h | 14 ++++ include/qemu/plugins.h | 18 +++++ qemu-options.hx | 10 +++ trace/Makefile.objs | 1 + trace/plugins.c | 139 ++++++++++++++++++++++++++++++++++++++ vl.c | 8 +++ 6 files changed, 190 insertions(+) create mode 100644 include/plugins/plugins.h create mode 100644 include/qemu/plugins.h create mode 100644 trace/plugins.c -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/include/plugins/plugins.h b/include/plugins/plugins.h new file mode 100644 index 0000000000..54ac53cb32 --- /dev/null +++ b/include/plugins/plugins.h @@ -0,0 +1,14 @@ +#ifndef PLUGINS_INTERFACE_H +#define PLUGINS_INTERFACE_H + +#include +#include + +/* Mandatory Plugin interfaces */ + +bool plugin_init(const char *args); +char *plugin_status(void); + +/* Other optional hooks are defined by available trace-points */ + +#endif /* PLUGINS_INTERFACE_H */ diff --git a/include/qemu/plugins.h b/include/qemu/plugins.h new file mode 100644 index 0000000000..c86bb7ae67 --- /dev/null +++ b/include/qemu/plugins.h @@ -0,0 +1,18 @@ +#ifndef PLUGINS_H +#define PLUGINS_H + +#ifdef CONFIG_TRACE_PLUGIN + +void qemu_plugin_parse_cmd_args(const char *optarg); +void qemu_plugin_load(const char *filename, const char *args); +void qemu_plugins_init(void); + +#else + +static inline void qemu_plugin_parse_cmd_args(const char *optarg) { } +static inline void qemu_plugin_load(const char *filename, const char *args) { } +static inline void qemu_plugins_init(void) { } + +#endif + +#endif /* PLUGINS_H */ diff --git a/qemu-options.hx b/qemu-options.hx index f139459e80..87206dd79f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3892,6 +3892,16 @@ STEXI Enable synchronization profiling. ETEXI +#ifdef CONFIG_TRACE_PLUGIN +DEF("plugin", HAS_ARG, QEMU_OPTION_plugin, \ + "-plugin file=[,args=] load plugin with \n", QEMU_ARCH_ALL) +STEXI +@item -plugin file=@var{file}[,args=@var{args}] +@findex -plugin +Load @var{file} plugin passing @var{args} arguments. +ETEXI +#endif + STEXI @end table ETEXI diff --git a/trace/Makefile.objs b/trace/Makefile.objs index afd571c3ec..4977f654a5 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -54,6 +54,7 @@ $(obj)/generated-tcg-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/ util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o +util-obj-$(CONFIG_TRACE_PLUGIN) += plugins.o util-obj-y += control.o target-obj-y += control-target.o util-obj-y += qmp.o diff --git a/trace/plugins.c b/trace/plugins.c new file mode 100644 index 0000000000..25aec2ff70 --- /dev/null +++ b/trace/plugins.c @@ -0,0 +1,139 @@ +/* + * Plugin Support + * + * + * Copyright (c) 2018 Pavel Dovgalyuk + * Copyright (c) 2018 Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include +#include "qemu-common.h" +#include "qemu/error-report.h" +#include "qemu/plugins.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "trace/control.h" + +typedef bool (*PluginInitFunc)(const char *); +typedef char * (*PluginStatusFunc)(void); + +typedef struct QemuPluginInfo { + const char *filename; + const char *args; + GModule *g_module; + + PluginInitFunc init; + PluginStatusFunc status; + + GPtrArray *events; + + QLIST_ENTRY(QemuPluginInfo) next; +} QemuPluginInfo; + +static QLIST_HEAD(, QemuPluginInfo) qemu_plugins + = QLIST_HEAD_INITIALIZER(qemu_plugins); + +static QemuOptsList qemu_plugin_opts = { + .name = "plugin", + .head = QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head), + .desc = { + { + .name = "file", + .type = QEMU_OPT_STRING, + },{ + .name = "args", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + +void qemu_plugin_parse_cmd_args(const char *optarg) +{ + QemuOpts *opts = qemu_opts_parse_noisily(&qemu_plugin_opts, optarg, false); + qemu_plugin_load(qemu_opt_get(opts, "file"), + qemu_opt_get(opts, "args")); +} + +static int bind_to_tracepoints(GModule *g_module, GPtrArray *events) +{ + int count = 0; + TraceEventIter iter; + TraceEvent *ev; + + trace_event_iter_init(&iter, "*"); + while ((ev = trace_event_iter_next(&iter)) != NULL) { + const char *name = trace_event_get_name(ev); + gpointer fn; + + if (g_module_symbol(g_module, name, &fn)) { + ev->plugin = (uintptr_t) fn; + trace_event_set_state_dynamic(ev, true); + count++; + } + } + + return count; +} + +void qemu_plugin_load(const char *filename, const char *args) +{ + GModule *g_module; + QemuPluginInfo *info = NULL; + if (!filename) { + error_report("plugin name was not specified"); + return; + } + g_module = g_module_open(filename, + G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); + if (!g_module) { + error_report("can't load plugin '%s'", filename); + return; + } + info = g_new0(QemuPluginInfo, 1); + info->filename = g_strdup(filename); + info->g_module = g_module; + + if (!g_module_symbol(g_module, "plugin_init", + (gpointer *) &info->init)) { + error_report("all plugins must provide a plugin_init hook"); + return; + } + + if (!g_module_symbol(g_module, "plugin_status", + (gpointer *) &info->status)) { + error_report("all plugins must provide a plugin_status hook"); + return; + } + + /* OK we can now see how many events might have bindings */ + info->events = g_ptr_array_new(); + + if (bind_to_tracepoints(g_module, info->events) < 0) { + error_report("failed to bind any events"); + return; + } + + /* Save the args, we will initialise later on once everything is + set up */ + if (args) { + info->args = g_strdup(args); + } + + QLIST_INSERT_HEAD(&qemu_plugins, info, next); + + return; +} + +void qemu_plugins_init(void) +{ + QemuPluginInfo *info; + QLIST_FOREACH(info, &qemu_plugins, next) { + if (info->init) { + info->init(info->args); + } + } +} diff --git a/vl.c b/vl.c index 795e025445..b46ef5032f 100644 --- a/vl.c +++ b/vl.c @@ -130,6 +130,7 @@ int main(int argc, char **argv) #include "qapi/qapi-commands-run-state.h" #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" +#include "qemu/plugins.h" #define MAX_VIRTIO_CONSOLES 1 @@ -3884,6 +3885,11 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_enable_sync_profile: qsp_enable(); break; +#ifdef CONFIG_TRACE_PLUGIN + case QEMU_OPTION_plugin: + qemu_plugin_parse_cmd_args(optarg); + break; +#endif case QEMU_OPTION_nouserconfig: /* Nothing to be parsed here. Especially, do not error out below. */ break; @@ -4449,6 +4455,8 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); + qemu_plugins_init(); + /* do monitor/qmp handling at preconfig state if requested */ main_loop(); From patchwork Fri Oct 5 15:49:04 2018 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: 148207 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp623483lji; Fri, 5 Oct 2018 09:01:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV601b6ucEH1ZIArVOKUmOBmZ33Fizdk/LWuCDAQG9VLuqcrbdFZ7ibcaK/HstEVtGRp80aEc X-Received: by 2002:a37:39c8:: with SMTP id g191-v6mr9177841qka.289.1538755265517; Fri, 05 Oct 2018 09:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755265; cv=none; d=google.com; s=arc-20160816; b=Y3dcD1pQ8jXEy6bI6FKPBpKNXubHBrcptKXS9xZtfGH3/jbuptVnzO5bZNLwxBCqxf zbFgAJDvDQJQuy38JUcNj2PoCNJ+s+MKFSc1VPu2NBD+T6pwxB+v0k07dwsr0aI6HCBA bktJZJBfMSME1a9xkUZiDgZZbgAK2aqg8KdbyUa5DO2XwgVUsw/pr3/TN1Ab0wp3OsTM G/FZk8ZeSc5/bskg5dsd9W7q4X6N3ePs2STXqg9Jm/T+RSd9uPAY1x3pbjyJM9l18UFC jKOmvh99YEtmr1OriwPbRYioXpaeLsVCBUGBarYlw5OJPxCSo9Veo8dQLqXk6qs9ea5T ZsrA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=pTezd02bQSxmcq683cGX0+CsPAikNVdIw3kttYYPxIE=; b=CWl+jm8enwPK9kd8By8YprQC0PgcqGPJJ10YxULn1h6tjCqxSgiJeeTwspCVbB3lr9 i/BeB+Bgo1Jm/JmvZcdzsDGAtCdHLvAYt39r146B7IUA1UFVgmsgqAh25Unj33258vwT 0ZQjJElwA4/b3HtsdRUtfTJhhmdSdqCUCPoMosU96kECCQAeHBlTMj5kCdJz/MDkwQZE XyrgwfNSS1nzVBj2ZGJ4Ala3COE5rlD3VV0DZTNGlcgvtruINnDgMpdQdQMru0w/e/fJ bgofgaBffY3gDdwsxgBih/FJ+ReRhx3it73DrtmGzGqhNjsZ6UWUcaB/ElCUxhIqHfdA lXaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iy86TiQV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p59-v6si1094898qtd.270.2018.10.05.09.01.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iy86TiQV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SXI-0002WD-9Q for patch@linaro.org; Fri, 05 Oct 2018 12:01:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSH-0005zp-84 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SSC-0004eb-Ni for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:53 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:53776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SSC-0004eN-Fz for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:48 -0400 Received: by mail-wm1-x32d.google.com with SMTP id b19-v6so2333565wme.3 for ; Fri, 05 Oct 2018 08:55:48 -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=pTezd02bQSxmcq683cGX0+CsPAikNVdIw3kttYYPxIE=; b=iy86TiQVz+DaWLI19VSwghy2dFBP7DQVGAoR6XF0e2TOS62mD9dLmwpWf7qH6wZHJQ N8D9uxWyeNY9a6E1eY+arFXIccdMnBp6GJw/1na5rQn1ef0FJJ+yEuI9azSfrR7ERRYj B5VKEQoD3wi2GT+H9VzmIP8gwxjeXiBlyUw5Y= 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=pTezd02bQSxmcq683cGX0+CsPAikNVdIw3kttYYPxIE=; b=S+sqbgSdyBkZTCxVl+b8v4UjgEUMh6aBoKErGWTAgHzTup73M5wtQ0+1O9Jge6jDQm I/7WzqlS/23sk15xeX7o56Sl6Lxkv5Z9pa8aQX8QrqW6GcbBI6H+RcZBOznfdPA1R02H xUYVP8d2xryyqOTa/EO3usKwyNYvf/gM+53Fqo4/UgYpfDpPfp5KB7V5sYOGKWlhxJ0w 6Zpldu0S/jR8OaClYCCRNyJdrnHulXEQsglkE7+FmTW5LjnRjtqqyhCZVpAPqjfHTufz UvDKSrhQx3vxv4QHi4rk22XlYF45Sr4B+GlQfK+5LuTuAHWY4DMchOdnBD3y7uNCPx5g E7MA== X-Gm-Message-State: ABuFfog7Zfz0Ehngq70NJSh3Nuob+vfQvoagqQYg2vLPBVkM07sUM6jc ulEarrx9K0nhx/QtwabR6YDMZw== X-Received: by 2002:a1c:9895:: with SMTP id a143-v6mr8290579wme.43.1538754947394; Fri, 05 Oct 2018 08:55:47 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x203-v6sm2418391wmg.42.2018.10.05.08.55.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:55:45 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E62053E0792; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:04 +0100 Message-Id: <20181005154910.3099-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d Subject: [Qemu-devel] [RFC PATCH 15/21] trace: add linux-user plugin support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel.Dovgaluk@ispras.ru, Riku Voipio , Laurent Vivier , cota@braap.org, Aaron Lindsay , =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Aaron Lindsay Signed-off-by: Aaron Lindsay [AJB: ifdeffery] Signed-off-by: Alex Bennée --- linux-user/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/linux-user/main.c b/linux-user/main.c index a68674d0de..9fbb827fe0 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -38,6 +38,7 @@ #include "trace/control.h" #include "target_elf.h" #include "cpu_loop-common.h" +#include "qemu/plugins.h" char *exec_path; @@ -393,6 +394,13 @@ static void handle_arg_trace(const char *arg) trace_file = trace_opt_parse(arg); } +#ifdef CONFIG_TRACE_PLUGIN +static void handle_arg_plugin(const char *arg) +{ + qemu_plugin_parse_cmd_args(arg); +} +#endif + struct qemu_argument { const char *argv; const char *env; @@ -444,6 +452,10 @@ static const struct qemu_argument arg_table[] = { "", "Seed for pseudo-random number generator"}, {"trace", "QEMU_TRACE", true, handle_arg_trace, "", "[[enable=]][,events=][,file=]"}, +#ifdef CONFIG_TRACE_PLUGIN + {"plugin", "QEMU_PLUGIN", true, handle_arg_plugin, + "", "file=[,args=]"}, +#endif {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, {NULL, NULL, false, NULL, NULL, NULL} @@ -830,6 +842,9 @@ int main(int argc, char **argv, char **envp) } gdb_handlesig(cpu, 0); } + + qemu_plugins_init(); + cpu_loop(env); /* never exits */ return 0; From patchwork Fri Oct 5 15:49:05 2018 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: 148210 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp624018lji; Fri, 5 Oct 2018 09:01:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV60u947p1P5ST2s388zksrRzfbCqJRVlWbZwDRZMeO3cIr8t8sD6fx2LV/+uvd4t1KFFkfrb X-Received: by 2002:aed:29c5:: with SMTP id o63-v6mr9870120qtd.264.1538755289160; Fri, 05 Oct 2018 09:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755289; cv=none; d=google.com; s=arc-20160816; b=nTMlJAhuAKgKxzQVR+7qXccTToQ0a9W6E9Swa5pp8u9cHus2aGoa2VwLQX13+CV3Eh g4VMRl1mvrYvKh3R5BuhFHydCgLp4yEUv1+BPEaZkqIzT+ZGMep4edTcZivIQonGakiF 1nWR6RE6NEGhUw3Rh2mjUM4KDYfZAUTzLWAWONYgcw8S+PBiLZINoheOj+OV6CPbPV1I 1TMWo5uWlAcm8xar0x+mKq7oS9yGXioh18OOP1xnB7aM2ZtdlLPyhIqMcluFimGD1zP4 B8NrqIfkeZNA9T/wrUiKh1R130HUeiJKBZL0z+WZQH6KnIvFC6WogfSzrI/ZFJe+H9O0 Cn9A== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=QrMIeogFtOpJBkF0FBEOHVX48G5nXsLxgwrjNiEkM8gHxgHX1QjwQkZmFEiJlsk3Um w+XaL8IfWSKQXsYzQMWbCRMxT6aJ0whTCCx1QRZXIQed2TocDeo+wBYlP0kU1GFOZZFB HCRaYuxscw9dmt8RIt3d1fhXg7Bp5JpQhCsM46m0v9LmefX9YeVL4ezz9sstzZEJZwjk 3qiRErcasXwzmR78xOsQKQpNfhHHTMvNkiZ4K0bf9ilc1nGx3paG+Io7I3qvH3mjCKEc 97Xca7L5nZL89jcA0InakUQmpPk0uG7OC2bwMYcMRK5ZMTdXh4gRWG7YFrol4LS9nDR1 dyeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gYYbld+z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 7-v6si112517qkv.273.2018.10.05.09.01.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gYYbld+z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SXg-0003D5-Gj for patch@linaro.org; Fri, 05 Oct 2018 12:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMF-0006fN-Fm for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006Fj-TY for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:40920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM9-00068C-El for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wm1-x331.google.com with SMTP id z204-v6so2374589wmc.5 for ; Fri, 05 Oct 2018 08:49:28 -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=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=gYYbld+zifSn9K1DBJBuHRTV0klwmLDdhLdOWb7l6Om2bLoghGMGR7VBhSlIByieGi 8hmvX1nCqjZcuBRQMKoZDRNAPzqvwWzLdlFzEiyJw31g/Xo4SyOAJPUUqC6gwOoazJQy gbo4GQKb8vWDildtMAL9wHkgwxCDzS8qANOv0= 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=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=BGAXxzDmjAxUFXEnGgfvqWl7SCflxqlr5b3hQZxmd4EO5FdmhrliDH9Fh5dFDGayp3 DybYCb7WW/4s5/XX3V7ARDSsn/azIAJCMj8ITTQjaHqdgLXcHUEoMIZs3XkQXV2aCt8z cNM46qNdSbSVzmYk4Ug2lArLRLWXz+gDYe9CyX/0D6opwDHtnvTo/D/EaFFCGOscmDcm F+Fmomi24yYStHugMJa6sYldw0GjJVqm2aqexWWCBguV8aJW2ETLOZiew8Pp8naspmhZ mu7aoDbguhFr4aO9e2PlJEBHnPort+H+Mrr2joabY3f6XWh88ozvo4WZB7DbCsXMREyc 4+hg== X-Gm-Message-State: ABuFfohFyxMbMZdsZJRvkcE6AWIz4n9uoIC0p60a5TVyxoB9eygkVshy skBm1iWUq4Pts1j3I/QEmx1QJY0T/zk= X-Received: by 2002:a1c:af07:: with SMTP id y7-v6mr8566978wme.33.1538754567674; Fri, 05 Oct 2018 08:49:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u76-v6sm3521928wmd.10.2018.10.05.08.49.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 067913E07DB; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:05 +0100 Message-Id: <20181005154910.3099-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [RFC PATCH 16/21] trace: add infrastructure for building plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to build any bundled plugins in the source tree. Out-of-tree builds can call Makefile.plugins to build in their own source tree: make -f $(QEMU_PATH)/trace/plugins/Makefile.plugins QEMU_SRC=$(QEMU_PATH) Signed-off-by: Alex Bennée --- Makefile | 5 ++++- trace/Makefile.objs | 24 ++++++++++++++++++++++++ trace/plugins/Makefile.plugins | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 trace/plugins/Makefile.plugins -- 2.17.1 diff --git a/Makefile b/Makefile index 1144d6e3ba..e04d1c5124 100644 --- a/Makefile +++ b/Makefile @@ -438,7 +438,7 @@ dummy := $(call unnest-vars,, \ include $(SRC_PATH)/tests/Makefile.include -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules +all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules plugins qemu-version.h: FORCE $(call quiet-command, \ @@ -1091,6 +1091,9 @@ help: @echo ' all - Build all' ifdef CONFIG_MODULES @echo ' modules - Build all modules' +endif +ifdef CONFIG_TRACE_PLUGIN + @echo ' plugins - Build all plugins' endif @echo ' dir/file.o - Build specified target only' @echo ' install - Install QEMU, documentation and tools' diff --git a/trace/Makefile.objs b/trace/Makefile.objs index 4977f654a5..4f62022595 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -58,3 +58,27 @@ util-obj-$(CONFIG_TRACE_PLUGIN) += plugins.o util-obj-y += control.o target-obj-y += control-target.o util-obj-y += qmp.o + +###################################################################### +# Plugins +ifdef CONFIG_TRACE_PLUGIN + +PLUGINS=$(dir $(wildcard $(SRC_PATH)/trace/plugins/*/.)) + +.PHONY: plugins $(PLUGINS) + +plugins: $(PLUGINS) + $(info built all plugins $(PLUGINS)) + +$(PLUGINS): + $(call quiet-command, \ + (cd $@ && $(MAKE) -f $(SRC_PATH)/trace/plugins/Makefile.plugins \ + QEMU_SRC=$(SRC_PATH) \ + BUILD_DIR=$(BUILD_DIR)/trace/plugins), \ + "PLUGIN","in $@") + +else + +plugins: + +endif diff --git a/trace/plugins/Makefile.plugins b/trace/plugins/Makefile.plugins new file mode 100644 index 0000000000..0056d91c74 --- /dev/null +++ b/trace/plugins/Makefile.plugins @@ -0,0 +1,32 @@ +# -*- Mode: makefile -*- +# +# QEMU plugins +# +# This Makefile is used to build plugins for QEMU. Unlike the rest of +# the object files we build we don't have visibility of QEMU's +# internals. When called from the main makefile we build plugins into +# BUILD_DIR/plugins otherwise where ever the Makefile was called from. +# QEMU_SRC +# + +BUILD_DIR ?= $(CURDIR) +CC ?= cc + +ifndef QEMU_SRC +$(error need to define QEMU_SRC for the build) +endif + +GLIB_CFLAGS = $(shell pkg-config --cflags glib-2.0) +CFLAGS = -I$(QEMU_SRC)/include/plugins $(GLIB_CFLAGS) -fno-PIE -fPIC -O3 -g +LDFLAGS = $(shell pkg-config --libs glib-2.0) -shared + +SRC = $(wildcard *.c) +PLUGINS = $(addprefix $(BUILD_DIR)/,$(SRC:.c=.so)) + +$(BUILD_DIR)/%.so: %.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +all: $(PLUGINS) + +clean: + rm -f $(PLUGIN_SO) $(PLUGIN_OBJ) From patchwork Fri Oct 5 15:49:06 2018 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: 148215 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp631183lji; Fri, 5 Oct 2018 09:06:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV61Wk7pjDtrrtUUEmRx3O5hMfxyrF5g5ZJ3A3+rKBlHP9Si6NtdV9XrhfNEarXTdKSftHIHo X-Received: by 2002:aed:206e:: with SMTP id 101-v6mr9819724qta.11.1538755615652; Fri, 05 Oct 2018 09:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755615; cv=none; d=google.com; s=arc-20160816; b=pP7EFOw6A/BGsTxmNZz7I9bqSwo8HV4LVqn55gadKa2BsallomZN6aoUvbgRJ3u20p TrZ2UYhndxyMyHlV/wY4LKyWm6AdzhSrMFmszr8WOS6eabDuw7VCD/p4l2TNjmBMN5gZ xea8RkI9ohoeAkiI0wOMbcV3OYhQy6GYL2fo86HN81uZUz6zh0CJTquSQUdnsg9jirg1 knq5f0xxyrBgJu+2LvfETAyPT8F+h6ajA56DO6Frs/vrY5dXy148CnZ81Dt8pcQQP5dC pwdR2PVajU+bSDzzGQnImkf34/ENxy2mPJYfj19NVVFcvx9ONp8NkmVUZpm8h+5kZWVi Vt8w== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=yEoC4JPYjoTTbOmow+eMx0SCxkJe38nlMdEtsRlWWgI=; b=0nk/CFmA0eoko3J95MwcjuutqDOdnmPAzIp3ZSaL0C5OOFnAju1oYw3BN6gJBOeEJp vEcdQaRlarJORZhRYK6smY8skYXEPPReCJJAb+8ceTlt52BCXgtGkQix7iombuUtXXWz oTMlE9K5FZhauFdtKjNbwXPt7jg2S8tjuT8fH13RSOhwq2UVbjc6NYH6RAY2akSJ1Yuj fM1xBzA7GrKtbM5kSa3ZQYViq49+nPJ83hCW9/fblrem5+WIzo8vmzyj/Rcyp7BOZRDc IPXXB0SJnDafB2msrVk0MNE8mMectcl8J4oxuyvEZil5UYaj9UMV50OaB6yzxGGlQbY3 ozZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UdgudvjJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p1-v6si2726245qta.42.2018.10.05.09.06.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UdgudvjJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8Scx-0007e9-5M for patch@linaro.org; Fri, 05 Oct 2018 12:06:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSH-0005zk-7S for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SSD-0004f2-Ji for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:53 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:52773) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SSD-0004ef-Cv for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:49 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 189-v6so2331470wmw.2 for ; Fri, 05 Oct 2018 08:55:49 -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=yEoC4JPYjoTTbOmow+eMx0SCxkJe38nlMdEtsRlWWgI=; b=UdgudvjJHnpaUsXNyXuqekzUPHpDMs17L9EJXMer20z3YczALoGnqPpY/+UvXbm2AW cV1TfkPZEISiN4LZ6EyIU8i5JQSUcLJBAP52BElsccCKBGYqdy1uv6G9z/Ql4NORLOJG LzlRZtgqBeIEpEtfRXia/QXRv6HtI2wtdIvR4= 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=yEoC4JPYjoTTbOmow+eMx0SCxkJe38nlMdEtsRlWWgI=; b=Pt7mQRyZ0SoJUPLcPPcojJnCVb9e8VqXC1be7K26ysu7z+IQSE0oT+l45x0i3BX8oB ASZbRgPpnOm9zncWeCZjH9V/7a5grleiAeN5UB5NQQrTf/whqsoCfOyDH+x4udFQH0Ar 6YKeIQ84lQNBsgZvZVsqzy3NMrvbXBWgbOSwDBmph592/K6kxZoQoyz1zBEkGH0D/Nq7 jw01G9+9cQ+8PEBZwqjvU6vAURtX7xA8ZwmUT/FoB505ZQ5Hnq2Noh+gNOn+jQkj1sum OHhh/d5OFpREdmBxY0yuUkrieEdV9RhyQPQBHSHmv1byiU6uVNU8XdUVPv5DD7cr88NC EMWw== X-Gm-Message-State: ABuFfohM1U60zFbs55wG4peAToE5VZi0ImuOgm0ZlgI0C29n/EGpgH9i WuLcB8eGMRGvfKIzRe0GVpV91w== X-Received: by 2002:a1c:a8c2:: with SMTP id r185-v6mr8149887wme.8.1538754948144; Fri, 05 Oct 2018 08:55:48 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 63-v6sm2675438wmj.39.2018.10.05.08.55.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:55:45 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1C8B13E0248; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:06 +0100 Message-Id: <20181005154910.3099-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [RFC PATCH 17/21] hmp: expose status of plugins to the monitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , Markus Armbruster , "Dr. David Alan Gilbert" , cota@braap.org, Pavel.Dovgaluk@ispras.ru, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- hmp-commands-info.hx | 17 +++++++++++++++++ include/qemu/plugins.h | 1 + monitor.c | 14 ++++++++++++++ trace/plugins.c | 15 +++++++++++++++ 4 files changed, 47 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson Reviewed-by: Dr. David Alan Gilbert diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index cbee8b944d..e245a852ae 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -683,6 +683,23 @@ STEXI Show available trace-events & their state. ETEXI +#if defined(CONFIG_TRACE_PLUGIN) + { + .name = "trace-plugins", + .args_type = "name:s?", + .params = "[name]", + .help = "show available plugins and any extra info " + "(name: plugin name pattern)", + .cmd = hmp_info_trace_plugins, + }, + +STEXI +@item info trace-plugins +@findex info trace-plugins +Show available trace-plugins & their state. +ETEXI +#endif + { .name = "tpm", .args_type = "", diff --git a/include/qemu/plugins.h b/include/qemu/plugins.h index c86bb7ae67..44f2ec8c98 100644 --- a/include/qemu/plugins.h +++ b/include/qemu/plugins.h @@ -6,6 +6,7 @@ void qemu_plugin_parse_cmd_args(const char *optarg); void qemu_plugin_load(const char *filename, const char *args); void qemu_plugins_init(void); +GString *qemu_plugin_status(const char *name); #else diff --git a/monitor.c b/monitor.c index d8229cd2b0..0d0de9ece7 100644 --- a/monitor.c +++ b/monitor.c @@ -67,6 +67,9 @@ #ifdef CONFIG_TRACE_SIMPLE #include "trace/simple.h" #endif +#ifdef CONFIG_TRACE_PLUGIN +#include "qemu/plugins.h" +#endif #include "exec/memory.h" #include "exec/exec-all.h" #include "qemu/log.h" @@ -1429,6 +1432,17 @@ static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) qapi_free_TraceEventInfoList(events); } +#ifdef CONFIG_TRACE_PLUGIN +static void hmp_info_trace_plugins(Monitor *mon, const QDict *qdict) +{ + const char *name = qdict_get_try_str(qdict, "name"); + GString *status = qemu_plugin_status(name); + + monitor_printf(mon, "%s", status->str); + g_string_free(status, true); +} +#endif + void qmp_client_migrate_info(const char *protocol, const char *hostname, bool has_port, int64_t port, bool has_tls_port, int64_t tls_port, diff --git a/trace/plugins.c b/trace/plugins.c index 25aec2ff70..05630b02e6 100644 --- a/trace/plugins.c +++ b/trace/plugins.c @@ -58,6 +58,21 @@ void qemu_plugin_parse_cmd_args(const char *optarg) qemu_opt_get(opts, "args")); } +GString *qemu_plugin_status(const char *name) +{ + QemuPluginInfo *info; + GString *status = g_string_new(""); + + QLIST_FOREACH(info, &qemu_plugins, next) { + if (info->status) { + char *pstatus = info->status(); + g_string_append_printf(status, "%s: %s\n", info->filename, pstatus); + g_free(pstatus); + } + } + return status; +} + static int bind_to_tracepoints(GModule *g_module, GPtrArray *events) { int count = 0; From patchwork Fri Oct 5 15:49:07 2018 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: 148203 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp620398lji; Fri, 5 Oct 2018 08:58:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ETDG4d5MKkf2WvIOzdC+ulxmP0iMa8eGVnALx9nnm7JiyCtjUk9oGj8CY395JLPTh5zRZ X-Received: by 2002:ac8:2a33:: with SMTP id k48-v6mr9744576qtk.245.1538755092508; Fri, 05 Oct 2018 08:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755092; cv=none; d=google.com; s=arc-20160816; b=B8DuEa/27wmqW7cbVFmSIQsbHrWJDA0BXy/a3GVa+iCmA2NrSc/PDvfgLOb/RelkTu VU1XzeCm1DFBSYzLMPdsIIeEsFX7ud+wB/oVu4EsermS5ubZhjcsfQTNq+y/6fCLwDd5 KD/lzjZdiGcOTH/w25YUDPPQ60S/GnuE0/HZRCHoWy2r2UX6k0vWJBDt7npmckR/0Bof K1fhjCDwfbWajl2/yZ20ZUWgmaVwpq0chuYawE+USQjM+mGC0iruoy9+yhJtpAF6X+rr 8OXWJtfUasDth7F5wdfPSVcYnYOXvLrFuxQLghMmbRoy1PEAp/jvoeudlU/CAk50xqmt tjSA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xomis5lLafULCE1DLy6Ga+55f13jUaR20ViL4qRpD/E=; b=JDr1UbtJRm56SSJngdzqtCtRMUBNvNfYbxSGO4Jr+2Q8zJtfONb+PEMc/FqZ9IfVlt BIUF5comzyooKjYuvQ9Ly8SxYsOwgupqnG9CFOLKwRcfTbWD37JNtQ5tF4ZBirbP06N7 9a0SbicjdlBvM443cDSAcEjz4cJzzUYPwZcy0P392AYKaaTUTzMsX8BlSvUmiSFcHRhn lWgWXvGRZ557jV72v7vJHmpfafuMBlBrJ+wDdVaR7FY/14BuPKhxiMMMfictFMtWj8fR 3GVo/DSz6F+SlluU0wQ68ntCg8J+nKGKuNM+LfGckekrcIvIDSM7PUZRbLetPPd2NSVP a3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bL8+OH+s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a5-v6si4065156qvn.135.2018.10.05.08.58.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bL8+OH+s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SUV-0000Oo-SS for patch@linaro.org; Fri, 05 Oct 2018 11:58:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMA-0006aj-Q7 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM8-0006D1-Qf for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:38979) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00068q-B9 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:32 -0400 Received: by mail-wr1-x42f.google.com with SMTP id 61-v6so13303655wrb.6 for ; Fri, 05 Oct 2018 08:49:29 -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=xomis5lLafULCE1DLy6Ga+55f13jUaR20ViL4qRpD/E=; b=bL8+OH+sB0sfnjWQkuT7tjAGjtVHZTO8QZfvyKo52ZBtEgmJ4CEZwCIS4UM8rhEUB/ T8pE9DZWgEFnZrvchP5k7lHP0VfigMZN8Wmi3wLKHoPemduD3EAQsK9fXA508W5YTByl N51+CbVs8qY/XsaI09L2u5lxX+qi6pkf2kgDY= 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=xomis5lLafULCE1DLy6Ga+55f13jUaR20ViL4qRpD/E=; b=g7KFNwemWTkukcNxqtvAMTBVvn7KxXlzMtKb2Q1mBBRpiwS8r/+LOHC2NmWrhB322l QpLCVaunwovGKwOWfly8GKdkYrRJGzASxbCaipsYDAEGFvtjcP5nB1WPsBtcFbxuyBIM vjol1hMallF2eEnwIhlCwaQPqg7xXdLEhbu9uQbZnTLU00eF8X+pefLL+KjadHKyT7YL u/gyqm5PTa+h5eihRq8Cu/M6BqxqEZG/H/aG0oTzwvxRX4bANCkNNFIoWgZ848cR50NU ydRd+iCocRv750o0ubBfsHmL2XBMquJfnQyU9SjVe8mqynCfuRSxuWe04ea8iQljM/XP 5d6w== X-Gm-Message-State: ABuFfojW0a3/vdBEJQnz8BNlv3YmNh+9BlZstsY+nBQrdeclAUgE6Gzq kvJq5RYV5Ia5x+Dv7aFhU2RQXS1cuQE= X-Received: by 2002:adf:8103:: with SMTP id 3-v6mr8531119wrm.106.1538754568509; Fri, 05 Oct 2018 08:49:28 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 195-v6sm2970011wmx.21.2018.10.05.08.49.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:24 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 308013E085A; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:07 +0100 Message-Id: <20181005154910.3099-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [RFC PATCH 18/21] linux-user: allow dumping of plugin status at end of run X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , cota@braap.org, Pavel.Dovgaluk@ispras.ru, =?utf-8?q?Alex_Benn=C3=A9e?= , vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As we don't have a monitor in linux-user mode we need some way of exporting our data to the world. We introduce a new -d option (plugin) which turns on the existing LOG_TRACE flag which qemu_plugin_status() will dump output to before we finally exit. Signed-off-by: Alex Bennée --- linux-user/exit.c | 12 ++++++++++++ util/log.c | 2 ++ 2 files changed, 14 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/linux-user/exit.c b/linux-user/exit.c index 14e94e28fa..2f9e016207 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -17,12 +17,23 @@ * along with this program; if not, see . */ #include "qemu/osdep.h" +#include "qemu/plugins.h" #include "qemu.h" #ifdef CONFIG_GCOV extern void __gcov_dump(void); #endif +static void plugin_report(void) +{ +#ifdef CONFIG_TRACE_PLUGIN + GString *plugin_report = qemu_plugin_status(""); + qemu_log_mask(LOG_TRACE, "%s", plugin_report->str); + g_string_free(plugin_report, true); +#endif +} + + void preexit_cleanup(CPUArchState *env, int code) { #ifdef TARGET_GPROF @@ -31,5 +42,6 @@ void preexit_cleanup(CPUArchState *env, int code) #ifdef CONFIG_GCOV __gcov_dump(); #endif + plugin_report(); gdb_exit(env, code); } diff --git a/util/log.c b/util/log.c index 5759bf571f..d4423277e0 100644 --- a/util/log.c +++ b/util/log.c @@ -288,6 +288,8 @@ const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, + { LOG_TRACE, "plugin", + "show summary plugin information at end of run." }, { 0, NULL, NULL }, }; From patchwork Fri Oct 5 15:49:08 2018 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: 148214 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp629328lji; Fri, 5 Oct 2018 09:05:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV61oEQFnXGahGmB1HvtvjjRGuh29hYpEa9nEUUjVV3LeIE/weuEmtyeWgubAihGSIkLp7eAu X-Received: by 2002:ae9:df02:: with SMTP id t2-v6mr8995313qkf.161.1538755526402; Fri, 05 Oct 2018 09:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755526; cv=none; d=google.com; s=arc-20160816; b=vSb9ObDSWaFP1OHefur0VktDcKZf5B57H/wrg3XHtDRCujR+R/pCFoV38C/qVH05u3 jqD3EjuJNxoHqVCBUsVunP9N99d9URNEe2fNdcba5qhNolgUvu6Tp3hbosykSiq51bQw fWrpCrcFkiwfvkSifOccmvk+dxNIm5fpwRE/pFtjz6h/7PgrHlCLJgLauTT6QQP5H1pe zdAGF2Z2qJ/42jS0G0jW19FE4FYhC0BVH6jABhJjYybo8447Z9TKKExV6WbaEK1SUO9V HrZjQNtHMbpoZBdc2EkoL+PfIQmxh4MviC99Kr51IncKYNCIh0+IpQ3yadMHK58paWBx a2pg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Gy6oZ4WvtbPxi9/JzF6atrZp6ZtERY/PrwaMhunFanw=; b=SpM835CJC/aB42ibmC0ilGJZ3ZhUEHCx26Za6BdgnntgL2QvBRILzYlMIhVwO/eG60 A8U2kcLB83qgQ34XFlta7LsV/vjOv9w3x+pZCEaab7ykGWhkY+CSoEx+LWODnfiHGBKh ZBmapg/hQ4sWaKuT0p7exJBW9i+RX5vvEnYDLHUXx+pSKeDJIZN6PCf3+L5ejjCwX68b 3nrLZvNnp9AGsJ+gEHu1bS3Jn+kWXtjZOfA+lXMA3EK4iIrMvu+UC0U8mUrIDHAhl6KS 56992CbLBBuk7COhdamIYoLWhZ7JY4VMg7FpJFi/01KSoxY1NrtCqvj2cAbJUkKZszLF I2fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="E3JUZd/d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u5-v6si5425002qvi.102.2018.10.05.09.05.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="E3JUZd/d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SbV-0006Si-ST for patch@linaro.org; Fri, 05 Oct 2018 12:05:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSH-0005zq-84 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SSF-0004fi-4o for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:53 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SSE-0004fR-Ts for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:51 -0400 Received: by mail-wr1-x444.google.com with SMTP id d2-v6so9634363wro.7 for ; Fri, 05 Oct 2018 08:55: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=Gy6oZ4WvtbPxi9/JzF6atrZp6ZtERY/PrwaMhunFanw=; b=E3JUZd/d4esfQI1xdFgrZmKr25ced+XlKLJeNAY8apCsHj+HjhsQt3/1gzPptwDmmM 99bpv8v53+I6WOnROw3RC818bJfeW6bSrunNi3iZsGO59DZiHotcc3RCHRPVdJGJtEk/ P3fr9t0OJ+ZkpbG3/V0im8EyPBBvpVw6r+aW8= 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=Gy6oZ4WvtbPxi9/JzF6atrZp6ZtERY/PrwaMhunFanw=; b=Z3gvrsZnr0Z0WeuNA5Jq/KBfjqnFbrPW++zkR2dmpHKJFpg4uHuBPgrgjjHjbBDvC2 rO+NOntSQBE+umc1ZjjOhdR9CHdo4rxOJMj7bcl4FYFGPLHnw8qtbWeDcPChMG1iP92e EXepsnrinbbzmoy/eT8X85KV3JEaZket0T2XIyFgBGtuC2lKo3TAAxH3okjC7rUI0+62 K3rWgVv8qTKj4JLRHaGJ9JSAeSlLgH1pP4JeRDviy2XcUHCFOkaROaO+ssZNAnJm+MFm WYxm/GNJsVGdphl26tvzaIJ8UBp+ZFUOSg9LbIQyDyBEMOjkDIP3VB6KWDnNoJcN46WP ZZWQ== X-Gm-Message-State: ABuFfoih2wyCosap+92BGcOlDV2jRmZmkHqf1vAv1qcnQGabAPf7UpZu qXv8XB7YIPEAzqhkera2+pumxg== X-Received: by 2002:adf:afdd:: with SMTP id y29-v6mr9322390wrd.176.1538754949744; Fri, 05 Oct 2018 08:55:49 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o126-v6sm2452350wmo.3.2018.10.05.08.55.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:55:46 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 42A0E3E085D; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:08 +0100 Message-Id: <20181005154910.3099-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [RFC PATCH 19/21] plugins: add an example hotblocks plugin X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This plugin attempts to track hotblocks by total execution count and average time to return to block. It is intended to be lower impact than saving a long log file and post-processing it. Signed-off-by: Alex Bennée --- trace/plugins/hotblocks/hotblocks.c | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 trace/plugins/hotblocks/hotblocks.c -- 2.17.1 diff --git a/trace/plugins/hotblocks/hotblocks.c b/trace/plugins/hotblocks/hotblocks.c new file mode 100644 index 0000000000..e9166ad1a5 --- /dev/null +++ b/trace/plugins/hotblocks/hotblocks.c @@ -0,0 +1,69 @@ +/* + * Execution Hotblocks Plugin + * + * Copyright (c) 2018 + * Written by Alex Bennée + * + * This code is licensed under the GNU GPL v2. + */ + +#include +#include +#include +#include +#include "plugins.h" + +/* Plugins need to take care of their own locking */ +GMutex lock; +GHashTable *hotblocks; + +typedef struct { + uintptr_t pc; + unsigned int hits; + struct timespec last; + unsigned long total_time; +} ExecCount; + +bool plugin_init(const char *args) +{ + hotblocks = g_hash_table_new(NULL, g_direct_equal); + return true; +} + +char *plugin_status(void) +{ + GString *report = g_string_new("We have "); + char *r; + g_mutex_lock(&lock); + g_string_append_printf(report, "%ud entries in the hash table\n", + g_hash_table_size(hotblocks)); + g_mutex_unlock(&lock); + r = report->str; + g_string_free(report, FALSE); + return r; +} + +bool exec_tb(void *tb, uintptr_t pc) +{ + ExecCount *cnt; + struct timespec current; + clock_gettime(CLOCK_MONOTONIC, ¤t); + + g_mutex_lock(&lock); + cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) pc); + if (cnt) { + cnt->hits++; + cnt->total_time += current.tv_nsec - cnt->last.tv_nsec; + cnt->last = current; + } else { + cnt = g_new0(ExecCount, 1); + cnt->pc = pc; + cnt->last = current; + cnt->hits = 1; + g_hash_table_insert(hotblocks, (gpointer) pc, (gpointer) cnt); + } + g_mutex_unlock(&lock); + + /* As we are collecting up samples no reason to continue tracing */ + return false; +} From patchwork Fri Oct 5 15:49:09 2018 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: 148218 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp637746lji; Fri, 5 Oct 2018 09:12:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV600fz63i9LMloz6A14AOTYKGDgCE5/YBH6+Y65ZxbLXxxUfngc3b+WZV1pnOCDS8SqIRg9s X-Received: by 2002:a0c:d585:: with SMTP id g5-v6mr10060776qvi.50.1538755946668; Fri, 05 Oct 2018 09:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755946; cv=none; d=google.com; s=arc-20160816; b=FqqO5dukPcCymxClwOHyoY8ybhgjlWmybYA3NiK469tMe/Y3uwu6O3JQgcpMAGMYXX Lmna61yX7JPZ4lYxMzDEXthCaHkjZ4Ze0mrn95mu2HKrpBbjwiPUNflB8J5wGWlaBDkL ue5p207RMK20tac62M53E8tfpNXilOsR8/CqG1YfGIf3/U2kD73jn958CdBz3iZ4+uW0 SdIRwYjtHOHusZdxTIjju8g9aD6U4Ast7U0A+cvP9blK70HFLeAumKmV66Cx6kXcTSu7 3+Ipli2dkch3F+eA354c0uqyoJldIIVu6NSmktqx7qPRRrbTbdrULxFSj3jj8c44Q4Hv wOZg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=niBrZfxJaKwm3OTekaz9i84MMz3w9A8+1X4ToD1jQC0=; b=uIrmFHJSKAvggG8R9b3QMY50hoEwUC45PeZJTjkWJrSrB0UqAvIrTxRnPpgk+Hv/vX H4btbMPxrILCJM8/UBxAad2Lw+JuynrUv6qlC4ir0x0U8ywKCQQjEZVeY5jV1r3mnFFm al0R38DX0Z2nruphm2rOqdEWqNe4xZ/FM+JNmCTkLIn9jedQfo4JmkfL2u5bioPH85Im snv+WHWAuGr7ZP7aEPM+0zvLld2dEB5gVK/efiXorzITpX3yCQZN7w7iZrTfkyyO+vcF 62GEPZB1qWc7c3wOGYynWhXlLjBLM8sewo+EiFTr9SN6QeVafKIOT/UkVQxgGfpevaA4 T6cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g1cDv6yw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k190-v6si5733919qkd.243.2018.10.05.09.12.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g1cDv6yw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SiI-0004Sm-3T for patch@linaro.org; Fri, 05 Oct 2018 12:12:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSH-0005zs-86 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SSE-0004fY-BW for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:53 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:34059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SSE-0004er-4c for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:50 -0400 Received: by mail-wr1-x435.google.com with SMTP id z4-v6so14074890wrb.1 for ; Fri, 05 Oct 2018 08:55: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=niBrZfxJaKwm3OTekaz9i84MMz3w9A8+1X4ToD1jQC0=; b=g1cDv6ywi8TZkmeFL4aIMJMCHyLOJgi0/zdkIID0Xoes/8HN1QiFaStiCVVuXVffUc NpafP7JFp5p7Ra6gYQmwj67JgZFdlfcqy49CEgRh72bhuBrHbgBMNAlR7hFgGzcyBph+ hB/SzcFX7b6pGune6TnqGMGYXQr2SIsl3mlNY= 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=niBrZfxJaKwm3OTekaz9i84MMz3w9A8+1X4ToD1jQC0=; b=hqyPlZmt7f+h9aWZ06icgWSsYkkw4TDr+vA3f8JAGi1qRn3VkAyjhYYt9oSG2CZiGu wunnJ2S2L9XAubdL/2qbmGSSi9K02Ry7SsI4pBxb9w4/9Q8FZK4rMqn1lHnsR0mrV+CW wFAUXpmkus/564ShTKCHxmdfiZOH8UFgXMEgFPhRRho06y7r8alztBiJS2ljiNaMNU7W uxLGQyZzQQAvG1CrqY57J+mIiwPyQHXTLG8CnwDT8L7zj4xVbbXzc4B8QOWudqsupj+c BB0wcTq2oZElNvbLN4st6AHnYATAOvgMngEAvzFlyJg+0BHpk60Y/z9vVpchJvPdOA2m EVNg== X-Gm-Message-State: ABuFfoiIFXB5YTfrcnKJ143BPUlY9/cOFCfQM2Nj/8WfXziK8NvXvUqE fV+Ft06KXR/EVk87Cimhl1jItwd0870= X-Received: by 2002:adf:ba06:: with SMTP id o6-v6mr8241430wrg.249.1538754948937; Fri, 05 Oct 2018 08:55:48 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id i15-v6sm4943516wro.58.2018.10.05.08.55.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:55:46 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 55E5D3E0893; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:09 +0100 Message-Id: <20181005154910.3099-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [RFC PATCH 20/21] plugins: add hotness summary to hotblocks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- trace/plugins/hotblocks/hotblocks.c | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/trace/plugins/hotblocks/hotblocks.c b/trace/plugins/hotblocks/hotblocks.c index e9166ad1a5..d2333ad866 100644 --- a/trace/plugins/hotblocks/hotblocks.c +++ b/trace/plugins/hotblocks/hotblocks.c @@ -11,11 +11,13 @@ #include #include #include +#include #include "plugins.h" /* Plugins need to take care of their own locking */ GMutex lock; GHashTable *hotblocks; +guint64 limit = 20; typedef struct { uintptr_t pc; @@ -24,20 +26,49 @@ typedef struct { unsigned long total_time; } ExecCount; +static gint cmp_hits(gconstpointer a, gconstpointer b) +{ + ExecCount *ea = (ExecCount *) a; + ExecCount *eb = (ExecCount *) b; + return ea->hits > eb->hits ? -1 : 1; +} + bool plugin_init(const char *args) { + guint64 count = g_ascii_strtoull(args, NULL, 10); + if (count > 0) { + limit = count; + } + hotblocks = g_hash_table_new(NULL, g_direct_equal); return true; } char *plugin_status(void) { - GString *report = g_string_new("We have "); + GString *report = g_string_new("collected "); + GList *counts, *it; char *r; + int i; + g_mutex_lock(&lock); g_string_append_printf(report, "%ud entries in the hash table\n", g_hash_table_size(hotblocks)); + counts = g_hash_table_get_values(hotblocks); + it = g_list_sort(counts, cmp_hits); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + ExecCount *rec = (ExecCount *) it->data; + g_string_append_printf(report, + " pc: %#016" PRIxPTR + " (%d hits)" + " %lu ns between returns\n", + rec->pc, rec->hits, + rec->total_time / rec->hits); + } + g_mutex_unlock(&lock); + g_list_free(it); r = report->str; g_string_free(report, FALSE); return r; From patchwork Fri Oct 5 15:49:10 2018 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: 148211 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp625302lji; Fri, 5 Oct 2018 09:02:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV63WM343WdYvEVXgentE1o3ztgXXKgEkCyQgvcxXSbYC75cCI39Q9Fe96E4cPlaYaUcaeCZL X-Received: by 2002:a37:11c7:: with SMTP id 68-v6mr9761298qkr.263.1538755350416; Fri, 05 Oct 2018 09:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755350; cv=none; d=google.com; s=arc-20160816; b=E8FRZgek8zlnWuwOAvcTACf7FtQu3oq8bT/XILdhR8W3/Lsg99Gv42d50ZfWxd8VlS ezLEXh1kzmwsfL8kVC/ybSDb2lhnTXd2br3BEYU6g0WRt8/TfzGz4DK9x4bOzfxOnCnP VWfuKrt49g8o1TJjG0cdpxsx2VXxdHOLGT8G8BszM45Bqo6563AoeP34mFM+64SfwWHF 61huYaw8eM/V1JoHwIbQARBjp9KEm+apBM37gzkDMgBmtso/fb1y/f4SYh8O9VigIOa7 HIH/jloHCA8dFM4tD6aEABEl4ZbNsB7Z/wjDbQnLxt8ex9ZlBrF9IU3Jn4tumpjxrd9W 1FRw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=X0BSWGSS6/tmeN0YSyUQmgbzm2XJlJLsKpzNSq0GLHU=; b=PCvHecOY9lQT68rEmFKPj7IFWJgJV8X0vzJ052xTQH/PD4O8CSrwHNS4aMx0zX3NRN bzV1jupUE5rtTXW1xUnXLuC61eUggsN6nrJYLafKfuvkWKMlT65VAW8p6fIvpNjDYUOa qRnROq4tBU6UU12EHdPJ+ok8oFyebX7NLHVgj7AHrz7eDQRUkZp8fzZfkvjfX/5ccAxj ZJ+NH/CCi/EseGC4UPKuF6dXaCmFj6W8e7+F9mbz4QIKCTUA1Aa1EWxL1KvkBBy7l1Di jhdtrIHjXVjBa7sOzVS/f1KG7T44gNoy81sfnl566ywVYt+cht9uwLa7xQHSpTeikaCY HiRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KF8Xe9dw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d5-v6si209607qkf.371.2018.10.05.09.02.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:02:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KF8Xe9dw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:35787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SYf-0003fS-H6 for patch@linaro.org; Fri, 05 Oct 2018 12:02:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SSH-0005zr-85 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SSC-0004eT-5Y for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:53 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:44972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SSB-0004eL-SF for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:55:48 -0400 Received: by mail-wr1-x42b.google.com with SMTP id 63-v6so14046135wra.11 for ; Fri, 05 Oct 2018 08:55:47 -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=X0BSWGSS6/tmeN0YSyUQmgbzm2XJlJLsKpzNSq0GLHU=; b=KF8Xe9dwo8SDVMgrO6WIRY0h3u0TavVJO4NYlLno+8dVKY9Tk/g7cCSJ3xaHGYqX4Y dlRd5RZD92w/qafGvDO8+0Kq6azdMX88jgWf6Gffo5LoW7doCwOKypEXzaHKUvQv6ZAm 3Ca2Y6WQwcVUFjYL8beiT/6hNw7tH6DuPFgW4= 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=X0BSWGSS6/tmeN0YSyUQmgbzm2XJlJLsKpzNSq0GLHU=; b=HCxGG5JLz3jFJaREgfGOtfMCKbdHZbzYNSH/C9cJ42ANKnCnTsv7vg83zSz3UWeoPN ByYFiwcfwlYXM9ax5kOQoCI974hJjN75xZwls4CazeptJ5Zcxl20HGHqEY0j+FB42iiC c5wm67SDoF7C0vU1XUI2cirdqJNPA75iC7olnWfpfoGDNEh8NUgbdXclIXJP3u1KcFdM PDgjT8pt7COxbfSf6Lf9ywiqF0lSQuySZMZwrcCabdvwuI1lvQv+kPkWQL+4fDORH/Z1 EecQhFjsdp81zhwt9umfYc1vJf6DPJ8Em8+AYvo+6GPlS+VurcM9CDIEd5LasFZ610qM fHSg== X-Gm-Message-State: ABuFfojehDwKP6YyJ/C6zKqMQ/q4kUFNmdBvgJJcQl+lbrLg/qbiaDDm tCQgbYkl4MnTV97XcCrkSjGgGQ== X-Received: by 2002:a5d:628c:: with SMTP id k12-v6mr8239088wru.83.1538754946603; Fri, 05 Oct 2018 08:55:46 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w4-v6sm15232978wra.83.2018.10.05.08.55.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:55:45 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 68D4B3E089A; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:10 +0100 Message-Id: <20181005154910.3099-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [RFC PATCH 21/21] plugin: add tlbflush stats plugin X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This plugin attempts to give an idea of how long it take QEMU to process the various types of TLB flush operation. Although this is generally of interest to QEMU developers the plugin is only using the trace point information to work this out. For example launching a system emulation with -plugin file=./trace/plugins/tlbflush.so allows the following to be reported on the monitor: (qemu) info trace-plugins ./trace/plugins/tlbflush.so: tlbflush report: cpu 0 101244 self events: avg time 103, max 18313 cpu 0 2 async events: avg time 14076146, max 27536460 cpu 0 122328 synced events: avg time 5441, max 29080526 cpu 0 162671 work events: avg time 5380, max 47305 cpu 1 101742 self events: avg time 110, max 29708 cpu 1 2 async events: avg time 14112140, max 27573506 cpu 1 122669 synced events: avg time 5762, max 1175419 cpu 1 163401 work events: avg time 5427, max 942563 cpu 2 116726 self events: avg time 107, max 18277 cpu 2 2 async events: avg time 14126146, max 27615150 cpu 2 120119 synced events: avg time 6318, max 928542 cpu 2 177175 work events: avg time 5772, max 699626 cpu 3 94551 self events: avg time 107, max 23313 cpu 3 1 async events: avg time 27947822, max 27947822 cpu 3 123203 synced events: avg time 7877, max 3913260 cpu 3 156481 work events: avg time 5126, max 54107 Signed-off-by: Alex Bennée --- trace/plugins/tlbflush/tlbflush.c | 283 ++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 trace/plugins/tlbflush/tlbflush.c -- 2.17.1 diff --git a/trace/plugins/tlbflush/tlbflush.c b/trace/plugins/tlbflush/tlbflush.c new file mode 100644 index 0000000000..0e6ab82978 --- /dev/null +++ b/trace/plugins/tlbflush/tlbflush.c @@ -0,0 +1,283 @@ +/* + * Execution Hotblocks Plugin + * + * Copyright (c) 2018 + * Written by Alex Bennée + * + * This code is licensed under the GNU GPL v2. + */ + +#include +#include +#include +#include +#include +#include "plugins.h" + +#define MAX_CPU 16 + +#ifndef __ATOMIC_RELAXED +#error "this plugin relies on atomics" +#endif + +/* + * We are not going to try and track coalesced requests so the + * measurement will start from the point of the first request and be + * cleared from the first work complete. + */ + +typedef enum FlushType { SELF, ASYNC, SYNCED } FlushType; + +typedef struct { + unsigned long count; + unsigned long total; + unsigned long max; +} EventCounts; + +typedef struct { + struct timespec start; + FlushType type; + + EventCounts self; + EventCounts async; + EventCounts synced; + EventCounts work; +} TLBStats; + +static TLBStats stats[MAX_CPU]; + +bool plugin_init(const char *args) +{ + return true; +} + +static void add_stats(GString *report, int cpu, char *name, EventCounts *event) +{ + if (event->count) { + g_string_append_printf(report, + "cpu %d %ld %s events: avg time %lu, max %lu\n", + cpu, event->count, name, + event->total / event->count, event->max); + } +} + +char *plugin_status(void) +{ + GString *report = g_string_new("tlbflush report:\n"); + char *r; + int i; + + for (i = 0; i < MAX_CPU; i++) { + TLBStats *cpu_stats = &stats[i]; + + add_stats(report, i, "self", &cpu_stats->self); + add_stats(report, i, "async", &cpu_stats->async); + add_stats(report, i, "synced", &cpu_stats->synced); + add_stats(report, i, "work", &cpu_stats->work); + } + + r = report->str; + g_string_free(report, FALSE); + return r; +} + + +/* + * Maybe start an event. This is imprecise as we don't catch all + * events. We will skip events when: + * - we already started for an event that hasn't completed + * - events that happen to start when tv_nsec == 0 + */ +static bool maybe_start_timer(TLBStats *cpu, struct timespec now) +{ + struct timespec zero = { 0, 0 }; + bool started; + + started = __atomic_compare_exchange_n(&cpu->start.tv_nsec, + &zero.tv_nsec, + now.tv_nsec, false, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + if (started) { + __atomic_store_n(&cpu->start.tv_sec, now.tv_sec, __ATOMIC_SEQ_CST); + } + + return started; +} + +bool tlb_flush_self(int line, int vcpu) +{ + struct timespec current; + TLBStats *this = &stats[vcpu]; + + clock_gettime(CLOCK_MONOTONIC, ¤t); + + if (maybe_start_timer(this, current)) { + this->type = SELF; + } + + return false; +} + +static void start_one_cpu(TLBStats *cpu, FlushType type, struct timespec now) +{ + if (maybe_start_timer(cpu, now)) { + cpu->type = type; + } +} + +bool tlb_flush_async_schedule(int line, int from, int to) +{ + struct timespec current; + TLBStats *this; + + clock_gettime(CLOCK_MONOTONIC, ¤t); + + if (to < 0) { + int i; + for (i = 0; i < MAX_CPU; i++) { + if (i != from) { + this = &stats[i]; + start_one_cpu(this, ASYNC, current); + } + } + } else { + this = &stats[to]; + start_one_cpu(this, ASYNC, current); + } +} + +bool tlb_flush_synced_schedule(int line, int from, int to) +{ + struct timespec current; + TLBStats *this; + + clock_gettime(CLOCK_MONOTONIC, ¤t); + + if (to < 0) { + int i; + for (i = 0; i < MAX_CPU; i++) { + if (i != from) { + this = &stats[i]; + start_one_cpu(this, SYNCED, current); + } + } + } else { + this = &stats[to]; + start_one_cpu(this, SYNCED, current); + } +} + + +static EventCounts *get_counts(FlushType type, TLBStats *stats) +{ + switch (type) { + case SELF: + return &stats->self; + case ASYNC: + return &stats->async; + case SYNCED: + return &stats->synced; + } +} + +/* return elapsed ns */ +static unsigned long get_elapsed(struct timespec start, struct timespec end) +{ + struct timespec temp; + + if ((end.tv_nsec - start.tv_nsec) < 0) { + temp.tv_sec = end.tv_sec - start.tv_sec - 1; + temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec; + } else { + temp.tv_sec = end.tv_sec - start.tv_sec; + temp.tv_nsec = end.tv_nsec - start.tv_nsec; + } + + return (temp.tv_sec * 1000000000) + temp.tv_nsec; +} + +/* Record the duration of a single event based on when it started */ +static struct timespec record_event(struct timespec start, EventCounts *event) +{ + struct timespec current; + unsigned long elapsed ; + + clock_gettime(CLOCK_MONOTONIC, ¤t); + elapsed = get_elapsed(start, current); + event->count++; + event->total += elapsed; + if (elapsed > event->max) { + event->max = elapsed; + } + + return current; +} + +/* Update the timer for work. As we are re-reading in the same thread + * we don't need to be totally sequential - it doesn't matter if the + * outer thread reads this or zero. + */ +static void update_timer(TLBStats *cpu, struct timespec new_time) +{ + /* we are using 0 to indicate no current event */ + if (new_time.tv_nsec == 0) { + new_time.tv_nsec = 1; + } + __atomic_store_n(&cpu->start.tv_sec, new_time.tv_sec, __ATOMIC_RELAXED); + __atomic_store_n(&cpu->start.tv_nsec, new_time.tv_nsec, __ATOMIC_RELAXED); +} + +/* ??? Maybe we should drop the start of work trace points but create + * a new one for processing and queued work ??? */ + +bool tlb_flush_all_work(int vcpu) +{ + struct timespec start; + TLBStats *this = &stats[vcpu]; + + start.tv_nsec = __atomic_load_n(&this->start.tv_nsec, __ATOMIC_SEQ_CST); + start.tv_sec = __atomic_load_n(&this->start.tv_sec, __ATOMIC_SEQ_CST); + + if (start.tv_nsec) { + EventCounts *event = get_counts(this->type, this); + struct timespec start_work = record_event(start, event); + update_timer(this, start_work); + } + + return false; +} + +bool tlb_flush_work(int line, int vcpu, unsigned long data) +{ + struct timespec start; + TLBStats *this = &stats[vcpu]; + + start.tv_nsec = __atomic_load_n(&this->start.tv_nsec, __ATOMIC_SEQ_CST); + start.tv_sec = __atomic_load_n(&this->start.tv_sec, __ATOMIC_SEQ_CST); + + if (start.tv_nsec) { + EventCounts *event = get_counts(this->type, this); + struct timespec start_work = record_event(start, event); + update_timer(this, start_work); + } + + return false; +} + +bool tlb_flush_work_complete(int line, int vcpu) +{ + struct timespec start; + TLBStats *this = &stats[vcpu]; + + start.tv_sec = __atomic_load_n(&this->start.tv_sec, __ATOMIC_RELAXED); + start.tv_nsec = __atomic_load_n(&this->start.tv_nsec, __ATOMIC_RELAXED); + + if (start.tv_nsec) { + EventCounts *event = &this->work; + record_event(start, event); + /* reset for next event */ + __atomic_store_n(&this->start.tv_nsec, 0, __ATOMIC_SEQ_CST); + } + + return false; +}