Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755940Ab3IYMxc (ORCPT ); Wed, 25 Sep 2013 08:53:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54395 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755700Ab3IYMvl (ORCPT ); Wed, 25 Sep 2013 08:51:41 -0400 From: Jiri Olsa To: linux-kernel@vger.kernel.org Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Corey Ashford , Frederic Weisbecker , Ingo Molnar , Paul Mackerras , Peter Zijlstra Subject: [PATCH 16/21] perf tools: Allow numeric event to change name via name term Date: Wed, 25 Sep 2013 14:50:42 +0200 Message-Id: <1380113447-17144-17-git-send-email-jolsa@redhat.com> In-Reply-To: <1380113447-17144-1-git-send-email-jolsa@redhat.com> References: <1380113447-17144-1-git-send-email-jolsa@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2704 Lines: 92 Allowing numeric event to change name via name term, so it's possible to change following event name: $ ./perf stat -e 'cycles:k,cycles/name=cycles_irq/k' kill usage: kill [ -s signal | -p ] [ -a ] pid ... kill -l [ signal ] Performance counter stats for 'kill': 958,972 cycles:k # 0.000 GHz 958,972 cycles_irq # 0.000 GHz 0.001047556 seconds time elapsed It'll be useful for aliasing/distinguishing events for on/off toggling terms. Signed-off-by: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9812531..1957849 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -583,6 +583,25 @@ do { \ #undef CHECK_TYPE_VAL } +static int parse_events__is_name_term(struct parse_events_term *term) +{ + return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME; +} + +static char *pmu_event_name(struct list_head *head_terms) +{ + struct parse_events_term *term; + + if (!head_terms) + return NULL; + + list_for_each_entry(term, head_terms, list) + if (parse_events__is_name_term(term)) + return term->val.str; + + return NULL; +} + static int config_attr(struct perf_event_attr *attr, struct list_head *head, int fail) { @@ -609,23 +628,7 @@ int parse_events_add_numeric(struct list_head *list, int *idx, config_attr(&attr, head_config, 1)) return -EINVAL; - return add_event(list, idx, &attr, NULL); -} - -static int parse_events__is_name_term(struct parse_events_term *term) -{ - return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME; -} - -static char *pmu_event_name(struct list_head *head_terms) -{ - struct parse_events_term *term; - - list_for_each_entry(term, head_terms, list) - if (parse_events__is_name_term(term)) - return term->val.str; - - return NULL; + return add_event(list, idx, &attr, pmu_event_name(terms)); } int parse_events_add_pmu(struct list_head *list, int *idx, -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/