From nobody Mon Feb 9 18:59:58 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 C037512F5BC; Thu, 4 Apr 2024 17:57:19 +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=1712253439; cv=none; b=nxNJ9oFzgE0pgKYJuiqS5Y/HaBihE6AcTSRSdVYUAaUsYpTcAyFuNF3BoeYXjtFRjMxPal359OeFZLJ8jYn1B656ABFlpizVl9uY0Y9HcLRt4aNGATaY6B9lfYeAak1VDVTUr0CTZMGwnk51vDuM8TG7Uq2oWWNXjA/6vPMa/gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253439; c=relaxed/simple; bh=GpzHHadLf3YosmcJ25cQdas5aywqFNxjfnYY+ULKu6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pq2o6m3vGRjflWdjxiBLUSw2rVlw3oPImnAcweTj/B8Mw12Jg9j+FXfJMBIr3ILFJCL4K562eRKr/jK6l+xgJ/oUK8ZQCYUZFw6KKAqp+jlpRWJMJKMtyMfsgaDHucF4cjggkibKSOyvvcQmGDKeIwQ4JTFSPIXKAw0RhGE7dRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IapbwqgI; 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="IapbwqgI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F7DC433B1; Thu, 4 Apr 2024 17:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253439; bh=GpzHHadLf3YosmcJ25cQdas5aywqFNxjfnYY+ULKu6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IapbwqgIG6nVtU4XbjbiafvS0yiobNrsyYLPd0Fl0YCdfNlToQymVKTID/Bve+jT6 dKvHnyqPeO+O8g8VpT5YzO2W3Jo6YsdoyM3g1IrdxLGKec2/9jlTjisCbMSzywNVY7 0MkPtZFruKk6SXi3faO6IjNmv8YvvzQIfaonX66dnVFe/AVQ3OMnBA3IU3RCX7kQNf l8rneWG4zQE3eeU6E4vQAD8bcg//22oulCv1DFDB632PVmD0XheOSdTKH86qzfjbhP 3YAKTEHYm4ZtZaQObn6w+RvK49GdLrr4/cd2WdaMhIdHM+C3IXVRcmc3kX5Bu18QvE pJVi+CdxCBy9Q== 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/9] perf annotate: Fix annotation_calc_lines() Date: Thu, 4 Apr 2024 10:57:08 -0700 Message-ID: <20240404175716.1225482-2-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It should pass a proper address (i.e. suitable for objdump or addr2line) to get_srcline() in order to work correctly. It used to pass an address with map__rip_2objdump() as the second argument but later it's changed to use notes->start. It's ok in normal cases but it can be changed when annotate_opts.full_addr is set. So let's convert the address directly instead of using the notes->start. Also the last argument is an IP to print symbol offset if requested. So it should pass symbol-relative address. Fixes: 7d18a824b5e5 ("perf annotate: Toggle full address <-> offset display= ") Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/util/annotate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 35235147b111..a330e92c2552 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1440,7 +1440,7 @@ void annotation__toggle_full_addr(struct annotation *= notes, struct map_symbol *m annotation__update_column_widths(notes); } =20 -static void annotation__calc_lines(struct annotation *notes, struct map *m= ap, +static void annotation__calc_lines(struct annotation *notes, struct map_sy= mbol *ms, struct rb_root *root) { struct annotation_line *al; @@ -1448,6 +1448,7 @@ static void annotation__calc_lines(struct annotation = *notes, struct map *map, =20 list_for_each_entry(al, ¬es->src->source, node) { double percent_max =3D 0.0; + u64 addr; int i; =20 for (i =3D 0; i < al->data_nr; i++) { @@ -1463,8 +1464,9 @@ static void annotation__calc_lines(struct annotation = *notes, struct map *map, if (percent_max <=3D 0.5) continue; =20 - al->path =3D get_srcline(map__dso(map), notes->start + al->offset, NULL, - false, true, notes->start + al->offset); + addr =3D map__rip_2objdump(ms->map, ms->sym->start); + al->path =3D get_srcline(map__dso(ms->map), addr + al->offset, NULL, + false, true, ms->sym->start + al->offset); insert_source_line(&tmp_root, al); } =20 @@ -1475,7 +1477,7 @@ static void symbol__calc_lines(struct map_symbol *ms,= struct rb_root *root) { struct annotation *notes =3D symbol__annotation(ms->sym); =20 - annotation__calc_lines(notes, ms->map, root); + annotation__calc_lines(notes, ms, root); } =20 int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 4654013048D; Thu, 4 Apr 2024 17:57:20 +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=1712253440; cv=none; b=N4tH1mUqjgFTMkFI80hSTH300aMfbPrMz0FVViEQfX4ApO0QXrVVD1DQne4oz/1pJ4BV/Geo2uh8DyOxtszjUi4d5tEMkmhH/v4IuOp3IjPgAP82DI7Jo2CXbMnHrvuj1NYd3UWBGzOLvKFuBHyi9wGhmv7fug8rXIDeJS5p3OI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253440; c=relaxed/simple; bh=SJjN9aXGnax1R0X3pXFjDpiQ0mqjOWsvypYEn+6C/2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lw19+4S2gUuJSG9UISuBJ/FUqQj15jyzjFlpovXZgiIRZOKYpg/fR/CvPMoEbFuI0DBiYAhqsjAe7gPubuuh0WE6R04kAl6oVysGnHUTUQ6IaHqJCPbCDFClPMCozPC105QJ8QGD8ykkMWaZwRLm6xggkRNFmwH1jdUdEOfr1Nk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eoQweGDv; 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="eoQweGDv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 823F9C43390; Thu, 4 Apr 2024 17:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253439; bh=SJjN9aXGnax1R0X3pXFjDpiQ0mqjOWsvypYEn+6C/2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eoQweGDvM4FNT1XXPnBdQsJCU1szgEFfLDQ7BRWS7gnjWtoMVOc8AmpEfzM4J9uUT RhkIpOiv+u0ShLWupXmvyjf1XLSrjpwjsFDw87WdbBE4AdhqBAZGwD1/fKuGj7ePD0 45sxE+QfY6hoQaRpSK4PZb5O0A7ldvA4R1Y7MI7mb+4C25Jjn2jIxyKEEEbXS/Zu7F bh0wBdT6+whJSQeEfUymbgdglOpJXRram/Ib2DRSYRD4QB9W6ui7OGzUIsXKR5My9x psqmMkclPYRpjyj3zqxOBvO0wRZxl+4Oh0Plsm5lXPQ6OetOr5O6i3Uqb9T9ypjQqz CTlUxIAOUlXPw== 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/9] perf annotate: Staticize some local functions Date: Thu, 4 Apr 2024 10:57:09 -0700 Message-ID: <20240404175716.1225482-3-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" I found annotation__mark_jump_targets(), annotation__set_offsets() and annotation__init_column_widths() are only used in the same file. Let's make them static. Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/util/annotate.c | 8 +++++--- tools/perf/util/annotate.h | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index a330e92c2552..bbf4894b1309 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1316,7 +1316,8 @@ bool disasm_line__is_valid_local_jump(struct disasm_l= ine *dl, struct symbol *sym return true; } =20 -void annotation__mark_jump_targets(struct annotation *notes, struct symbol= *sym) +static void +annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) { u64 offset, size =3D symbol__size(sym); =20 @@ -1347,7 +1348,7 @@ void annotation__mark_jump_targets(struct annotation = *notes, struct symbol *sym) } } =20 -void annotation__set_offsets(struct annotation *notes, s64 size) +static void annotation__set_offsets(struct annotation *notes, s64 size) { struct annotation_line *al; struct annotated_source *src =3D notes->src; @@ -1404,7 +1405,8 @@ static int annotation__max_ins_name(struct annotation= *notes) return max_name; } =20 -void annotation__init_column_widths(struct annotation *notes, struct symbo= l *sym) +static void +annotation__init_column_widths(struct annotation *notes, struct symbol *sy= m) { notes->widths.addr =3D notes->widths.target =3D notes->widths.min_addr =3D hex_width(symbol__size(sym)); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index b3007c9966fd..3f383f38f65f 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -340,10 +340,7 @@ static inline bool annotation_line__filter(struct anno= tation_line *al) return annotate_opts.hide_src_code && al->offset =3D=3D -1; } =20 -void annotation__set_offsets(struct annotation *notes, s64 size); -void annotation__mark_jump_targets(struct annotation *notes, struct symbol= *sym); void annotation__update_column_widths(struct annotation *notes); -void annotation__init_column_widths(struct annotation *notes, struct symbo= l *sym); void annotation__toggle_full_addr(struct annotation *notes, struct map_sym= bol *ms); =20 static inline struct sym_hist *annotated_source__histogram(struct annotate= d_source *src, int idx) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 C1295130A6C; Thu, 4 Apr 2024 17:57:20 +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=1712253440; cv=none; b=usQCS0NVIiedSGaHLKhZVumEa7guWLwCI8Go4ko6RDlAcLUaXRI0992XN2jBPXeTxVe2XPyt99fPQAZrB+Fhee5VWjf34ETxfi2NlV+JVjn+IAZQVSLcuvFh+C4KTFmpoWA/AjABMbohQX5fs4OwzgzrJx2o10A7B7fJE8IewFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253440; c=relaxed/simple; bh=w9JrZi8TtmQvvS0sNkL9xIp3LrMjB1YasM8k1btFVTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a9uFcHr/K74Urx6DIJRsjb+qoUmaCPyrFTlCD+oCY36fR2D9As/YJ0fA2EqtNiIdrGQPNiB7w1cZnR62zt8ntP3uoepBDtRYACiEax1H9DEnrExP4eQdaOYCjOo9DNPbRPoQIgdzVKaYb1+9qfm4l00ZZvNZp2M0Cz3VUF6J4ag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VJBsC324; 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="VJBsC324" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1199BC433F1; Thu, 4 Apr 2024 17:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253440; bh=w9JrZi8TtmQvvS0sNkL9xIp3LrMjB1YasM8k1btFVTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJBsC324CSDL3+ca0TRJhGTnahMC6sR6RMg+U72D1Tt8K6C6g8LB9XuIJUKo57Wew W8zs159IIiP1+oLG7DOLaywu3cDUHYOzqNynERUGsJmUA7ulyrfQQ+UP15grTcugSt NDC1OJCGNSYs9T07LSh3B8Km5UEo2L95922PSB3I+SgMGchSN/ZHxsQYchBKQK93yK A3sNlNAkpM3qFmPEBxcx8tPcEgEmw0rA/U5HfsbEB8kAJiMKTmCWieFMkb2mzMMh1t D9ygG3GGzLWu1NJlbYCBwYZAFF17oxLb3XYWCwyUzrsTnbPAEBmPSdHlQXYf5axJ6z 1G3YG45h5v+FA== 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/9] perf annotate: Introduce annotated_source__get_line() Date: Thu, 4 Apr 2024 10:57:10 -0700 Message-ID: <20240404175716.1225482-4-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It's a helper function to get annotation_line at the given offset without using the offsets array. The goal is to get rid of the offsets array altogether. It just does the linear search but I think it's better to save memory as it won't be called in a hot path. Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 26 +++++++++++++++++++++----- tools/perf/util/annotate.h | 3 +++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index ec5e21932876..e72583f37972 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -186,7 +186,7 @@ static void annotate_browser__draw_current_jump(struct = ui_browser *browser) * name right after the '<' token and probably treating this like a * 'call' instruction. */ - target =3D notes->src->offsets[cursor->ops.target.offset]; + target =3D annotated_source__get_line(notes->src, cursor->ops.target.offs= et); if (target =3D=3D NULL) { ui_helpline__printf("WARN: jump target inconsistency, press 'o', notes->= offsets[%#x] =3D NULL\n", cursor->ops.target.offset); diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index bbf4894b1309..2409d7424c71 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -369,13 +369,25 @@ int addr_map_symbol__account_cycles(struct addr_map_s= ymbol *ams, return err; } =20 +struct annotation_line *annotated_source__get_line(struct annotated_source= *src, + s64 offset) +{ + struct annotation_line *al; + + list_for_each_entry(al, &src->source, node) { + if (al->offset =3D=3D offset) + return al; + } + return NULL; +} + static unsigned annotation__count_insn(struct annotation *notes, u64 start= , u64 end) { unsigned n_insn =3D 0; u64 offset; =20 for (offset =3D start; offset <=3D end; offset++) { - if (notes->src->offsets[offset]) + if (annotated_source__get_line(notes->src, offset)) n_insn++; } return n_insn; @@ -405,8 +417,9 @@ static void annotation__count_and_fill(struct annotatio= n *notes, u64 start, u64 return; =20 for (offset =3D start; offset <=3D end; offset++) { - struct annotation_line *al =3D notes->src->offsets[offset]; + struct annotation_line *al; =20 + al =3D annotated_source__get_line(notes->src, offset); if (al && al->cycles && al->cycles->ipc =3D=3D 0.0) { al->cycles->ipc =3D ipc; cover_insn++; @@ -443,7 +456,7 @@ static int annotation__compute_ipc(struct annotation *n= otes, size_t size) if (ch && ch->cycles) { struct annotation_line *al; =20 - al =3D notes->src->offsets[offset]; + al =3D annotated_source__get_line(notes->src, offset); if (al && al->cycles =3D=3D NULL) { al->cycles =3D zalloc(sizeof(*al->cycles)); if (al->cycles =3D=3D NULL) { @@ -466,7 +479,9 @@ static int annotation__compute_ipc(struct annotation *n= otes, size_t size) struct cyc_hist *ch =3D ¬es->branch->cycles_hist[offset]; =20 if (ch && ch->cycles) { - struct annotation_line *al =3D notes->src->offsets[offset]; + struct annotation_line *al; + + al =3D annotated_source__get_line(notes->src, offset); if (al) zfree(&al->cycles); } @@ -1326,9 +1341,10 @@ annotation__mark_jump_targets(struct annotation *not= es, struct symbol *sym) return; =20 for (offset =3D 0; offset < size; ++offset) { - struct annotation_line *al =3D notes->src->offsets[offset]; + struct annotation_line *al; struct disasm_line *dl; =20 + al =3D annotated_source__get_line(notes->src, offset); dl =3D disasm_line(al); =20 if (!disasm_line__is_valid_local_jump(dl, sym)) diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 3f383f38f65f..aa3298c20300 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -270,6 +270,9 @@ struct annotated_source { u16 max_line_len; }; =20 +struct annotation_line *annotated_source__get_line(struct annotated_source= *src, + s64 offset); + /** * struct annotated_branch - basic block and IPC information for a symbol. * --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 08BA6130AD6; Thu, 4 Apr 2024 17:57:21 +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=1712253441; cv=none; b=Ff8m0yiJ+7CNnqGWgtnMTovTZuZS1FXzJ3r/lB2cYmkpiqsrYH4JI30QnMv7jq0VL7sjg/TeZLnVytdL/rHozvJFqt4gkyh19e1LInCeVi8L0z0RdQU61IIYzAI/H8KSBFfpJzrpubF7qLsJwgWdCaDBgf358we6TrgNaPNqUBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253441; c=relaxed/simple; bh=fv8+KGbOGn0vJth3f19KOjYOJnNdxCaQN7X8NxsFZaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uhNgdpUPcMWQwURiXe3WoaxV0Qeyi/0fRAkI8NT174KwFhuU7qmKueji1dOQupaRWXy0nxywFn7+cP8IzjaMAXQfN7Yu7tYFrMvIBfYCHMROmyRoQwE3UZsFCV50L8kHnHtXTqvCcNKiSCw+Caf2rWJk7RustEs4znziqnA7Uo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T/ErhSB9; 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="T/ErhSB9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89856C433C7; Thu, 4 Apr 2024 17:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253440; bh=fv8+KGbOGn0vJth3f19KOjYOJnNdxCaQN7X8NxsFZaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/ErhSB9/JWesnoJaud1PgLIOFJdTGdy6nla3lvbvaEdlivSQQzR5e1WlKjpMkm6j 6Ll6ojkBFCp/vOHhg7NLro1t8xwJCxYtndcOtGzDGabrzR193eG5ZwdGZiNwZhfNKT sQIVzaNlUUe6RtlqHogKOp6bxVCCtMbomvSVFaqsqbYEyPuj7iA21A2WaZXKBi6Ab1 F5nbA0tKhQKVeGIhspnDsLooivXyR0thTR6ZEUY20ee7yHZLuKKqp8gwl32dcmC+tE VurtgaKsvTAxheDuJGcifvyOqUJZxO0OyFOmxdoJVyYhfzVb2BxfqWKp0ul5TYsThP BNmlw0shmU0LQ== 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/9] perf annotate: Check annotation lines more efficiently Date: Thu, 4 Apr 2024 10:57:11 -0700 Message-ID: <20240404175716.1225482-5-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" In some places, it checks annotated (disasm) lines for each byte. But as it already has a list of disasm lines, it'd be better to traverse the list entries instead of checking every offset with linear search (by annotated_source__get_line() helper). Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/util/annotate.c | 56 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 2409d7424c71..d98fc248ba5b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -383,12 +383,19 @@ struct annotation_line *annotated_source__get_line(st= ruct annotated_source *src, =20 static unsigned annotation__count_insn(struct annotation *notes, u64 start= , u64 end) { + struct annotation_line *al; unsigned n_insn =3D 0; - u64 offset; =20 - for (offset =3D start; offset <=3D end; offset++) { - if (annotated_source__get_line(notes->src, offset)) - n_insn++; + al =3D annotated_source__get_line(notes->src, start); + if (al =3D=3D NULL) + return 0; + + list_for_each_entry_from(al, ¬es->src->source, node) { + if (al->offset =3D=3D -1) + continue; + if ((u64)al->offset > end) + break; + n_insn++; } return n_insn; } @@ -405,10 +412,10 @@ static void annotation__count_and_fill(struct annotat= ion *notes, u64 start, u64 { unsigned n_insn; unsigned int cover_insn =3D 0; - u64 offset; =20 n_insn =3D annotation__count_insn(notes, start, end); if (n_insn && ch->num && ch->cycles) { + struct annotation_line *al; struct annotated_branch *branch; float ipc =3D n_insn / ((double)ch->cycles / (double)ch->num); =20 @@ -416,11 +423,16 @@ static void annotation__count_and_fill(struct annotat= ion *notes, u64 start, u64 if (ch->reset >=3D 0x7fff) return; =20 - for (offset =3D start; offset <=3D end; offset++) { - struct annotation_line *al; + al =3D annotated_source__get_line(notes->src, start); + if (al =3D=3D NULL) + return; =20 - al =3D annotated_source__get_line(notes->src, offset); - if (al && al->cycles && al->cycles->ipc =3D=3D 0.0) { + list_for_each_entry_from(al, ¬es->src->source, node) { + if (al->offset =3D=3D -1) + continue; + if ((u64)al->offset > end) + break; + if (al->cycles && al->cycles->ipc =3D=3D 0.0) { al->cycles->ipc =3D ipc; cover_insn++; } @@ -1268,13 +1280,16 @@ void symbol__annotate_decay_histogram(struct symbol= *sym, int evidx) { struct annotation *notes =3D symbol__annotation(sym); struct sym_hist *h =3D annotation__histogram(notes, evidx); - int len =3D symbol__size(sym), offset; + struct annotation_line *al; =20 h->nr_samples =3D 0; - for (offset =3D 0; offset < len; ++offset) { + list_for_each_entry(al, ¬es->src->source, node) { struct sym_hist_entry *entry; =20 - entry =3D annotated_source__hist_entry(notes->src, evidx, offset); + if (al->offset =3D=3D -1) + continue; + + entry =3D annotated_source__hist_entry(notes->src, evidx, al->offset); if (entry =3D=3D NULL) continue; =20 @@ -1334,33 +1349,32 @@ bool disasm_line__is_valid_local_jump(struct disasm= _line *dl, struct symbol *sym static void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) { - u64 offset, size =3D symbol__size(sym); + struct annotation_line *al; =20 /* PLT symbols contain external offsets */ if (strstr(sym->name, "@plt")) return; =20 - for (offset =3D 0; offset < size; ++offset) { - struct annotation_line *al; + list_for_each_entry(al, ¬es->src->source, node) { struct disasm_line *dl; + struct annotation_line *target; =20 - al =3D annotated_source__get_line(notes->src, offset); dl =3D disasm_line(al); =20 if (!disasm_line__is_valid_local_jump(dl, sym)) continue; =20 - al =3D notes->src->offsets[dl->ops.target.offset]; - + target =3D annotated_source__get_line(notes->src, + dl->ops.target.offset); /* * FIXME: Oops, no jump target? Buggy disassembler? Or do we * have to adjust to the previous offset? */ - if (al =3D=3D NULL) + if (target =3D=3D NULL) continue; =20 - if (++al->jump_sources > notes->max_jump_sources) - notes->max_jump_sources =3D al->jump_sources; + if (++target->jump_sources > notes->max_jump_sources) + notes->max_jump_sources =3D target->jump_sources; } } =20 --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 73C8913119B; Thu, 4 Apr 2024 17:57:21 +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=1712253441; cv=none; b=byd3oi66oiLlY04sK92bah2Yh3H1DkXXAin1WVtUMr12shqT5He/h9rqDlvagM0u8CoVUpGEaUwn9ZU6XAj4jtdSAk1ETtL7N+uz4kKp1hAIg84dcolxWAyRYLKMTk5Ttp6ofiVtCWYGL4PtuDP29EAHrp79RdqFDzwT+3w6YKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253441; c=relaxed/simple; bh=rx0Er1u712mtimPPRUKohpR7c9tBI51uTJQRc2Ubw6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YyXrb/b4tTgOpEgK15dyXWq+HhC+CclheL7dmzmLHd+Z3aSBhUQWPfUYEadr/ofLUtm/6IrjxS2/B4xlXv+yAAlVyntwpOP2JqrU2BXcnJaNrlmNoPBcxgn6irnMnHBV9CGruk2g5dOZPS4Ryj9iq3Hy4VWZRghdcuoGBF3I4lA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RzYuVDxR; 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="RzYuVDxR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06896C43394; Thu, 4 Apr 2024 17:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253441; bh=rx0Er1u712mtimPPRUKohpR7c9tBI51uTJQRc2Ubw6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RzYuVDxR1uQ1L8XzQWRu3/+Ow9mDheUg1IMpGxSAclmTROSDwUd706w0PQsF+83Gt xQL2OIR9mduxPy060SYX2l/tMk75oytWeIVbCmDsXanLpEmRNPxS7n+HWFyqZ+LDNw 2N3DFaeQ3FD9xBkZinOxe/rQYEMMPJFIkuRQLWVs+9g3LsQEFtXWZUkrx6h48A2nhY endIfjVblhs/DTZvy2/tu1MYUV6kj9lPV6aodNqqFuwHDkrCwgByPxatYa6G7zDuyJ CUuFHUkXYIcB8V///Fv7zhkBxPujEUrg7gpw2sh96ODPjILynjUz4mxAhtG1E4+mHd mIClGonep7zhg== 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 5/9] perf annotate: Get rid of offsets array Date: Thu, 4 Apr 2024 10:57:12 -0700 Message-ID: <20240404175716.1225482-6-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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 struct annotated_source.offsets[] is to save pointers to annotation_line at each offset. We can use annotated_source__get_line() helper instead and let's get rid of the array. Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 5 +---- tools/perf/util/annotate.c | 29 ++++++----------------------- tools/perf/util/annotate.h | 2 -- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index e72583f37972..c93da2ce727f 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -977,7 +977,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct = evsel *evsel, dso->annotate_warned =3D true; symbol__strerror_disassemble(ms, err, msg, sizeof(msg)); ui__error("Couldn't annotate %s:\n%s", sym->name, msg); - goto out_free_offsets; + return -1; } } =20 @@ -996,8 +996,5 @@ int symbol__tui_annotate(struct map_symbol *ms, struct = evsel *evsel, if(not_annotated) annotated_source__purge(notes->src); =20 -out_free_offsets: - if(not_annotated) - zfree(¬es->src->offsets); return ret; } diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d98fc248ba5b..0e8319835986 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1378,7 +1378,7 @@ annotation__mark_jump_targets(struct annotation *note= s, struct symbol *sym) } } =20 -static void annotation__set_offsets(struct annotation *notes, s64 size) +static void annotation__set_index(struct annotation *notes) { struct annotation_line *al; struct annotated_source *src =3D notes->src; @@ -1393,18 +1393,9 @@ static void annotation__set_offsets(struct annotatio= n *notes, s64 size) if (src->max_line_len < line_len) src->max_line_len =3D line_len; al->idx =3D src->nr_entries++; - if (al->offset !=3D -1) { + if (al->offset !=3D -1) al->idx_asm =3D src->nr_asm_entries++; - /* - * FIXME: short term bandaid to cope with assembly - * routines that comes with labels in the same column - * as the address in objdump, sigh. - * - * E.g. copy_user_generic_unrolled - */ - if (al->offset < size) - notes->src->offsets[al->offset] =3D al; - } else + else al->idx_asm =3D -1; } } @@ -1835,25 +1826,21 @@ int symbol__annotate2(struct map_symbol *ms, struct= evsel *evsel, size_t size =3D symbol__size(sym); int nr_pcnt =3D 1, err; =20 - notes->src->offsets =3D zalloc(size * sizeof(struct annotation_line *)); - if (notes->src->offsets =3D=3D NULL) - return ENOMEM; - if (evsel__is_group_event(evsel)) nr_pcnt =3D evsel->core.nr_members; =20 err =3D symbol__annotate(ms, evsel, parch); if (err) - goto out_free_offsets; + return err; =20 symbol__calc_percent(sym, evsel); =20 - annotation__set_offsets(notes, size); + annotation__set_index(notes); annotation__mark_jump_targets(notes, sym); =20 err =3D annotation__compute_ipc(notes, size); if (err) - goto out_free_offsets; + return err; =20 annotation__init_column_widths(notes, sym); notes->nr_events =3D nr_pcnt; @@ -1862,10 +1849,6 @@ int symbol__annotate2(struct map_symbol *ms, struct = evsel *evsel, sym->annotate2 =3D 1; =20 return 0; - -out_free_offsets: - zfree(¬es->src->offsets); - return err; } =20 static int annotation__config(const char *var, const char *value, void *da= ta) diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index aa3298c20300..d61184499bda 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -246,7 +246,6 @@ struct cyc_hist { * we have more than a group in a evlist, where we will want * to see each group separately, that is why symbol__annotate2() * sets src->nr_histograms to evsel->nr_members. - * @offsets: Array of annotation_line to be accessed by offset. * @samples: Hash map of sym_hist_entry. Keyed by event index and offset = in symbol. * @nr_entries: Number of annotated_line in the source list. * @nr_asm_entries: Number of annotated_line with actual asm instruction i= n the @@ -262,7 +261,6 @@ struct cyc_hist { struct annotated_source { struct list_head source; struct sym_hist *histograms; - struct annotation_line **offsets; struct hashmap *samples; int nr_histograms; int nr_entries; --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 504F0132816; Thu, 4 Apr 2024 17:57:21 +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=1712253442; cv=none; b=oWOw8RV/9KARQTGKPZC0YDvd0bteySij2DEk3w9ZCvT+E0U8H7nm+tqJPIrmkbSQ0fYoelK9oab+jbS5W5D43iMCCSVQYMAPtnBgA9iCYxwhw0Xb5OF4U8Y4eFssrsJNdMqIpzSpoP5IT4jpzfzDHGdvssOtgoHLqGya41iV71A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253442; c=relaxed/simple; bh=Xxo+cBqc6qIpHVIyGo1yk3m+aPbd3TuunlhzqIeauC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s4o8qhQnJBLObglUwUlVQ7MvTg0M3RON8ntUE6qQnkmjm0xsZxZiX8WZMJfoAXaIbXJLkBL/g47E2RAZBh7Awhry+iVKivv2YAOMQSM3L7nt1GfR6KrXSVsTPl/4PJbEVcAkpuTCi9F0SndcPAzSszLe0/fftcYccoPV1OH5B5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KeZgV1KF; 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="KeZgV1KF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E06DC4167D; Thu, 4 Apr 2024 17:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253441; bh=Xxo+cBqc6qIpHVIyGo1yk3m+aPbd3TuunlhzqIeauC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KeZgV1KFwBBkcZv+ZjBNIvjAC7EPYSkTR1LVwYipa4eiIX/5uFooTeHfT8IYxeIyL gfYzxFDjEt8ssR+Mtpnt3YawlbfjVXB5/X0RMR0oqi2b9XY1VlR6FK/8A167GORbA/ 0thvXqtCgC6WNu7Pl9DM8dth72rUe+EtGcTOvislB6XduFdfZsgC9EdLPvFC0n+r9O DvA2waD1xxCjf6DfkIb8Ej2bnKzkPnQxuWDRSvRPOz5CGHWBzBimPk4pU4acupcGdR 9fjYlaLwQj2rzOgle0SPYXojY2BKktOjLiqZc/fkAu6BuxyQpYJk2gfcaLHTT5t9Af uUSZ1+sMAQBZA== 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 6/9] perf annotate: Move widths struct to annotated_source Date: Thu, 4 Apr 2024 10:57:13 -0700 Message-ID: <20240404175716.1225482-7-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It's only used in perf annotate output which means functions with actual samples. No need to consume memory for every symbol (annotation). Also move max_line_len field into it as it's related. Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 6 ++--- tools/perf/util/annotate.c | 41 +++++++++++++++++-------------- tools/perf/util/annotate.h | 20 +++++++-------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index c93da2ce727f..032642a0b4b6 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -205,13 +205,13 @@ static void annotate_browser__draw_current_jump(struc= t ui_browser *browser) =20 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS); __ui_browser__line_arrow(browser, - pcnt_width + 2 + notes->widths.addr + width, + pcnt_width + 2 + notes->src->widths.addr + width, from, to); =20 diff =3D is_fused(ab, cursor); if (diff > 0) { ui_browser__mark_fused(browser, - pcnt_width + 3 + notes->widths.addr + width, + pcnt_width + 3 + notes->src->widths.addr + width, from - diff, diff, to > from); } } @@ -983,7 +983,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct = evsel *evsel, =20 ui_helpline__push("Press ESC to exit"); =20 - browser.b.width =3D notes->src->max_line_len; + browser.b.width =3D notes->src->widths.max_line_len; browser.b.nr_entries =3D notes->src->nr_entries; browser.b.entries =3D ¬es->src->source, browser.b.width +=3D 18; /* Percentage */ diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0e8319835986..0be744bb529c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1383,15 +1383,15 @@ static void annotation__set_index(struct annotation= *notes) struct annotation_line *al; struct annotated_source *src =3D notes->src; =20 - src->max_line_len =3D 0; + src->widths.max_line_len =3D 0; src->nr_entries =3D 0; src->nr_asm_entries =3D 0; =20 list_for_each_entry(al, &src->source, node) { size_t line_len =3D strlen(al->line); =20 - if (src->max_line_len < line_len) - src->max_line_len =3D line_len; + if (src->widths.max_line_len < line_len) + src->widths.max_line_len =3D line_len; al->idx =3D src->nr_entries++; if (al->offset !=3D -1) al->idx_asm =3D src->nr_asm_entries++; @@ -1429,26 +1429,26 @@ static int annotation__max_ins_name(struct annotati= on *notes) static void annotation__init_column_widths(struct annotation *notes, struct symbol *sy= m) { - notes->widths.addr =3D notes->widths.target =3D - notes->widths.min_addr =3D hex_width(symbol__size(sym)); - notes->widths.max_addr =3D hex_width(sym->end); - notes->widths.jumps =3D width_jumps(notes->max_jump_sources); - notes->widths.max_ins_name =3D annotation__max_ins_name(notes); + notes->src->widths.addr =3D notes->src->widths.target =3D + notes->src->widths.min_addr =3D hex_width(symbol__size(sym)); + notes->src->widths.max_addr =3D hex_width(sym->end); + notes->src->widths.jumps =3D width_jumps(notes->max_jump_sources); + notes->src->widths.max_ins_name =3D annotation__max_ins_name(notes); } =20 void annotation__update_column_widths(struct annotation *notes) { if (annotate_opts.use_offset) - notes->widths.target =3D notes->widths.min_addr; + notes->src->widths.target =3D notes->src->widths.min_addr; else if (annotate_opts.full_addr) - notes->widths.target =3D BITS_PER_LONG / 4; + notes->src->widths.target =3D BITS_PER_LONG / 4; else - notes->widths.target =3D notes->widths.max_addr; + notes->src->widths.target =3D notes->src->widths.max_addr; =20 - notes->widths.addr =3D notes->widths.target; + notes->src->widths.addr =3D notes->src->widths.target; =20 if (annotate_opts.show_nr_jumps) - notes->widths.addr +=3D notes->widths.jumps + 1; + notes->src->widths.addr +=3D notes->src->widths.jumps + 1; } =20 void annotation__toggle_full_addr(struct annotation *notes, struct map_sym= bol *ms) @@ -1625,7 +1625,8 @@ static void disasm_line__write(struct disasm_line *dl= , struct annotation *notes, obj__printf(obj, " "); } =20 - disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, notes->wi= dths.max_ins_name); + disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, + notes->src->widths.max_ins_name); } =20 static void ipc_coverage_string(char *bf, int size, struct annotation *not= es) @@ -1753,9 +1754,11 @@ static void __annotation_line__write(struct annotati= on_line *al, struct annotati obj__printf(obj, "%-*s", width - pcnt_width - cycles_width, " "); else if (al->offset =3D=3D -1) { if (al->line_nr && annotate_opts.show_linenr) - printed =3D scnprintf(bf, sizeof(bf), "%-*d ", notes->widths.addr + 1, = al->line_nr); + printed =3D scnprintf(bf, sizeof(bf), "%-*d ", + notes->src->widths.addr + 1, al->line_nr); else - printed =3D scnprintf(bf, sizeof(bf), "%-*s ", notes->widths.addr, " "= ); + printed =3D scnprintf(bf, sizeof(bf), "%-*s ", + notes->src->widths.addr, " "); obj__printf(obj, bf); obj__printf(obj, "%-*s", width - printed - pcnt_width - cycles_width + 1= , al->line); } else { @@ -1773,7 +1776,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati if (annotate_opts.show_nr_jumps) { int prev; printed =3D scnprintf(bf, sizeof(bf), "%*d ", - notes->widths.jumps, + notes->src->widths.jumps, al->jump_sources); prev =3D obj__set_jumps_percent_color(obj, al->jump_sources, current_entry); @@ -1782,7 +1785,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati } print_addr: printed =3D scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", - notes->widths.target, addr); + notes->src->widths.target, addr); } else if (ins__is_call(&disasm_line(al)->ins) && annotate_opts.offset_level >=3D ANNOTATION__OFFSET_CALL) { goto print_addr; @@ -1790,7 +1793,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati goto print_addr; } else { printed =3D scnprintf(bf, sizeof(bf), "%-*s ", - notes->widths.addr, " "); + notes->src->widths.addr, " "); } } =20 diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d61184499bda..402ae774426b 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -250,7 +250,7 @@ struct cyc_hist { * @nr_entries: Number of annotated_line in the source list. * @nr_asm_entries: Number of annotated_line with actual asm instruction i= n the * source list. - * @max_line_len: Maximum length of objdump output in an annotated_line. + * @widths: Precalculated width of each column in the TUI output. * * disasm_lines are allocated, percentages calculated and all sorted by pe= rcentage * when the annotation is about to be presented, so the percentages are for @@ -265,7 +265,15 @@ struct annotated_source { int nr_histograms; int nr_entries; int nr_asm_entries; - u16 max_line_len; + struct { + u8 addr; + u8 jumps; + u8 target; + u8 min_addr; + u8 max_addr; + u8 max_ins_name; + u16 max_line_len; + } widths; }; =20 struct annotation_line *annotated_source__get_line(struct annotated_source= *src, @@ -302,14 +310,6 @@ struct LOCKABLE annotation { u64 start; int nr_events; int max_jump_sources; - struct { - u8 addr; - u8 jumps; - u8 target; - u8 min_addr; - u8 max_addr; - u8 max_ins_name; - } widths; struct annotated_source *src; struct annotated_branch *branch; }; --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 748D812F37C; Thu, 4 Apr 2024 17:57:22 +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=1712253442; cv=none; b=FAWdaB29uc4+Im7J/FS8LSiQXxg7ZWgKvnAYjxcWHdmf6HGX1HB8sCNxoBORk/J4IeLoV0pZKGZKyEflwxFzwWmnr/UMy4kbsE11bDRH0fZQtu2ltzaklTmbjtUb7GRymr98mqnzU+IjSTtSjcSD1drh2URHHdKHxD+H4UPiP1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253442; c=relaxed/simple; bh=JWXX9PYo6AsnQWhyMkd6vlh4yGAwW5IMqqn8kgE6iFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EGR04CR+RXcIK3H83iTja5Usv7TDdNXt9/XqWq+dtI5aIiZYp4M0IP02jDvFCB1nx8ypIFn+px6FhiBIJ35EjAEsV8JXeC5QKlF6fTAcMPAb3T2C7xu8G9MZ+KvU4ACMhwl6sG6XVE0LPMrYNktQIbnvEZ4XWA9DD2wxh1VOTIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLRMwyqH; 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="PLRMwyqH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE72BC433F1; Thu, 4 Apr 2024 17:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253442; bh=JWXX9PYo6AsnQWhyMkd6vlh4yGAwW5IMqqn8kgE6iFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLRMwyqH4kak3eAT7K0+hug8hKn0h1WpNFwrJXxzwD0p4cAVn+iNBvlz2ahGWqJlX Ampw/0yoVStwFaloX+t37hENnS1MKsHjt2EBWyrYexkOlB+0egA4KinVuM6dZt7TJv RnliIv1pNDwCxB3qTU/H+OusUAwY0buY9nRoltKsQ0vpbdkrZBy9+5xZf9KBmtrU4S SE1+j6Ofbf0QAUOV9Ta8Wbyry936Fqqn8g/Rg5ICv4UockMSpZZJu1Rq9xnpAh7Rls 1ZqFJqnh7B9O9xpoTpaIoi2i6jQ4cpAjWYbiiC2qrg5sbHSzJVVIeIf5Pd7FD0F8zv 8FoJRUh8TR4qA== 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 7/9] perf annotate: Move max_jump_sources struct to annotated_source Date: Thu, 4 Apr 2024 10:57:14 -0700 Message-ID: <20240404175716.1225482-8-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It's only used in perf annotate output which means functions with actual samples. No need to consume memory for every symbol (annotation). Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 6 +++--- tools/perf/util/annotate.h | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 032642a0b4b6..0e16c268e329 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -49,7 +49,7 @@ static int ui_browser__jumps_percent_color(struct ui_brow= ser *browser, int nr, b =20 if (current && (!browser->use_navkeypressed || browser->navkeypressed)) return HE_COLORSET_SELECTED; - if (nr =3D=3D notes->max_jump_sources) + if (nr =3D=3D notes->src->max_jump_sources) return HE_COLORSET_TOP; if (nr > 1) return HE_COLORSET_MEDIUM; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0be744bb529c..1fd51856d78f 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1373,8 +1373,8 @@ annotation__mark_jump_targets(struct annotation *note= s, struct symbol *sym) if (target =3D=3D NULL) continue; =20 - if (++target->jump_sources > notes->max_jump_sources) - notes->max_jump_sources =3D target->jump_sources; + if (++target->jump_sources > notes->src->max_jump_sources) + notes->src->max_jump_sources =3D target->jump_sources; } } =20 @@ -1432,7 +1432,7 @@ annotation__init_column_widths(struct annotation *not= es, struct symbol *sym) notes->src->widths.addr =3D notes->src->widths.target =3D notes->src->widths.min_addr =3D hex_width(symbol__size(sym)); notes->src->widths.max_addr =3D hex_width(sym->end); - notes->src->widths.jumps =3D width_jumps(notes->max_jump_sources); + notes->src->widths.jumps =3D width_jumps(notes->src->max_jump_sources); notes->src->widths.max_ins_name =3D annotation__max_ins_name(notes); } =20 diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 402ae774426b..382705311d28 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -250,6 +250,8 @@ struct cyc_hist { * @nr_entries: Number of annotated_line in the source list. * @nr_asm_entries: Number of annotated_line with actual asm instruction i= n the * source list. + * @max_jump_sources: Maximum number of jump instructions targeting to the= same + * instruction. * @widths: Precalculated width of each column in the TUI output. * * disasm_lines are allocated, percentages calculated and all sorted by pe= rcentage @@ -265,6 +267,7 @@ struct annotated_source { int nr_histograms; int nr_entries; int nr_asm_entries; + int max_jump_sources; struct { u8 addr; u8 jumps; @@ -309,7 +312,6 @@ struct annotated_branch { struct LOCKABLE annotation { u64 start; int nr_events; - int max_jump_sources; struct annotated_source *src; struct annotated_branch *branch; }; --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 4CD631339B1; Thu, 4 Apr 2024 17:57:22 +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=1712253443; cv=none; b=S4aV/Hl31oeCo0DsM+LGk38d7N58Li3nVa9WWhbqPJsSW/vNiHdn1SDlIUfOrUL1mnzM+mfNpWajYOTR43ctq46WlvebmTiRLz0KVAZYR12+Hj5g0tq+BoXYRmVYICf2krz2HpEwc/HJimq3z610MfbFePv6+LOo++7GqPXwA7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253443; c=relaxed/simple; bh=zOkpmF2bfwe8D5R+ONfcu1WFleIDXUSyCE14ZC5NB/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rcj06WOfqEwcv64qh3HWQ8+01AZhGdD4Z5v5yM37e0L/nZPPxBafXaD06GvmgPxUt7mTzNPF3oBgCDtxIOwaQ5FwYfbzYqaH1LSmrhZ/K5UjSKhYZRBQbtc1JBuR79NevCdZJopWqGnwKkoyoG4AJHI4ToG1P4ilwTO/ulf1zcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GFL5JYvJ; 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="GFL5JYvJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CD8BC43330; Thu, 4 Apr 2024 17:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253442; bh=zOkpmF2bfwe8D5R+ONfcu1WFleIDXUSyCE14ZC5NB/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFL5JYvJQKECvIkWeaD9FDcy67MEtBVJdlLjvsd93jDYlHXxE7GyoneUqbQviyS3Y OxSDbzIL0r5rrxUgfbvZHGikfw63P9vFcbByrvWZ5rgqThJgR0LX/nrJbFRpDBzCcU p1sIvkrwEfiYxEWFi71ZPz0N+ET67nVz5UvuGOeI6STjtQjm5jWJZ8s57En60n7FgX x8KPyuW+x93vohjQui3fSPSqKoRRvhVgR/PGFjqibr8Les4k0hxP3WPIGPvJGUy6uB SA/DixozWwQxLIy3AzT0+W7yb8AujY8GlFEYEQDs+XL6qw9zKpcz1OmbJ5Tt6RSixp ZdyOhr0NV2dOQ== 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 8/9] perf annotate: Move nr_events struct to annotated_source Date: Thu, 4 Apr 2024 10:57:15 -0700 Message-ID: <20240404175716.1225482-9-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It's only used in perf annotate output which means functions with actual samples. No need to consume memory for every symbol (annotation). Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/util/annotate.c | 6 +++--- tools/perf/util/annotate.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 1fd51856d78f..5f79ae0bccfd 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1584,7 +1584,7 @@ static double annotation_line__max_percent(struct ann= otation_line *al, double percent_max =3D 0.0; int i; =20 - for (i =3D 0; i < notes->nr_events; i++) { + for (i =3D 0; i < notes->src->nr_events; i++) { double percent; =20 percent =3D annotation_data__percent(&al->data[i], @@ -1674,7 +1674,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati if (al->offset !=3D -1 && percent_max !=3D 0.0) { int i; =20 - for (i =3D 0; i < notes->nr_events; i++) { + for (i =3D 0; i < notes->src->nr_events; i++) { double percent; =20 percent =3D annotation_data__percent(&al->data[i], percent_type); @@ -1846,7 +1846,7 @@ int symbol__annotate2(struct map_symbol *ms, struct e= vsel *evsel, return err; =20 annotation__init_column_widths(notes, sym); - notes->nr_events =3D nr_pcnt; + notes->src->nr_events =3D nr_pcnt; =20 annotation__update_column_widths(notes); sym->annotate2 =3D 1; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 382705311d28..d22b9e9a2fad 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -247,6 +247,7 @@ struct cyc_hist { * to see each group separately, that is why symbol__annotate2() * sets src->nr_histograms to evsel->nr_members. * @samples: Hash map of sym_hist_entry. Keyed by event index and offset = in symbol. + * @nr_events: Number of events in the current output. * @nr_entries: Number of annotated_line in the source list. * @nr_asm_entries: Number of annotated_line with actual asm instruction i= n the * source list. @@ -265,6 +266,7 @@ struct annotated_source { struct sym_hist *histograms; struct hashmap *samples; int nr_histograms; + int nr_events; int nr_entries; int nr_asm_entries; int max_jump_sources; @@ -311,7 +313,6 @@ struct annotated_branch { =20 struct LOCKABLE annotation { u64 start; - int nr_events; struct annotated_source *src; struct annotated_branch *branch; }; @@ -335,7 +336,7 @@ static inline int annotation__cycles_width(struct annot= ation *notes) =20 static inline int annotation__pcnt_width(struct annotation *notes) { - return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events; + return (symbol_conf.show_total_period ? 12 : 7) * notes->src->nr_events; } =20 static inline bool annotation_line__filter(struct annotation_line *al) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 18:59:58 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 A07CC134426; Thu, 4 Apr 2024 17:57:23 +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=1712253443; cv=none; b=jTFdKCAw2oNcAFidg8JafWX+42HeEjBVk5R9Sc/p79Jn6+ZVHIQqe9Jtopa2Gn0NYwzksal5ja3l+YJb8q3IOHLM6Ua/gdqIiR/4ADB0tSGqnnvMkslGE/dgLBz4kxkR2+YEmO/kZOrRQ+bNvQhcR+YU8BoosL1Smrg345yOQFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253443; c=relaxed/simple; bh=niT6BQxb6KQYb+xioB6nmxiNDINwRSyOvMNKOzr69J0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B1DlNZ7TKTsoofDHADQQqI5iXQSTeNZkYWE1pNpv3rRM3/L5UsE29SGxQPEviU0DW35kToXlPqjOLslphM63qurBjEdmVkIkOqAGbW7YWrdZqg2IdwGN84zYkwLNXYx6WjasPk9u7/xGPEIqdba1BeWUjIhU0qKfJFCx1OVnQFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CGSYEztl; 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="CGSYEztl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE04AC4167E; Thu, 4 Apr 2024 17:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253443; bh=niT6BQxb6KQYb+xioB6nmxiNDINwRSyOvMNKOzr69J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CGSYEztlyQ2d65DXA/9VDqohrGM22hsX9Jl7GvQKfzYroW5NOWOm8xcbfc75gyZOg zs1J6GGB8bgZFbLi8kPFU05yqF3pKdzWw6wbkX1ms/zOREFLMaGD6i/wIOucNH2+Za jvUzAqbjZVuX3cgrAuoZoiy3cz4x/9hWDR/5NhgBkfdnDBIbJ6gw50132AJFq32HdB NydZ3T8DLM42PxfD4RzT2riPmDFvELSiWYpXpWalQaBRzDQkEX8C106rgxbMkyrUOT Z/SA1v+jmFDjZ7HnIyvzCv2sEdIgs0HgwLZUYzH7ryxyZHaE1+5Bn6HAM50l4j/FOf t6lpcYs3TkxLw== 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 9/9] perf annotate: Move start field struct to annotated_source Date: Thu, 4 Apr 2024 10:57:16 -0700 Message-ID: <20240404175716.1225482-10-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-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" It's only used in perf annotate output which means functions with actual samples. No need to consume memory for every symbol (annotation). Signed-off-by: Namhyung Kim Tested-by: Ian Rogers --- tools/perf/util/annotate.c | 10 +++++----- tools/perf/util/annotate.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 5f79ae0bccfd..4db49611c386 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -909,9 +909,9 @@ int symbol__annotate(struct map_symbol *ms, struct evse= l *evsel, args.arch =3D arch; args.ms =3D *ms; if (annotate_opts.full_addr) - notes->start =3D map__objdump_2mem(ms->map, ms->sym->start); + notes->src->start =3D map__objdump_2mem(ms->map, ms->sym->start); else - notes->start =3D map__rip_2objdump(ms->map, ms->sym->start); + notes->src->start =3D map__rip_2objdump(ms->map, ms->sym->start); =20 return symbol__disassemble(sym, &args); } @@ -1456,9 +1456,9 @@ void annotation__toggle_full_addr(struct annotation *= notes, struct map_symbol *m annotate_opts.full_addr =3D !annotate_opts.full_addr; =20 if (annotate_opts.full_addr) - notes->start =3D map__objdump_2mem(ms->map, ms->sym->start); + notes->src->start =3D map__objdump_2mem(ms->map, ms->sym->start); else - notes->start =3D map__rip_2objdump(ms->map, ms->sym->start); + notes->src->start =3D map__rip_2objdump(ms->map, ms->sym->start); =20 annotation__update_column_widths(notes); } @@ -1766,7 +1766,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati int color =3D -1; =20 if (!annotate_opts.use_offset) - addr +=3D notes->start; + addr +=3D notes->src->start; =20 if (!annotate_opts.use_offset) { printed =3D scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d22b9e9a2fad..d5c821c22f79 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -270,6 +270,7 @@ struct annotated_source { int nr_entries; int nr_asm_entries; int max_jump_sources; + u64 start; struct { u8 addr; u8 jumps; @@ -312,7 +313,6 @@ struct annotated_branch { }; =20 struct LOCKABLE annotation { - u64 start; struct annotated_source *src; struct annotated_branch *branch; }; --=20 2.44.0.478.gd926399ef9-goog