From patchwork Wed Jul 4 09:23:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 9816 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id BEFAD23E47 for ; Wed, 4 Jul 2012 09:20:56 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7446FA18797 for ; Wed, 4 Jul 2012 09:20:56 +0000 (UTC) Received: by yenq6 with SMTP id q6so6753212yen.11 for ; Wed, 04 Jul 2012 02:20:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:message-id :date:from:user-agent:mime-version:to:cc:subject:content-type :x-gm-message-state; bh=zo6GNwgcjdCA6C9eUmk0RxFsw9fWce3Zu+LIbqUm5mo=; b=b6NI9PxzRrGdSwIOMyfw5vtUysam88CJXB0wk1wdRW/eCVpI5/2XFMqDKebFMvoKwa gPGVaH2mwk5jyV5gVIhVFeReg7w/zI3BZJuagfnOLOw11Uoi82v+474sH6vyIkULdcB/ Rw1hfgdbneKSDmTpvcImqONE0n2tWqsMLoAGdnoXWYFnK9GGcdDLpzx6g9NOxubFWFV0 /PD71tYul90qp4CocE41AQ4UkZD2QLq2+L/DvfJPrC5eMAPaNQrEErh36O4ggApzhSMz GYxmFJ6LO+BLNkvpobamg1f/Ejo6BnmsJGh6hnlcszHf+G6ycoCIeYjsOa+5J2vv32vE zXOQ== Received: by 10.42.89.72 with SMTP id f8mr10807376icm.33.1341393655695; Wed, 04 Jul 2012 02:20:55 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp51252ibb; Wed, 4 Jul 2012 02:20:54 -0700 (PDT) Received: by 10.112.86.105 with SMTP id o9mr9685299lbz.32.1341393653930; Wed, 04 Jul 2012 02:20:53 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id jc5si22052359lab.63.2012.07.04.02.20.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jul 2012 02:20:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.178 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) client-ip=209.85.217.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.217.178 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) smtp.mail=dmitry.antipov@linaro.org Received: by lbbgj10 with SMTP id gj10so13613067lbb.37 for ; Wed, 04 Jul 2012 02:20:53 -0700 (PDT) Received: by 10.152.122.12 with SMTP id lo12mr21010514lab.3.1341393652963; Wed, 04 Jul 2012 02:20:52 -0700 (PDT) Received: from localhost.localdomain ([213.87.135.221]) by mx.google.com with ESMTPS id fd1sm13474461lbb.7.2012.07.04.02.20.49 (version=SSLv3 cipher=OTHER); Wed, 04 Jul 2012 02:20:52 -0700 (PDT) Message-ID: <4FF40B7E.20202@linaro.org> Date: Wed, 04 Jul 2012 13:23:10 +0400 From: Dmitry Antipov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo CC: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: perf sched replay again X-Gm-Message-State: ALoCoQlIKEqLTzMF+Tw67lRKwPPZDVmiIqDDSm1eOwfsyKplb2RVtbizJrBn043uAUlbCpszlMhs I remember that this was rejected some time ago. Nevertheless, is it possible to accept this until we will have a better solution? Dmitry >From 7b394670bee55ca694f921bd96f210b0d4c7dfe0 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 4 Jul 2012 13:20:59 +0400 Subject: [PATCH] perf sched replay: fix event lookup Use new function trace_find_event_by_name to lookup events before looking through /sys files. This helps 'perf sched replay' to map event names to IDs correctly when processing perf.data recorded on another machine. Signed-off-by: Dmitry Antipov --- tools/perf/util/evlist.c | 22 ++++++++++++++++++++-- tools/perf/util/trace-event-parse.c | 4 ++++ tools/perf/util/trace-event.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 7400fb3..58a5433 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -17,6 +17,7 @@ #include #include "parse-events.h" +#include "trace-event.h" #include @@ -242,12 +243,29 @@ int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, const struct perf_evsel_str_handler *assocs, size_t nr_assocs) { + struct event_format *event; struct perf_evsel *evsel; + char *p, *sys, *name; int err; - size_t i; + size_t i, off; for (i = 0; i < nr_assocs; i++) { - err = trace_event__id(assocs[i].name); + err = -ENOENT; + p = strchr(assocs[i].name, ':'); + if (!p) + goto out; + off = p - assocs[i].name; + sys = malloc(off + 1); + if (!sys) + err = -ENOMEM; + else { + memcpy(sys, assocs[i].name, off); + sys[off] = '\0'; + name = p + 1; + event = trace_find_event_by_name(sys, name); + err = event ? event->id : trace_event__id(assocs[i].name); + free(sys); + } if (err < 0) goto out; diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index df2fddb..44cbb40 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -176,6 +176,10 @@ struct event_format *trace_find_event(int type) return pevent_find_event(pevent, type); } +struct event_format *trace_find_event_by_name(const char *sys, const char *name) +{ + return pevent_find_event_by_name(pevent, sys, name); +} void print_trace_event(int cpu, void *data, int size) { diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 639852a..66f83a0 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -40,6 +40,7 @@ int parse_event_file(char *buf, unsigned long size, char *sys); struct pevent_record *trace_peek_data(int cpu); struct event_format *trace_find_event(int type); +struct event_format *trace_find_event_by_name(const char *sys, const char *name); unsigned long long raw_field_value(struct event_format *event, const char *name, void *data);