From nobody Mon Feb 9 00:20:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE88D174EFC; Fri, 5 Apr 2024 21:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351883; cv=none; b=DNfOz9LxrvnxU/ZT3XEQrTng3POpZ2tviurX4IAzxyZpBqY5y5aBl0jSh7FSiXUSmTMbnnhU0RyKDsY6/K76I5WDhxK6Zp9RHvojqvnTLdhQ4z7nHffyAbn9SROC20t2TJoAz8Ma+E6CdkBsFCCHzDHRieKoR+s2t+MFZroSJSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351883; c=relaxed/simple; bh=/mD4TfV2bgQIloZA4pLiUgBGcNpWC07TW8Yr0ztFQao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fg2zgMJuezsmbaqtcTakV9mE4ZX/0YGQosJBqM31VZt0zy7+nG3h75ompC5zitWBPAEZLO6i6ePfmDCfwWxIOEfaGMcIsO4N8aSX3a/YZq3/JW0eT/AGGOhbLbJjQNfq8XccvoFJLKVmlg40zhJAkU82b5JC+5gv+lZFzztRWEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E2EsdL94; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E2EsdL94" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A423C43394; Fri, 5 Apr 2024 21:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712351882; bh=/mD4TfV2bgQIloZA4pLiUgBGcNpWC07TW8Yr0ztFQao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2EsdL94x3bXSp5rB9EZspfBC/kRewIvwocNqgJ1rPPJFjmKWiEz2TKy2HozZwtD4 8bUDcz7g9TlXjGb+dkVPMAL5H5okG40UfM+gJRkWcK3koJdsiW4tv13DMDmANS/LJw uvNrBi/txRbqbZ9W5GOCq5kJFbt8wZRUGaMk26EuWe7cwY0WgE/hWdCMEiCPc7BAJ4 j/2ndT5mbgkNCUul8R0wR7dFBnMRMSN2jHoWd9s1RiBbXmoDHuIC3DQmlJTn3wkUaw nFsaadzLAR1ArSTzJPNohjcQKAbuugTgf3poKKpsi5sWv0cwLbu6xwMdt3uUlaH2/s hV4c8TXDCu7ug== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 1/4] perf annotate: Make sure to call symbol__annotate2() in TUI Date: Fri, 5 Apr 2024 14:17:57 -0700 Message-ID: <20240405211800.1412920-2-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240405211800.1412920-1-namhyung@kernel.org> References: <20240405211800.1412920-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The symbol__annotate2() initializes some data structures needed by TUI. It has a logic to prevent calling it multiple times by checking if it has the annotated source. But data type profiling uses a different code (symbol__annotate) to allocate the annotated lines in advance. So TUI missed to call symbol__annotate2() when it shows the annotation browser. Make symbol__annotate() reentrant and handle that situation properly. This fixes a crash in the annotation browser started by perf report in TUI like below. $ perf report -s type,sym --tui # and press 'a' key and then move down Fixes: 81e57deec325 ("perf report: Support data type profiling") Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index ec5e21932876..4790c735599b 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -970,7 +970,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct = evsel *evsel, if (dso->annotate_warned) return -1; =20 - if (not_annotated) { + if (not_annotated || !sym->annotate2) { err =3D symbol__annotate2(ms, evsel, &browser.arch); if (err) { char msg[BUFSIZ]; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 35235147b111..ded9ad86df00 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -879,6 +879,9 @@ int symbol__annotate(struct map_symbol *ms, struct evse= l *evsel, if (parch) *parch =3D arch; =20 + if (!list_empty(¬es->src->source)) + return 0; + args.arch =3D arch; args.ms =3D *ms; if (annotate_opts.full_addr) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 00:20:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 862AC17554B; Fri, 5 Apr 2024 21:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351883; cv=none; b=hbkwJqbIDi7o7kVtj6TZ+pAFZv5JGAO9CWqcdHjsnJZUf0Jo8bqJ8SIC+PeZAYTZHsf8XGqcBK2lr9lUr2Rfcnzax2onmkdt2LpuoF0BXlaE0jaxf8V/Pm4kBscU6Ujup0xt0lSVWEtcbcXU4IJdShOp8W1wwRzWiHdNn5v/LUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351883; c=relaxed/simple; bh=Wot6ma/gg8ednN0U6RXz9Cy+ni+Dlc7ehc3kD04ODV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CsNbAImwiKzZyhDH8YjCeT8euXjOpSCfKjQJHa6ehzqClo+LHhjffyI49TnBi7KKivdYOKq7uAEtgQ/VxY94q854L7eptd8ajvYmgRniZvTDdYomFGrQR8tHi4Rz8xsFITZt/SZ9lEGpoWc+PhXUJxkA0+QSAaQI4fXfx5FGj/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WalGlqB6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WalGlqB6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A51C43390; Fri, 5 Apr 2024 21:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712351883; bh=Wot6ma/gg8ednN0U6RXz9Cy+ni+Dlc7ehc3kD04ODV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WalGlqB6KhBW5HQq5Gs95gX4YgYlz4gAZaqKDMKP+d016xOF0C+h0bDa27/EXQc/I arneBPLdXwQ5YYi/ks4Y/qqIlr+HQEnCpJaY4ir7KtMX/uUrp4d4jlWwLBl5JYZg6H 3YUGCxuOlEzpdXM8f9WkdQqivsyxtCFVb2W4sYi0DI3Ik9mVRa2PlMwuPmL/0ExjqG gBkehcbpcqMYML/S7nqS40DV9VPn4Y0Cy9BgqPyi+9XtdSSNRAP3HKmJplFnyqfQ5U /Gv7FChhsLR/0Pn9rVV/CY7Cu/b9YkNCg6ravtKWEzrScZu9NlIAzaE9EIpdETDeqo mGxQ/ISSaimcg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 2/4] perf annotate-data: Fix global variable lookup Date: Fri, 5 Apr 2024 14:17:58 -0700 Message-ID: <20240405211800.1412920-3-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240405211800.1412920-1-namhyung@kernel.org> References: <20240405211800.1412920-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The recent change in the global variable handling added a bug to miss setting the return value even if it found a data type. Also add the type name in the debug message. Fixes: 1ebb5e17ef21 ("perf annotate-data: Add get_global_var_type()") Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/util/annotate-data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-dat= a.c index 043d80791bd0..1047ea9d578c 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1468,8 +1468,10 @@ static int find_data_type_die(struct data_loc_info *= dloc, Dwarf_Die *type_die) &offset, type_die)) { dloc->type_offset =3D offset; =20 - pr_debug_dtp("found PC-rel by addr=3D%#"PRIx64" offset=3D%#x\n", + pr_debug_dtp("found PC-rel by addr=3D%#"PRIx64" offset=3D%#x", dloc->var_addr, offset); + pr_debug_type_name(type_die, TSR_KIND_TYPE); + ret =3D 0; goto out; } } --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 00:20:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12AF117555F; Fri, 5 Apr 2024 21:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351884; cv=none; b=gp6+h7ryhQmR3CLxoFnmpaBqNL5IDG4PQAgBrf+dHft7/ytRWyFWQK1cME6II8yfypjtVqgIVZRYJl2dz0trvD6Tt0vcoMHCL6BpcxnUlBNLoPwtILa+9TIfi42jWwXpGTL/MNW9emVeN+LEpV5d0DelH59ZErwSyEI3GhkdDnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351884; c=relaxed/simple; bh=LKDlW092ImDWCgqQqaKslE3/JEHI6TM1IPtRvR2f8ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BPd4tEks/p0175HtAdk8AKFKuuSGbJdbDnAnyY47fswb+QK0tKcaaA1iRTohNftjyCwvZ8uUUwpzgjN2/B9KD4ALCTXyJv7gH1yXwoeZ2GE5POItLWEm9jNv/OpJOgIcTrhVyntF/5yjxl0kAElVMNzpY5kd5YPG9CNyxjvMgBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MWNBseiG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MWNBseiG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 288D0C433B1; Fri, 5 Apr 2024 21:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712351883; bh=LKDlW092ImDWCgqQqaKslE3/JEHI6TM1IPtRvR2f8ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWNBseiGgt4SKG3NJgoYb0E1vBH8wm7ZpRS+t8qWo+avPiLcTqDDWUFvN/6sHxaOr vs29Ae1QQ5MJTeX5WRIbx43BStFb16OYlLmEq2xNpwyRUSzzRRyaRKY/jLRRk9O8Aw dDA+BimaqFWi+qjgY9N3kQwEYGT351b0PIgeXGdTkmNUqLVstLEbNmpCBsF+rDcOys LGFtxextlwn2VU6BN50r0CrQ9T2o6QCi8JirMMEUK4fV2Pz5EwdnolFqA54RjHXQW3 QWEdYd3OOQTWM41TtCe+6PWBIG9EXdGLPkg//kJnWBzNrTZE4Xc/UWPhbFrbPDXFFe PEKjCCHaJ4TEA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 3/4] perf annotate-data: Do not delete non-asm lines Date: Fri, 5 Apr 2024 14:17:59 -0700 Message-ID: <20240405211800.1412920-4-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240405211800.1412920-1-namhyung@kernel.org> References: <20240405211800.1412920-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For data type profiling, it removed non-instruction lines from the list of annotation lines. It was to simplify the implementation dealing with instructions like to calculate the PC-relative address and to search the shortest path to the target instruction or basic block. But it means that it removes all the comments and debug information in the annotate output like source file name and line numbers. To support both code annotation and data type annotation, it'd be better to keep the non-instruction lines as well. So this change is to skip those lines during the data type profiling and to display them in the normal perf annotate output. No function changes intended (other than having more lines). Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/util/annotate-data.c | 6 +++ tools/perf/util/annotate.c | 93 ++++++++++++++++++++++++--------- 2 files changed, 74 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-dat= a.c index 1047ea9d578c..b69a1cd1577a 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1314,6 +1314,8 @@ static int find_data_type_insn(struct data_loc_info *= dloc, int reg, list_for_each_entry(bb, basic_blocks, list) { struct disasm_line *dl =3D bb->begin; =20 + BUG_ON(bb->begin->al.offset =3D=3D -1 || bb->end->al.offset =3D=3D -1); + pr_debug_dtp("bb: [%"PRIx64" - %"PRIx64"]\n", bb->begin->al.offset, bb->end->al.offset); =20 @@ -1321,6 +1323,10 @@ static int find_data_type_insn(struct data_loc_info = *dloc, int reg, u64 this_ip =3D sym->start + dl->al.offset; u64 addr =3D map__rip_2objdump(dloc->ms->map, this_ip); =20 + /* Skip comment or debug info lines */ + if (dl->al.offset =3D=3D -1) + continue; + /* Update variable type at this address */ update_var_state(&state, dloc, addr, dl->al.offset, var_types); =20 diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index ded9ad86df00..9df82e58cf6e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2142,23 +2142,10 @@ int annotate_get_insn_location(struct arch *arch, s= truct disasm_line *dl, =20 static void symbol__ensure_annotate(struct map_symbol *ms, struct evsel *e= vsel) { - struct disasm_line *dl, *tmp_dl; - struct annotation *notes; - - notes =3D symbol__annotation(ms->sym); - if (!list_empty(¬es->src->source)) - return; - - if (symbol__annotate(ms, evsel, NULL) < 0) - return; + struct annotation *notes =3D symbol__annotation(ms->sym); =20 - /* remove non-insn disasm lines for simplicity */ - list_for_each_entry_safe(dl, tmp_dl, ¬es->src->source, al.node) { - if (dl->al.offset =3D=3D -1) { - list_del(&dl->al.node); - free(dl); - } - } + if (list_empty(¬es->src->source)) + symbol__annotate(ms, evsel, NULL); } =20 static struct disasm_line *find_disasm_line(struct symbol *sym, u64 ip, @@ -2170,6 +2157,9 @@ static struct disasm_line *find_disasm_line(struct sy= mbol *sym, u64 ip, notes =3D symbol__annotation(sym); =20 list_for_each_entry(dl, ¬es->src->source, al.node) { + if (dl->al.offset =3D=3D -1) + continue; + if (sym->start + dl->al.offset =3D=3D ip) { /* * llvm-objdump places "lock" in a separate line and @@ -2234,6 +2224,46 @@ static bool is_stack_canary(struct arch *arch, struc= t annotated_op_loc *loc) return false; } =20 +static struct disasm_line * +annotation__prev_asm_line(struct annotation *notes, struct disasm_line *cu= rr) +{ + struct list_head *sources =3D ¬es->src->source; + struct disasm_line *prev; + + if (curr =3D=3D list_first_entry(sources, struct disasm_line, al.node)) + return NULL; + + prev =3D list_prev_entry(curr, al.node); + while (prev->al.offset =3D=3D -1 && + prev !=3D list_first_entry(sources, struct disasm_line, al.node)) + prev =3D list_prev_entry(prev, al.node); + + if (prev->al.offset =3D=3D -1) + return NULL; + + return prev; +} + +static struct disasm_line * +annotation__next_asm_line(struct annotation *notes, struct disasm_line *cu= rr) +{ + struct list_head *sources =3D ¬es->src->source; + struct disasm_line *next; + + if (curr =3D=3D list_last_entry(sources, struct disasm_line, al.node)) + return NULL; + + next =3D list_next_entry(curr, al.node); + while (next->al.offset =3D=3D -1 && + next !=3D list_last_entry(sources, struct disasm_line, al.node)) + next =3D list_next_entry(next, al.node); + + if (next->al.offset =3D=3D -1) + return NULL; + + return next; +} + u64 annotate_calc_pcrel(struct map_symbol *ms, u64 ip, int offset, struct disasm_line *dl) { @@ -2249,12 +2279,12 @@ u64 annotate_calc_pcrel(struct map_symbol *ms, u64 = ip, int offset, * disasm_line. If it's the last one, we can use symbol's end * address directly. */ - if (&dl->al.node =3D=3D notes->src->source.prev) + next =3D annotation__next_asm_line(notes, dl); + if (next =3D=3D NULL) addr =3D ms->sym->end + offset; - else { - next =3D list_next_entry(dl, al.node); + else addr =3D ip + (next->al.offset - dl->al.offset) + offset; - } + return map__rip_2objdump(ms->map, addr); } =20 @@ -2386,10 +2416,13 @@ struct annotated_data_type *hist_entry__get_data_ty= pe(struct hist_entry *he) * from the previous instruction. */ if (dl->al.offset > 0) { + struct annotation *notes; struct disasm_line *prev_dl; =20 - prev_dl =3D list_prev_entry(dl, al.node); - if (ins__is_fused(arch, prev_dl->ins.name, dl->ins.name)) { + notes =3D symbol__annotation(ms->sym); + prev_dl =3D annotation__prev_asm_line(notes, dl); + + if (prev_dl && ins__is_fused(arch, prev_dl->ins.name, dl->ins.name)) { dl =3D prev_dl; goto retry; } @@ -2494,8 +2527,16 @@ static bool process_basic_block(struct basic_block_d= ata *bb_data, =20 last_dl =3D list_last_entry(¬es->src->source, struct disasm_line, al.node); + if (last_dl->al.offset =3D=3D -1) + last_dl =3D annotation__prev_asm_line(notes, last_dl); + + if (last_dl =3D=3D NULL) + return false; =20 list_for_each_entry_from(dl, ¬es->src->source, al.node) { + /* Skip comment or debug info line */ + if (dl->al.offset =3D=3D -1) + continue; /* Found the target instruction */ if (sym->start + dl->al.offset =3D=3D target) { found =3D true; @@ -2516,7 +2557,8 @@ static bool process_basic_block(struct basic_block_da= ta *bb_data, /* jump instruction creates new basic block(s) */ next_dl =3D find_disasm_line(sym, sym->start + dl->ops.target.offset, /*allow_update=3D*/false); - add_basic_block(bb_data, link, next_dl); + if (next_dl) + add_basic_block(bb_data, link, next_dl); =20 /* * FIXME: determine conditional jumps properly. @@ -2524,8 +2566,9 @@ static bool process_basic_block(struct basic_block_da= ta *bb_data, * next disasm line. */ if (!strstr(dl->ins.name, "jmp")) { - next_dl =3D list_next_entry(dl, al.node); - add_basic_block(bb_data, link, next_dl); + next_dl =3D annotation__next_asm_line(notes, dl); + if (next_dl) + add_basic_block(bb_data, link, next_dl); } break; =20 --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 00:20:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D66F175560; Fri, 5 Apr 2024 21:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351884; cv=none; b=IIljUsd58MNODHMkhSZT8aaxemvo7H9jJmv0X1stNmHSAjfm9HR9WLHKxnjZCO4AkWKT3Yg3KlJMiFWGz0IJ2weEFiFD2Wg6Z9nslAhYUISJPa8m3Hp6fQyB520yIKvCHi8wfh67UrjxCw4We9CL5Zzd6TXAA1XELVWe1HtA8Ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351884; c=relaxed/simple; bh=ItK41RqmUBjvIaYBvM/7weZYcst7IoTKTUZ5r9Uaq5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F89K/WZrJ/77ZnLKu4K5cClkbwf4UArVfxvXBkpiOtLGG3C6NncJ5vlU8K66HRV1TA053lrzKLJCcMdlNUWDwEVRodecJiDTgdK/YQ0XQR0+tktv91qqfpa22CLfBz71txNyU9PSJb4dt8D7PdMvQAS7V3n8KDEwnLo0YcS8OGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iqL9R1aN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iqL9R1aN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A20D8C43330; Fri, 5 Apr 2024 21:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712351884; bh=ItK41RqmUBjvIaYBvM/7weZYcst7IoTKTUZ5r9Uaq5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqL9R1aNx0z3z2Y0rkUr9j5gHKm0DsE1Vsw9uWJhqm6FZsRjllivep+e2PrSjvkTk U99AkUgd+gQPkxrg15+F2yA0DuFy0SQcmQp7byinTYntJSJkDew+z5e5W5nyZ9NjEZ v4zKsrjk79nRJO9tVwHRuqakLBO0BuUfmum5e//SeuT+HVG2mTfmPWVEc7I3s7o6qQ DoOVdLJF7Tk4gJE6c9f5x9fkeRiOXxFgI1sdwp4RJM2wl1uwabMnPbqMjMTgYMqGfo puNHp5XCV/eAeVkKAD/Wb5A3OOhobTDUkNltqEvfqi9wqq4alxxOW05PUZyRJwisRP FNl3hhW6LwhXg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 4/4] perf annotate: Get rid of symbol__ensure_annotate() Date: Fri, 5 Apr 2024 14:18:00 -0700 Message-ID: <20240405211800.1412920-5-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240405211800.1412920-1-namhyung@kernel.org> References: <20240405211800.1412920-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now symbol__annotate() is reentrant and it doesn't need to remove non-instruction lines. Let's get rid of symbol__ensure_annotate() and call symbol__annotate() directly. Also we can use it to get the arch pointer instead of calling evsel__get_arch() directly. Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/util/annotate.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 9df82e58cf6e..903565799d1b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2140,14 +2140,6 @@ int annotate_get_insn_location(struct arch *arch, st= ruct disasm_line *dl, return 0; } =20 -static void symbol__ensure_annotate(struct map_symbol *ms, struct evsel *e= vsel) -{ - struct annotation *notes =3D symbol__annotation(ms->sym); - - if (list_empty(¬es->src->source)) - symbol__annotate(ms, evsel, NULL); -} - static struct disasm_line *find_disasm_line(struct symbol *sym, u64 ip, bool allow_update) { @@ -2322,14 +2314,12 @@ struct annotated_data_type *hist_entry__get_data_ty= pe(struct hist_entry *he) return NULL; } =20 - if (evsel__get_arch(evsel, &arch) < 0) { + /* Make sure it has the disasm of the function */ + if (symbol__annotate(ms, evsel, &arch) < 0) { ann_data_stat.no_insn++; return NULL; } =20 - /* Make sure it runs objdump to get disasm of the function */ - symbol__ensure_annotate(ms, evsel); - /* * Get a disasm to extract the location from the insn. * This is too slow... --=20 2.44.0.478.gd926399ef9-goog