Received: by 10.223.164.202 with SMTP id h10csp1625685wrb; Sat, 18 Nov 2017 02:57:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMYTVSz5l81e7o7VdiCQwo9TCrp5Y0D8rymj1VEUmymnkkQaOqc6WoA0Bw4WmJfzsx90W5nY X-Received: by 10.101.66.197 with SMTP id l5mr7923002pgp.240.1511002624552; Sat, 18 Nov 2017 02:57:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511002624; cv=none; d=google.com; s=arc-20160816; b=q4lswUeoJbRhaEYzFqlqxgZhARSFc58nGyEVSXys7N36B3aCfZdkj3b8svOtSj50k/ zAPMzPRk8tqvlscDCyXSfGLhzlNokpNlu5DAWSMQsYrsQUy/Qb4hIKUTvOACx4VNTdtY Z7nfWCKhm+YEJfXo7hPnk2BfwBEs68eUWGRmNLRs+HP4rgBZQJDqHdZJ5e1sVnJepFcn Ews7FHUy0Tn0CM0SIUz6YKkgQ6X99g6Ap+LDeqYBtwp/lQvQN0A7vDZygbg7KzQwtNnQ F9LhKtfSQZ6VX3T4zNtrKSJdXN76LQljYmB7EtWpnIEOt2ccstPsFsQeTSDeGnXX/H+X HxaQ== 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=+q10L21IDKgqHl/c8xEdNNRlUvgLUhWb5yxw1DSbfrs=; b=FbcuDJbvYOOBK5s8aKtbFh4EP3Rnbc+kW1nOH2FWtLB+R7LiNrycdGwD7niqbNX3YH HCO0wMMT6r6lAx+8AiUXP+NcEv1QbTWNfNgB24Jduu3GmskzQj5d9UKJrtP7AAb2tEaU aJkjK0yavhFBDQY6N89m4tMUkB8fjpUrj3DYbLlhSBbyYZvhY5DeaKqGMvqGItbHq+7k /Gf1gI5nRoat5N8UFV//3bCHE8apdfJJdDnfFvKkTnlQ9JmVefRntKq5AgJT8Oapk9+E yaxX/I2GKzRpBr31AG7kwXriK8mkoqmwTwFPfuckM8QpWWWvudq7+dq+oyCggbcT/FFj IjRg== 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 a33si4390194pld.210.2017.11.18.02.56.50; Sat, 18 Nov 2017 02:57:04 -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 S1422823AbdKQUhI (ORCPT + 93 others); Fri, 17 Nov 2017 15:37:08 -0500 Received: from mga03.intel.com ([134.134.136.65]:49784 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936044AbdKQUfi (ORCPT ); Fri, 17 Nov 2017 15:35:38 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 12:35:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,411,1505804400"; d="scan'208";a="8893447" Received: from mjglynn-mobl.ger.corp.intel.com (HELO localhost) ([10.254.124.112]) by orsmga002.jf.intel.com with ESMTP; 17 Nov 2017 12:35:35 -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, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v6 29/37] tracing: Add cpu field for hist triggers Date: Fri, 17 Nov 2017 14:33:08 -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 A common key to use in a histogram is the cpuid - add a new cpu 'synthetic' field for that purpose. This field is named cpu rather than $cpu or $common_cpu because 'cpu' already exists as a special filter field and it makes more sense to match that rather than add another name for the same thing. Signed-off-by: Tom Zanussi --- Documentation/trace/histogram.txt | 17 +++++++++++++++++ kernel/trace/trace_events_hist.c | 28 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt index d1d92ed..cd3ec00 100644 --- a/Documentation/trace/histogram.txt +++ b/Documentation/trace/histogram.txt @@ -172,6 +172,23 @@ The examples below provide a more concrete illustration of the concepts and typical usage patterns discussed above. + 'special' event fields + ------------------------ + + There are a number of 'special event fields' available for use as + keys or values in a hist trigger. These look like and behave as if + they were actual event fields, but aren't really part of the event's + field definition or format file. They are however available for any + event, and can be used anywhere an actual event field could be. + 'Special' field names are always prefixed with a '$' character to + indicate that they're not normal fields (with the exception of + 'cpu', for compatibility with existing filter usage): + + $common_timestamp u64 - timestamp (from ring buffer) associated + with the event, in nanoseconds. May be + modified by .usecs to have timestamps + interpreted as microseconds. + cpu int - the cpu on which the event occurred. 6.2 'hist' trigger examples --------------------------- diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 121f7ef..afbfa9c 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -227,6 +227,7 @@ enum hist_field_flags { HIST_FIELD_FL_VAR = 1 << 12, HIST_FIELD_FL_EXPR = 1 << 13, HIST_FIELD_FL_VAR_REF = 1 << 14, + HIST_FIELD_FL_CPU = 1 << 15, }; struct var_defs { @@ -1177,6 +1178,16 @@ static u64 hist_field_timestamp(struct hist_field *hist_field, return ts; } +static u64 hist_field_cpu(struct hist_field *hist_field, + struct tracing_map_elt *elt, + struct ring_buffer_event *rbe, + void *event) +{ + int cpu = smp_processor_id(); + + return cpu; +} + static struct hist_field * check_field_for_var_ref(struct hist_field *hist_field, struct hist_trigger_data *var_data, @@ -1622,6 +1633,8 @@ static const char *hist_field_name(struct hist_field *field, field_name = hist_field_name(field->operands[0], ++level); else if (field->flags & HIST_FIELD_FL_TIMESTAMP) field_name = "$common_timestamp"; + else if (field->flags & HIST_FIELD_FL_CPU) + field_name = "cpu"; else if (field->flags & HIST_FIELD_FL_EXPR || field->flags & HIST_FIELD_FL_VAR_REF) { if (field->system) { @@ -2125,6 +2138,15 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, goto out; } + if (flags & HIST_FIELD_FL_CPU) { + hist_field->fn = hist_field_cpu; + hist_field->size = sizeof(int); + hist_field->type = kstrdup("int", GFP_KERNEL); + if (!hist_field->type) + goto free; + goto out; + } + if (WARN_ON_ONCE(!field)) goto out; @@ -2343,7 +2365,9 @@ static struct hist_field *parse_var_ref(struct hist_trigger_data *hist_data, hist_data->enable_timestamps = true; if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS) hist_data->attrs->ts_in_usecs = true; - } else { + } else if (strcmp(field_name, "cpu") == 0) + *flags |= HIST_FIELD_FL_CPU; + else { field = trace_find_event_field(file->event_call, field_name); if (!field || !field->size) { field = ERR_PTR(-EINVAL); @@ -4612,6 +4636,8 @@ static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) seq_puts(m, "$common_timestamp"); + else if (hist_field->flags & HIST_FIELD_FL_CPU) + seq_puts(m, "cpu"); else if (field_name) { if (hist_field->flags & HIST_FIELD_FL_VAR_REF) seq_putc(m, '$'); -- 1.9.3 From 1585436930686881783@xxx Wed Nov 29 21:21:21 +0000 2017 X-GM-THRID: 1585436930686881783 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread