Received: by 10.223.164.202 with SMTP id h10csp682427wrb; Thu, 9 Nov 2017 12:37:51 -0800 (PST) X-Google-Smtp-Source: ABhQp+R0Qtfn7NwLM885ctJvUAFBu7ohKCaiKSds9FcS74SgSPyDdqaSEm+RDT83gCCDfqs0a2Sq X-Received: by 10.84.176.65 with SMTP id u59mr1619089plb.21.1510259871175; Thu, 09 Nov 2017 12:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510259871; cv=none; d=google.com; s=arc-20160816; b=NdtNOQql9OMJkUiUbvvH+/y2VJP47J3yitkFKOrAOqCnnCW+IBEBaMfNxARqN4977X 7CulVrkOK2EaX7LrE5ja5HoMqabQucg1eYxbMUWwFdCE1DIlSAJ5ZCxWYJ1ygaHFgFLo 2kfbDTo7a1Xy6nSgLkZATon6+LZGavSXJ5tqvU/wPrKHM80ftz0zNdttr+gzw9/gfsAJ B/0V53ionHu4tRrsAWoZPtC2dHHZ4slABpXmQei+O2Hfk8va4Oz8b2WU3gf2BcZFun3w rbxcYmEt+WcMyeFgs7vU7OOZjSKu0e3utyqHB47wGxUKtbemDVChek4ycNS8Uw/FX8kn DDuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=n0/Bvch++2emMNELzRjCsAFPM/hLjiuqyL9F/ko9Nbc=; b=vDQYBLS5w1JsEtSi28Cly86QTawqxaM5/kpM+3ot5xhUbTyjNIlmtlF9jseiWncNFs mGofiNizkah+LHe5aiKKw4lJaA94/USRgITYxEveST77k/0eaZUl+ug6c1bj4UHEUlVb z7BhcBQBjY63OQjPkR6+YIDn53462WzCisWOwb10BDdDDvcH8oktY0T0ZgIVqGFL1HZh iVKvWKnghoTqXrc7Uk9kTmvxfLsX2ZkPkBRj8S1w9r4ILAeUVlR0LCw8elb/ANmtTwVH CluxsOMnEs5d8Dq2gjFWlncLGjrowEKJQnZ0dELVL+5wd5f8AtT5KFs7Zks/mPvW6PBq qRjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n63si7620857pfb.377.2017.11.09.12.37.39; Thu, 09 Nov 2017 12:37:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755281AbdKIUgM (ORCPT + 83 others); Thu, 9 Nov 2017 15:36:12 -0500 Received: from mga02.intel.com ([134.134.136.20]:15128 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753823AbdKIUgF (ORCPT ); Thu, 9 Nov 2017 15:36:05 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 12:36:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,370,1505804400"; d="scan'208";a="883219" Received: from dkusalov-mobl4.amr.corp.intel.com (HELO localhost) ([10.254.117.34]) by fmsmga001.fm.intel.com with ESMTP; 09 Nov 2017 12:36:02 -0800 From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, rajvi.jingar@intel.com, julia@ni.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v5 34/37] tracing: Add a clock attribute for hist triggers Date: Thu, 9 Nov 2017 14:34:05 -0600 Message-Id: X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Tom Zanussi Signed-off-by: Rajvi Jingar --- Documentation/trace/histogram.txt | 11 ++++++++++- kernel/trace/trace_events_hist.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt index 0eea8b9..aa450bb 100644 --- a/Documentation/trace/histogram.txt +++ b/Documentation/trace/histogram.txt @@ -1674,7 +1674,16 @@ features have been added to the hist trigger support: 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 ------------------------- diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 6e2979a..4d1b636 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -242,6 +242,7 @@ struct hist_trigger_attrs { char *vals_str; char *sort_key_str; char *name; + char *clock; bool pause; bool cont; bool clear; @@ -1790,6 +1791,7 @@ static void destroy_hist_trigger_attrs(struct hist_trigger_attrs *attrs) kfree(attrs->sort_key_str); kfree(attrs->keys_str); kfree(attrs->vals_str); + kfree(attrs->clock); kfree(attrs); } @@ -1845,6 +1847,19 @@ static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) 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); @@ -1908,6 +1923,14 @@ static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) 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); @@ -4917,6 +4940,8 @@ static int event_hist_trigger_print(struct seq_file *m, 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); @@ -5179,10 +5204,19 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops, 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); + } + + ret++; out: return ret; } -- 1.9.3 From 1583625175757698371@xxx Thu Nov 09 21:24:16 +0000 2017 X-GM-THRID: 1583625175757698371 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread