From patchwork Tue Jun 12 14:43:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 9232 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 B27C023E37 for ; Tue, 12 Jun 2012 14:43:20 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 64B50A1846C for ; Tue, 12 Jun 2012 14:43:20 +0000 (UTC) Received: by ggnf1 with SMTP id f1so3794171ggn.11 for ; Tue, 12 Jun 2012 07:43:19 -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 :dkim-signature:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to:x-url :user-agent:x-gm-message-state; bh=ZkpQ95t8005AEO8S0Bu+sTJZxKlEe7A1JJg2krK3ONw=; b=hUKx42/19sVQObdhcEmzLK4jnBNbXxJWxF3CFvk7K0hU7vwkERYZk45aJdzmtJd3pc pgVkYQZCkGdblUi2Dbtx++XxwxJzxgFD+KXbMYXAk1OFiFfJ90iUy4E1jt4gFGyw1RMl PNoAcUKglDyTbowpz9jekWaoP4xKV9R9WmrTKYrrvDsbQcI6yzlwJNNNq77ImrfnrznX Zmv8v0k+kABP2Xkqb211EY8stG3HdPcS1X7Q9zN3KObnyW9FtlGxVehlomvZomoJMABa VtPw2uzeOp03+2BLuIXu3WPE9mVwjoTYWCjlCCQvyyCQnaHcdtfbEEY94lWkHBFbzYEa LWVA== Received: by 10.50.46.232 with SMTP id y8mr8437947igm.57.1339512199682; Tue, 12 Jun 2012 07:43:19 -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 v20csp170603ibb; Tue, 12 Jun 2012 07:43:18 -0700 (PDT) Received: by 10.220.66.3 with SMTP id l3mr14811191vci.51.1339512198031; Tue, 12 Jun 2012 07:43:18 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id dn3si11956025vdc.68.2012.06.12.07.43.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 07:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of arnaldo.melo@gmail.com designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of arnaldo.melo@gmail.com designates 209.85.220.178 as permitted sender) smtp.mail=arnaldo.melo@gmail.com; dkim=pass header.i=@gmail.com Received: by vcdm8 with SMTP id m8so3794460vcd.37 for ; Tue, 12 Jun 2012 07:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:x-url:user-agent; bh=ZkpQ95t8005AEO8S0Bu+sTJZxKlEe7A1JJg2krK3ONw=; b=xUsQokmvVrPV0LQZRzVNGmvPul3Z3iU+mOD5TfZGcuZEdgD2L3ruLx7mwfcDp9Krxr 1UVCQpsGIpAWCEU2TV87Y767JElUh0m/SI4KD50d6RK1a6zpaSNKk5F7OlFXXZ51Irrs e4OXY/skRRGlvRB+rYzwmMWmHnEuLzhVU6jYgh9j/WEafUYmzy/hoTVTYXdTK5PF8xAd 4WB8HTautSpNwj6EcIumRYfxTKXr37YRcsvmUCMCunbZeV5eS05bG7WQyhWPTOZRjEka B9M2nhb6Jwfw1/05URNqLImCQR7gcPd44C9czkJGaw5rqzGRcIjWVy/lQsO9VmuGhxIL GbvA== Received: by 10.220.106.135 with SMTP id x7mr14946665vco.28.1339512196118; Tue, 12 Jun 2012 07:43:16 -0700 (PDT) Received: from aninha.ghostprotocols.net (201.47.31.31.dynamic.adsl.gvt.net.br. [201.47.31.31]) by mx.google.com with ESMTPS id z17sm24296179vdg.13.2012.06.12.07.43.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 07:43:13 -0700 (PDT) Sender: Arnaldo Carvalho de Melo Received: by aninha.ghostprotocols.net (Postfix, from userid 500) id D7B4C2586D; Tue, 12 Jun 2012 11:43:08 -0300 (BRT) Date: Tue, 12 Jun 2012 11:43:08 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim , Dmitry Antipov Cc: Ingo Molnar , Paul Mackerras , Peter Zijlstra , linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: Re: [PATCH] perf report: fix event name reporting Message-ID: <20120612144308.GA5816@infradead.org> References: <1339158207-20575-1-git-send-email-dmitry.antipov@linaro.org> <20120611141416.GC2202@infradead.org> <87y5nt598x.fsf@sejong.aot.lge.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87y5nt598x.fsf@sejong.aot.lge.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkI4jorbMdVqa3JzguVSuxCzyXix6PF7qkJF7PZ0ad3+6GaLBEYLPFbLIMTyaolnr8ojwZc Em Tue, Jun 12, 2012 at 03:34:22PM +0900, Namhyung Kim escreveu: > On Mon, 11 Jun 2012 11:14:16 -0300, Arnaldo Carvalho de Melo wrote: > > Em Fri, Jun 08, 2012 at 04:23:27PM +0400, Dmitry Antipov escreveu: > >> Use trace_find_event to find event name before looking through > >> /sys files. This helps 'perf report' to show real event names > >> instead of 'unknown:unknown' when processing perf.data recorded > >> on another machine. > > > > We have to somehow tell perf_evlist__tty_browse_hists that it should try > > to figure out the name of the event by looking at _either_ /sys (local > > events) or what came in the perf.data file. > > > > That is because 'perf top' and 'perf report' uses > > perf_evlist__tty_browse_hists. One is for local events (top) and the > > other for perf.data files, that may or not be for local (in the sense of > > running the same kernel for record + report) or for "remote" (running on > > the same machine but with a different kernel at record than the one used > > at report) or from a different machine altogether, perhaps even > > different arch. > > I just thought that we should always consider the remote case first and > falls back to local case because if we looked for local events, the > remote events (perf.data) would not exist so that it can falls to the > local case safely. > > Now I think that we need a session method to check whether the current > session is local or remote, and acts something based on that info. We just need to get the data from the perf.data file as early as possible, i.e. just after processing the perf.data headers, like in the attached patch. Dmitry, can you please try it? - Arnaldo >From cb9dd49e11f83d548c822d7022ac180b0518b25c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 11 Jun 2012 19:03:32 -0300 Subject: [PATCH 1/1] perf tools: Fix synthesizing tracepoint names from the perf.data headers Content-Type: text/plain; charset="UTF-8" We need to use the per event info snapshoted at record time to synthesize the events name, so do it just after reading the perf.data headers, when we already processed the /sys events data, otherwise we'll end up using the local /sys that only by sheer luck will have the same tracepoint ID -> real event association. Example: # uname -a Linux felicio.ghostprotocols.net 3.4.0-rc5+ #1 SMP Sat May 19 15:27:11 BRT 2012 x86_64 x86_64 x86_64 GNU/Linux # perf record -e sched:sched_switch usleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.015 MB perf.data (~648 samples) ] # cat /t/events/sched/sched_switch/id 279 # perf evlist -v sched:sched_switch: sample_freq=1, type: 2, config: 279, size: 80, sample_type: 1159, read_format: 7, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, sample_id_all: 1, exclude_guest: 1 # So on the above machine the sched:sched_switch has tracepoint id 279, but on the machine were we'll analyse it it has a different id: $ cat /t/events/sched/sched_switch/id 56 $ perf evlist -i /tmp/perf.data kmem:mm_balancedirty_writeout $ cat /t/events/kmem/mm_balancedirty_writeout/id 279 With this fix: $ perf evlist -i /tmp/perf.data sched:sched_switch Reported-by: Dmitry Antipov Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-auwks8fpuhmrdpiefs55o5oz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 4f9b247..e909d43 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2093,6 +2093,35 @@ static int read_attr(int fd, struct perf_header *ph, return ret <= 0 ? -1 : 0; } +static int perf_evsel__set_tracepoint_name(struct perf_evsel *evsel) +{ + struct event_format *event = trace_find_event(evsel->attr.config); + char bf[128]; + + if (event == NULL) + return -1; + + snprintf(bf, sizeof(bf), "%s:%s", event->system, event->name); + evsel->name = strdup(bf); + if (event->name == NULL) + return -1; + + return 0; +} + +static int perf_evlist__set_tracepoint_names(struct perf_evlist *evlist) +{ + struct perf_evsel *pos; + + list_for_each_entry(pos, &evlist->entries, node) { + if (pos->attr.type == PERF_TYPE_TRACEPOINT && + perf_evsel__set_tracepoint_name(pos)) + return -1; + } + + return 0; +} + int perf_session__read_header(struct perf_session *session, int fd) { struct perf_header *header = &session->header; @@ -2174,6 +2203,9 @@ int perf_session__read_header(struct perf_session *session, int fd) lseek(fd, header->data_offset, SEEK_SET); + if (perf_evlist__set_tracepoint_names(session->evlist)) + goto out_delete_evlist; + header->frozen = 1; return 0; out_errno: