From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752532AbcGMH3V (ORCPT ); Wed, 13 Jul 2016 03:29:21 -0400 Received: from terminus.zytor.com ([198.137.202.10]:42388 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbcGMH3J (ORCPT ); Wed, 13 Jul 2016 03:29:09 -0400 Date: Wed, 13 Jul 2016 00:28:54 -0700 From: tip-bot for Steven Rostedt Message-ID: Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org, namhyung@kernel.org, mingo@kernel.org, hpa@zytor.com, akpm@linux-foundation.org, tglx@linutronix.de, acme@redhat.com Reply-To: acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, akpm@linux-foundation.org, mingo@kernel.org, namhyung@kernel.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org In-Reply-To: <20160712093306.5b058103@gandalf.local.home> References: <20160712093306.5b058103@gandalf.local.home> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Add filter on task CPU id Git-Commit-ID: 6d248fbda59c51ef5f2e90e11551d9e17aeb226f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6d248fbda59c51ef5f2e90e11551d9e17aeb226f Gitweb: http://git.kernel.org/tip/6d248fbda59c51ef5f2e90e11551d9e17aeb226f Author: Steven Rostedt AuthorDate: Tue, 12 Jul 2016 09:33:06 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 12 Jul 2016 16:27:39 -0300 tools lib traceevent: Add filter on task CPU id Add a 'CPU' special field to allow the filter in trace-cmd report to filter on the task's CPU. By adding a special field 'CPU' (all caps) the user can now filter out tasks based on which CPU they are on. This is useful when filtering out (or in) a bunch of threads. -F 'CPU == 0' Signed-off-by: Steven Rostedt Cc: Andrew Morton Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20160712093306.5b058103@gandalf.local.home Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/parse-filter.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 88cccea..7c214ce 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -28,11 +28,16 @@ #include "event-utils.h" #define COMM "COMM" +#define CPU "CPU" static struct format_field comm = { .name = "COMM", }; +static struct format_field cpu = { + .name = "CPU", +}; + struct event_list { struct event_list *next; struct event_format *event; @@ -382,14 +387,17 @@ create_arg_item(struct event_format *event, const char *token, /* Consider this a field */ field = pevent_find_any_field(event, token); if (!field) { - if (strcmp(token, COMM) != 0) { + /* If token is 'COMM' or 'CPU' then it is special */ + if (strcmp(token, COMM) == 0) { + field = &comm; + } else if (strcmp(token, CPU) == 0) { + field = &cpu; + } else { /* not a field, Make it false */ arg->type = FILTER_ARG_BOOLEAN; arg->boolean.value = FILTER_FALSE; break; } - /* If token is 'COMM' then it is special */ - field = &comm; } arg->type = FILTER_ARG_FIELD; arg->field.field = field; @@ -1718,6 +1726,10 @@ get_value(struct event_format *event, return (unsigned long)name; } + /* Handle our dummy "cpu" field */ + if (field == &cpu) + return record->cpu; + pevent_read_number_field(field, record->data, &val); if (!(field->flags & FIELD_IS_SIGNED))