From patchwork Wed Aug 29 12:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" X-Patchwork-Id: 10580157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D6AB175A for ; Wed, 29 Aug 2018 12:37:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B00C2AA9C for ; Wed, 29 Aug 2018 12:37:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F34772AFB7; Wed, 29 Aug 2018 12:37:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 650312AA9C for ; Wed, 29 Aug 2018 12:37:20 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AF96ACE5; Wed, 29 Aug 2018 12:36:37 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 69A9FCB7 for ; Wed, 29 Aug 2018 12:36:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx06.melco.co.jp (mx06.melco.co.jp [192.218.140.146]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C26C07C2 for ; Wed, 29 Aug 2018 12:36:34 +0000 (UTC) Received: from mr06.melco.co.jp (mr06 [133.141.98.164]) by mx06.melco.co.jp (Postfix) with ESMTP id B5C603A3279 for ; Wed, 29 Aug 2018 21:18:07 +0900 (JST) Received: from mr06.melco.co.jp (unknown [127.0.0.1]) by mr06.imss (Postfix) with ESMTP id 420l5C4qxHzRkFm for ; Wed, 29 Aug 2018 21:18:07 +0900 (JST) Received: from mf04_second.melco.co.jp (unknown [192.168.20.184]) by mr06.melco.co.jp (Postfix) with ESMTP id 420l5C4XGvzRk5W for ; Wed, 29 Aug 2018 21:18:07 +0900 (JST) Received: from mf04.melco.co.jp (unknown [133.141.98.184]) by mf04_second.melco.co.jp (Postfix) with ESMTP id 420l5C4sxlzRkCw for ; Wed, 29 Aug 2018 21:18:07 +0900 (JST) Received: from JPN01-TY1-obe.outbound.protection.outlook.com (unknown [23.103.139.178]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l5C4j7gzRkCn for ; Wed, 29 Aug 2018 21:18:07 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitsubishielectricgroup.onmicrosoft.com; s=selector1-mitsubishielectricgroup-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X+h+WJzfuJnEjmzp8ikyDHDXVTfizDF3zkvMCV9/n1Y=; b=S4u2nhRlFD+0cIfW5nPBrVKJBtXJvIgFvGJqYzhNP5NtmEAFnbdqvaiI6YRPHcpxMteWAN/mAOMaF4n3HqD1N5CJZbplpk6pHDNg4681DZCkGWZDnI0w+jouIz/cVDdhnoS29WZ07wvT7VTZ3zPdYnbkxoCDQZomoPa6PV5dgV4= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB0762.jpnprd01.prod.outlook.com (10.167.158.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.15; Wed, 29 Aug 2018 12:18:07 +0000 Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa]) by TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa%2]) with mapi id 15.20.1080.015; Wed, 29 Aug 2018 12:18:07 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 40/54] tracing: Add a clock attribute for hist triggers Thread-Index: AdQ/jMdC/3PGchBlQgCMnb3hvQsHZg== Date: Wed, 29 Aug 2018 12:17:11 +0000 Deferred-Delivery: Wed, 29 Aug 2018 12:15:00 +0000 Message-ID: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-melpop: 1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=Motai.Hirotaka@aj.MitsubishiElectric.co.jp; x-originating-ip: [153.231.200.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; TY1PR01MB0762; 6:HEwXm5Sr8uHyAiJ6bcGiNpIv26HTvQ6HTu7w0Lv/MYCOqpBsna6WSrZLFzpIfO0eGaeqbBypcUdW1e/NUkeUxTWdFu6iwF09Jee0uHUvxiBjwQPAGflzk0XlMDCXYveaqKmKIlBaGl9jrnIPomixdhGhovG6Gvoyvz1s6zeRSO+rHArN6UskLsKPS8yJTXhSpUPIXMRxe7DJeeT+YrJvD1zJwW7rYllOdTkOm0XQqYTwK8QBqb8ohwAI9pwZKH0Y8J9JdCqX7cMnWDxNgvUSpPs6TeUHNAnP2aeR2ldpFiVKiBnmOM+s1CWlo/7oZJ7JKayZBYk927BOAIrZqec+9gXFFD0pZVh7oqogVSK5CdXx4MX9HToyCEYY8WjhLNDiQIN/4WIH0277+fPogERV3XNBHVjo/ozCvO+hDY3N+qohayHx8LptKut2jEO/XNxb9QicMm2S4EFjfL1U6bCeQg==; 5:FF6qvKtA35iqjYecVqZ/DcXx0fojk8m97LyFabG6+C6J0/wXNFjlnnMN6rvGRBRzHzPv6H0E9Vc4y0K0p9rEcKoCBV9ewWQsb9qyPMzzAO6NfnMbaTZCp2RFj1Q4DVpIRlsmBnJFg1ZG6BtKXTfkXLb0Jxabc6r/VW/7180NIKg=; 7:5hczyCFUvreMshlQce1kdBdhXpAq466uwybkwqjfTxd7SssogiUyy0EIB9gUMDwWLPhgnAvQcN+SomOIQmduK4zPO9Vrm7+Zn59ZutjtHnAeSuDvduerOiLh2oKKt2m2WiO5Lkaey2XtIx4HKfCU5kjY6XYG65b8QTSKhsnvHzBtw/1Y9ySgEqTG8IsZxMorE9gc38MuFFmdX1ORWUCw4Hy0hDIgbH0nXz6uaaQYidGB/7RkCteSd8nJ2J/p0XBF x-ms-office365-filtering-correlation-id: 05cfd941-77cb-416c-8eda-08d60da97a3c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB0762; x-ms-traffictypediagnostic: TY1PR01MB0762: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(42068640409301)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699016); SRVR:TY1PR01MB0762; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB0762; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(396003)(346002)(376002)(136003)(366004)(199004)(189003)(7696005)(186003)(72206003)(6116002)(478600001)(3846002)(1857600001)(256004)(74482002)(5250100002)(5660300001)(14444005)(966005)(2501003)(99286004)(2900100001)(8936002)(53936002)(68736007)(33656002)(9686003)(2906002)(97736004)(6306002)(26005)(476003)(7736002)(305945005)(74316002)(6666003)(316002)(14454004)(486006)(55016002)(81166006)(5640700003)(66066001)(8676002)(86362001)(6436002)(2351001)(6506007)(106356001)(25786009)(6916009)(105586002)(102836004)(575784001)(81156014)(21314002); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB0762; H:TY1PR01MB1692.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:0; MX:1; received-spf: None (protection.outlook.com: aj.MitsubishiElectric.co.jp does not designate permitted sender hosts) x-microsoft-antispam-message-info: GuGMtNA771h+IS61rnKW9HYEECKZzWRJlpdGrgyIJwo6wNqkZ3FP8IULB7TB91Qj54zXSolPzN482ET03ZYT1z9NDC3tRhPtdEPud4vcpSDoUiP4F91pYKlB9TiL7ar4oKE0ZWbMKCIzXKWTEiP/QqIZvR5lheIaDc0qlH2QziQHtwl+eY5PAMOq+3EULikHIQKo+rOvdOBm5TMutdeuoz86st0/wBQkLs6NNWcnchuThG5OFGCW26Jh76jXP518fO8aFu0HipbpDwLnj59U6S8Ye0hYjQtCjUtQ0EwyXhf6FQtscIBM+aaBe3/k2g7IQul2YWxyCvMH4snpQLXMmeT/2bHNh5hWlX1MsUGo4vg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 05cfd941-77cb-416c-8eda-08d60da97a3c X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6447 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB0762 Subject: [LTSI-dev] [PATCH 40/54] tracing: Add a clock attribute for hist triggers X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP The default clock if timestamps are used in a histogram is "global". If timestamps aren't used, the clock is irrelevant. Use the "clock=" param only if you want to override the default "global" clock for a histogram with timestamps. Link: http://lkml.kernel.org/r/427bed1389c5d22aa40c3e0683e30cc3d151e260.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Rajvi Jingar Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit a4072fe85ba3671720cab0788291af953db27318) Signed-off-by: Hirotaka MOTAI --- Documentation/trace/histogram.txt | 11 +++++++- kernel/trace/trace_events_hist.c | 42 ++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt index df08882d..6e05510a 100644 --- a/Documentation/trace/histogram.txt +++ b/Documentation/trace/histogram.txt @@ -1666,17 +1666,26 @@ features have been added to the hist trigger support: underlying ftrace ring buffer. This timestamp is now exposed as a a synthetic field named 'common_timestamp' which can be used in histograms as if it were any other event field; it isn't an actual field in the trace format but rather is a synthesized value that nonetheless can be used as if it were an actual field. By default it is in units of nanoseconds; appending '.usecs' to a common_timestamp field changes the units to microseconds. -These features are decribed in more detail in the following sections. +A note on inter-event timestamps: If common_timestamp is used in a +histogram, the trace buffer is automatically switched over to using +absolute timestamps and the "global" trace clock, in order to avoid +bogus timestamp differences with other clocks that aren't coherent +across CPUs. This can be overridden by specifying one of the other +trace clocks instead, using the "clock=XXX" hist trigger attribute, +where XXX is any of the clocks listed in the tracing/trace_clock +pseudo-file. + +These features are described in more detail in the following sections. 2.2.1 Histogram Variables ------------------------- Variables are simply named locations used for saving and retrieving values between matching events. A 'matching' event is defined as an event that has a matching key - if a variable is saved for a histogram entry corresponding to that key, any subsequent event with a matching diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 8719b0ea..f7d0da20 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -237,16 +237,17 @@ struct var_defs { char *expr[TRACING_MAP_VARS_MAX]; }; struct hist_trigger_attrs { char *keys_str; char *vals_str; char *sort_key_str; char *name; + char *clock; bool pause; bool cont; bool clear; bool ts_in_usecs; unsigned int map_bits; char *assignment_str[TRACING_MAP_VARS_MAX]; unsigned int n_assignments; @@ -1771,16 +1772,17 @@ static void destroy_hist_trigger_attrs(struct hist_trigger_attrs *attrs) for (i = 0; i < attrs->n_actions; i++) kfree(attrs->action_str[i]); kfree(attrs->name); kfree(attrs->sort_key_str); kfree(attrs->keys_str); kfree(attrs->vals_str); + kfree(attrs->clock); kfree(attrs); } static int parse_action(char *str, struct hist_trigger_attrs *attrs) { int ret = -EINVAL; if (attrs->n_actions >= HIST_ACTIONS_MAX) @@ -1826,16 +1828,29 @@ static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) goto out; } } else if (strncmp(str, "name=", strlen("name=")) == 0) { attrs->name = kstrdup(str, GFP_KERNEL); if (!attrs->name) { ret = -ENOMEM; goto out; } + } else if (strncmp(str, "clock=", strlen("clock=")) == 0) { + strsep(&str, "="); + if (!str) { + ret = -EINVAL; + goto out; + } + + str = strstrip(str); + attrs->clock = kstrdup(str, GFP_KERNEL); + if (!attrs->clock) { + ret = -ENOMEM; + goto out; + } } else if (strncmp(str, "size=", strlen("size=")) == 0) { int map_bits = parse_map_size(str); if (map_bits < 0) { ret = map_bits; goto out; } attrs->map_bits = map_bits; @@ -1890,16 +1905,24 @@ static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) } } if (!attrs->keys_str) { ret = -EINVAL; goto free; } + if (!attrs->clock) { + attrs->clock = kstrdup("global", GFP_KERNEL); + if (!attrs->clock) { + ret = -ENOMEM; + goto free; + } + } + return attrs; free: destroy_hist_trigger_attrs(attrs); return ERR_PTR(ret); } static inline void save_comm(char *comm, struct task_struct *task) @@ -4929,16 +4952,18 @@ static int event_hist_trigger_print(struct seq_file *m, idx += hist_data->n_vars; hist_field_print(m, hist_data->fields[idx]); } if (sort_key->descending) seq_puts(m, ".descending"); } seq_printf(m, ":size=%u", (1 << hist_data->map->map_bits)); + if (hist_data->enable_timestamps) + seq_printf(m, ":clock=%s", hist_data->attrs->clock); print_actions_spec(m, hist_data); if (data->filter_str) seq_printf(m, " if %s", data->filter_str); if (data->paused) seq_puts(m, " [paused]"); @@ -5196,32 +5221,43 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops, ret = -ENOENT; goto out; } if (hist_data->attrs->pause) data->paused = true; if (named_data) { - destroy_hist_data(data->private_data); data->private_data = named_data->private_data; set_named_trigger_data(data, named_data); data->ops = &event_hist_trigger_named_ops; } if (data->ops->init) { ret = data->ops->init(data->ops, data); if (ret < 0) goto out; } - ret++; + if (hist_data->enable_timestamps) { + char *clock = hist_data->attrs->clock; + + ret = tracing_set_clock(file->tr, hist_data->attrs->clock); + if (ret) { + hist_err("Couldn't set trace_clock: ", clock); + goto out; + } - if (hist_data->enable_timestamps) tracing_set_time_stamp_abs(file->tr, true); + } + + if (named_data) + destroy_hist_data(hist_data); + + ret++; out: return ret; } static int hist_trigger_enable(struct event_trigger_data *data, struct trace_event_file *file) { int ret = 0;