Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935248AbcKWXaG (ORCPT ); Wed, 23 Nov 2016 18:30:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49220 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934301AbcKWXaF (ORCPT ); Wed, 23 Nov 2016 18:30:05 -0500 Date: Thu, 24 Nov 2016 00:18:32 +0100 From: Jiri Olsa To: kan.liang@intel.com Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, wangnan0@huawei.com, mark.rutland@arm.com, andi@firstfloor.org Subject: Re: [PATCH 14/14] perf script: show overhead events Message-ID: <20161123231832.GJ15978@krava> References: <1479894292-16277-1-git-send-email-kan.liang@intel.com> <1479894292-16277-15-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479894292-16277-15-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 23 Nov 2016 23:18:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2015 Lines: 67 On Wed, Nov 23, 2016 at 04:44:52AM -0500, kan.liang@intel.com wrote: > From: Kan Liang > > Introduce a new option --show-overhead to show overhead events in perf > script > > Signed-off-by: Kan Liang > --- > tools/perf/builtin-script.c | 36 ++++++++++++++++++++++++++++++++++++ > tools/perf/util/event.c | 37 +++++++++++++++++++++++++++++++++++++ > tools/perf/util/event.h | 1 + > 3 files changed, 74 insertions(+) > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index e1daff3..76d9747 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c > @@ -829,6 +829,7 @@ struct perf_script { > bool show_task_events; > bool show_mmap_events; > bool show_switch_events; > + bool show_overhead; > bool allocated; > struct cpu_map *cpus; > struct thread_map *threads; > @@ -1264,6 +1265,37 @@ static int process_switch_event(struct perf_tool *tool, > return 0; > } > > +static int process_overhead_event(struct perf_tool *tool, > + union perf_event *event, > + struct perf_sample *sample, > + struct machine *machine) > +{ > + struct thread *thread; > + struct perf_script *script = container_of(tool, struct perf_script, tool); > + struct perf_session *session = script->session; > + struct perf_evsel *evsel; > + > + if (perf_event__process_switch(tool, event, sample, machine) < 0) > + return -1; process_switch event? copy&paste error? jirka > + if (sample) { > + evsel = perf_evlist__id2evsel(session->evlist, sample->id); > + thread = machine__findnew_thread(machine, sample->pid, sample->tid); > + if (thread == NULL) { > + pr_debug("problem processing OVERHEAD event, skipping it.\n"); > + return -1; > + } > + > + print_sample_start(sample, thread, evsel); > + perf_event__fprintf(event, stdout); > + thread__put(thread); > + } else { > + /* USER OVERHEAD event */ > + perf_event__fprintf(event, stdout); > + } > + > + return 0; > +} > + SNIP