From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC4F8C433DB for ; Fri, 22 Jan 2021 17:10:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93D3D233FA for ; Fri, 22 Jan 2021 17:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbhAVRJs (ORCPT ); Fri, 22 Jan 2021 12:09:48 -0500 Received: from foss.arm.com ([217.140.110.172]:55662 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729544AbhAVQUl (ORCPT ); Fri, 22 Jan 2021 11:20:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E47BD139F; Fri, 22 Jan 2021 08:19:48 -0800 (PST) Received: from e125528.arm.com (unknown [10.57.9.161]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 79D3B3F719; Fri, 22 Jan 2021 08:19:44 -0800 (PST) From: Alexandre Truong To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Alexandre Truong , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kemeng Shi , Ian Rogers , Andi Kleen , Kan Liang , Jin Yao , Adrian Hunter , Suzuki K Poulose , Al Grant , James Clark , Wilco Dijkstra Subject: [PATCH 2/4] perf tools: add a mechanism to inject stack frames Date: Fri, 22 Jan 2021 16:18:52 +0000 Message-Id: <20210122161854.5289-2-alexandre.truong@arm.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210122161854.5289-1-alexandre.truong@arm.com> References: <20210122161854.5289-1-alexandre.truong@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a mechanism for platforms to inject stack frames for the leaf frame caller if there is enough information to determine a frame is missing from dwarf or other post processing mechanisms. Signed-off-by: Alexandre Truong Cc: John Garry Cc: Will Deacon Cc: Mathieu Poirier Cc: Leo Yan Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Kemeng Shi Cc: Ian Rogers Cc: Andi Kleen Cc: Kan Liang Cc: Jin Yao Cc: Adrian Hunter Cc: Suzuki K Poulose Cc: Al Grant Cc: James Clark Cc: Wilco Dijkstra --- tools/perf/util/machine.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 522ea3236bcc..40082d70eec1 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2671,6 +2671,12 @@ static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, return err; } +static u64 get_leaf_frame_caller(struct perf_sample *sample __maybe_unused, + struct thread *thread __maybe_unused) +{ + return 0; +} + static int thread__resolve_callchain_sample(struct thread *thread, struct callchain_cursor *cursor, struct evsel *evsel, @@ -2687,6 +2693,8 @@ static int thread__resolve_callchain_sample(struct thread *thread, int i, j, err, nr_entries; int skip_idx = -1; int first_call = 0; + u64 leaf_frame_caller; + int pos; if (chain) chain_nr = chain->nr; @@ -2811,6 +2819,21 @@ static int thread__resolve_callchain_sample(struct thread *thread, continue; } + pos = callchain_param.order == ORDER_CALLEE ? 2 : chain_nr - 2; + + if (i == pos) { + leaf_frame_caller = get_leaf_frame_caller(sample, thread); + + if (leaf_frame_caller && leaf_frame_caller != ip) { + + err = add_callchain_ip(thread, cursor, parent, + root_al, &cpumode, leaf_frame_caller, + false, NULL, NULL, 0); + if (err) + return (err < 0) ? err : 0; + } + } + err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip, false, NULL, NULL, 0); -- 2.23.0