From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933624AbeAXL5R (ORCPT ); Wed, 24 Jan 2018 06:57:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50912 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933363AbeAXLvw (ORCPT ); Wed, 24 Jan 2018 06:51:52 -0500 From: Jiri Olsa To: Peter Zijlstra , Ingo Molnar Cc: lkml , Namhyung Kim , David Ahern , Andi Kleen , Alexander Shishkin , Andy Lutomirski , Arnaldo Carvalho de Melo Subject: [PATCH 02/21] perf tools: Add perf_sample__process function Date: Wed, 24 Jan 2018 12:51:24 +0100 Message-Id: <20180124115143.14322-3-jolsa@kernel.org> In-Reply-To: <20180124115143.14322-1-jolsa@kernel.org> References: <20180124115143.14322-1-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Later we are going to process samples from another place in the code. Factor out perf_sample__process function for that purpose, that prepares iterator and calls the hist_entry_iter__add function. Link: http://lkml.kernel.org/n/tip-bh115ggpykl0wt8e7e3rolwn@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-report.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 697ccd2c68ca..9bae7f11691c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -193,6 +193,31 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter, return err; } +static int +perf_sample__process(struct perf_sample *sample, struct addr_location *al, + struct perf_evsel *evsel, struct report *rep) +{ + struct hist_entry_iter iter = { + .evsel = evsel, + .sample = sample, + .hide_unresolved = symbol_conf.hide_unresolved, + .add_entry_cb = hist_iter__report_callback, + }; + + if (sort__mode == SORT_MODE__BRANCH) { + iter.add_entry_cb = hist_iter__branch_callback; + iter.ops = &hist_iter_branch; + } else if (rep->mem_mode) { + iter.ops = &hist_iter_mem; + } else if (symbol_conf.cumulate_callchain) { + iter.ops = &hist_iter_cumulative; + } else { + iter.ops = &hist_iter_normal; + } + + return hist_entry_iter__add(&iter, al, rep->max_stack, rep); +} + static int process_sample_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, @@ -201,12 +226,6 @@ static int process_sample_event(struct perf_tool *tool, { struct report *rep = container_of(tool, struct report, tool); struct addr_location al; - struct hist_entry_iter iter = { - .evsel = evsel, - .sample = sample, - .hide_unresolved = symbol_conf.hide_unresolved, - .add_entry_cb = hist_iter__report_callback, - }; int ret = 0; if (perf_time__ranges_skip_sample(rep->ptime_range, rep->range_num, @@ -233,21 +252,12 @@ static int process_sample_event(struct perf_tool *tool, */ if (!sample->branch_stack) goto out_put; - - iter.add_entry_cb = hist_iter__branch_callback; - iter.ops = &hist_iter_branch; - } else if (rep->mem_mode) { - iter.ops = &hist_iter_mem; - } else if (symbol_conf.cumulate_callchain) { - iter.ops = &hist_iter_cumulative; - } else { - iter.ops = &hist_iter_normal; } if (al.map != NULL) al.map->dso->hit = 1; - ret = hist_entry_iter__add(&iter, &al, rep->max_stack, rep); + ret = perf_sample__process(sample, &al, evsel, rep); if (ret < 0) pr_debug("problem adding hist entry, skipping event\n"); out_put: -- 2.13.6