From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751912AbdBJHlh (ORCPT ); Fri, 10 Feb 2017 02:41:37 -0500 Received: from terminus.zytor.com ([65.50.211.136]:50638 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbdBJHlg (ORCPT ); Fri, 10 Feb 2017 02:41:36 -0500 Date: Thu, 9 Feb 2017 23:41:20 -0800 From: tip-bot for Andi Kleen Message-ID: Cc: jolsa@kernel.org, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, ak@linux.intel.com Reply-To: jolsa@kernel.org, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de In-Reply-To: <20170128020345.19007-2-andi@firstfloor.org> References: <20170128020345.19007-2-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf jevents: Parse eventcode as number Git-Commit-ID: d581141970ef3965c1624960fa928d765afd8a3e 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: d581141970ef3965c1624960fa928d765afd8a3e Gitweb: http://git.kernel.org/tip/d581141970ef3965c1624960fa928d765afd8a3e Author: Andi Kleen AuthorDate: Fri, 27 Jan 2017 18:03:36 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 8 Feb 2017 08:55:02 -0300 perf jevents: Parse eventcode as number The next patch needs to modify event code. Previously eventcode was just passed through as a string. Now parse it as a number. v2: Don't special case 0 Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20170128020345.19007-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/pmu-events/jevents.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 41611d7..551377b 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -135,7 +135,6 @@ static struct field { const char *field; const char *kernel; } fields[] = { - { "EventCode", "event=" }, { "UMask", "umask=" }, { "CounterMask", "cmask=" }, { "Invert", "inv=" }, @@ -343,6 +342,7 @@ int json_events(const char *fn, jsmntok_t *tokens, *tok; int i, j, len; char *map; + char buf[128]; if (!fn) return -ENOENT; @@ -356,6 +356,7 @@ int json_events(const char *fn, char *event = NULL, *desc = NULL, *name = NULL; char *long_desc = NULL; char *extra_desc = NULL; + unsigned long long eventcode = 0; struct msrmap *msr = NULL; jsmntok_t *msrval = NULL; jsmntok_t *precise = NULL; @@ -376,6 +377,11 @@ int json_events(const char *fn, nz = !json_streq(map, val, "0"); if (match_field(map, field, nz, &event, val)) { /* ok */ + } else if (json_streq(map, field, "EventCode")) { + char *code = NULL; + addfield(map, &code, "", "", val); + eventcode |= strtoul(code, NULL, 0); + free(code); } else if (json_streq(map, field, "EventName")) { addfield(map, &name, "", "", val); } else if (json_streq(map, field, "BriefDescription")) { @@ -410,6 +416,8 @@ int json_events(const char *fn, addfield(map, &extra_desc, " ", "(Precise event)", NULL); } + snprintf(buf, sizeof buf, "event=%#llx", eventcode); + addfield(map, &event, ",", buf, NULL); if (desc && extra_desc) addfield(map, &desc, " ", extra_desc, NULL); if (long_desc && extra_desc)