From nobody Sun Feb 8 11:55:54 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 1CA1A4B5AE; Sat, 3 Aug 2024 21:13:34 +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=1722719615; cv=none; b=YSvpgTnhZBso+iJcGlbhDxpycm6ni8seA5SHJDukigOAfI3ERRxQga5LCXF+vIzuOeSpPv2JbKj/25vGTrCnCYPM7wCTGayESspiqiT/IywOIYs2L26BUcCRNAQJrgr7S92A/QBhC0QA25lGWxfPMPKn6t8hvX16zKpK0rM82YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722719615; c=relaxed/simple; bh=Sa77W2mGtTdRYoOM3VRTSR43IiKdEmQY77hNIkja2PQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jiOTr+jVdlzLZx9vzsLldDFqVyF3pPLOfJnNTFBCl12C0RELpDSszpQ7r2vjKRl/+6srFs5w/ys4za57WTk0cYTqquJCIKEphkFE0c7lmupDLDsVmy18sRP/hjbSIKxZbPe9MBBu8T6S5P9hZMe3II7ySSWcqwPL885QsG3mGY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L+Bduktz; 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="L+Bduktz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48802C4AF0C; Sat, 3 Aug 2024 21:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722719614; bh=Sa77W2mGtTdRYoOM3VRTSR43IiKdEmQY77hNIkja2PQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+Bduktz/9aUD/ukNZaLzAKycBGMH/+aOYWl5/WPPlyA1Hdtve9Vz5mPxZ5EAG7gX mpnfYOG3ht26A7aet5xQ2utmHu7GIEpz/gtfenOi4O9zaIhX/kF3obmGIPPwq+TH8f oyvlcpJH9efThEOlhsg0/dAP9wIbdSzD5GLhaEu94xzpu3k69EzcqP+T4kHMBpqdgz IpSo09x5sjdI1PKxkKfwh+srdBHl35T7F6OqMr0PQU43a1lNUVE/W9u1TiAW1/jrEm cvjPV+qr03ogGz6OPX828xolLIyiKNiZ1eeo+L0rybV4ncHk/PRnN9SIPSMbjBOwa7 Ku+rhsnFbOjcw== 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/5] perf annotate: Use al->data_nr if possible Date: Sat, 3 Aug 2024 14:13:28 -0700 Message-ID: <20240803211332.1107222-2-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240803211332.1107222-1-namhyung@kernel.org> References: <20240803211332.1107222-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 data_nr keeps the number of entries in al->data[] so it should use it when it iterates the array. The notes->src->nr_events should have the same number but it'd be natural to use al->data_nr. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index a2ee4074f768..91ad948c89d5 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1594,13 +1594,12 @@ bool ui__has_annotation(void) =20 =20 static double annotation_line__max_percent(struct annotation_line *al, - struct annotation *notes, unsigned int percent_type) { double percent_max =3D 0.0; int i; =20 - for (i =3D 0; i < notes->src->nr_events; i++) { + for (i =3D 0; i < al->data_nr; i++) { double percent; =20 percent =3D annotation_data__percent(&al->data[i], @@ -1672,7 +1671,7 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati void (*obj__write_graph)(void *obj, int graph)) =20 { - double percent_max =3D annotation_line__max_percent(al, notes, percent_ty= pe); + double percent_max =3D annotation_line__max_percent(al, percent_type); int pcnt_width =3D annotation__pcnt_width(notes), cycles_width =3D annotation__cycles_width(notes); bool show_title =3D false; @@ -1690,7 +1689,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->src->nr_events; i++) { + for (i =3D 0; i < al->data_nr; i++) { double percent; =20 percent =3D annotation_data__percent(&al->data[i], percent_type); --=20 2.46.0.rc2.264.g509ed76dc8-goog From nobody Sun Feb 8 11:55:54 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 9076F61FF6; Sat, 3 Aug 2024 21:13:35 +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=1722719615; cv=none; b=DgK0yOyJTr+X1eAXiN6KampK7/TnDOewvf1afiUd0u88eBybcfzsr+msn8mMDMq8ft7Ipsyoy+53xIf4bU3Q5kJi/+52ED9QcDVRnw7aXuwi/b9e8qRA7dsunUN8KOg9CW+ceVzokgK5ysdIiCvcilqoyoy3Ak7x9nbQrjKFEno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722719615; c=relaxed/simple; bh=S74RA+BGZpwoXEEN1ma65H75GaeDz2xqt/5KZxfR5+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7MHzbmcJvOlbEpRIBZr1sEbrlUNeYodt3a+u4uR8Qbjm5yL2UT/4dLFFkY/vDkbqsyXvDFquS/SnD+BGeOee6bIImv2F182e6StREPzwyoeJYOitY4jOGXJg2v3D22QSjRbbfEbsJbhUVtr3d7RZKaNLh7i+ehMArq5AS1d820= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PwkcaR4B; 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="PwkcaR4B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCBBDC4AF10; Sat, 3 Aug 2024 21:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722719615; bh=S74RA+BGZpwoXEEN1ma65H75GaeDz2xqt/5KZxfR5+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PwkcaR4BevnQqcARPbkPRjaaiDzyHWyh4mA5Adx/PsaJTA2Hbu9ZQwDq7Qcrexznc oZq3uVmtfMRjtINcJpCcq5tLy+cbXbXaV6oJzZz2EtDXkCk+WrBBnwQckvcMiSDtwV AV8FTBg6G4j1gpI4sEJYi5PoIEz4Eqr5mf7HW6OtX4t/z5syTU67S8CJTMdcS0VxMJ srL8SmtUFv15LD9B5FkhWi0JpKl+nHnccVA/klOxSwkNvcFT6DrOeujfkFOuHnW1ej cASY/UIqjzpJpfGFPhxFLocti0V71KI+BGVF+uInMkPS89ek5sqp7mo6Bp6uzKowTs 8XkPoeYCJIurQ== 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/5] perf annotate: Set notes->src->nr_events early Date: Sat, 3 Aug 2024 14:13:29 -0700 Message-ID: <20240803211332.1107222-3-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240803211332.1107222-1-namhyung@kernel.org> References: <20240803211332.1107222-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" We want to use it in different places so make sure it sets properly in symbol__annotate() before creating the disasm lines. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 91ad948c89d5..09e6fdf344db 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -925,6 +925,11 @@ int symbol__annotate(struct map_symbol *ms, struct evs= el *evsel, return -1; } =20 + if (evsel__is_group_event(evsel)) + notes->src->nr_events =3D evsel->core.nr_members; + else + notes->src->nr_events =3D 1; + if (annotate_opts.full_addr) notes->src->start =3D map__objdump_2mem(ms->map, ms->sym->start); else @@ -1842,10 +1847,7 @@ int symbol__annotate2(struct map_symbol *ms, struct = evsel *evsel, struct symbol *sym =3D ms->sym; struct annotation *notes =3D symbol__annotation(sym); size_t size =3D symbol__size(sym); - int nr_pcnt =3D 1, err; - - if (evsel__is_group_event(evsel)) - nr_pcnt =3D evsel->core.nr_members; + int err; =20 err =3D symbol__annotate(ms, evsel, parch); if (err) @@ -1861,8 +1863,6 @@ int symbol__annotate2(struct map_symbol *ms, struct e= vsel *evsel, return err; =20 annotation__init_column_widths(notes, sym); - notes->src->nr_events =3D nr_pcnt; - annotation__update_column_widths(notes); sym->annotate2 =3D 1; =20 --=20 2.46.0.rc2.264.g509ed76dc8-goog From nobody Sun Feb 8 11:55:54 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 05DF37A15B; Sat, 3 Aug 2024 21:13:35 +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=1722719616; cv=none; b=T3m+9pfYvZ4pS9wvY9gWuNqSccnEpFYkL6acbpA5asRfRZIrf02C8jXNHpK0eTq0RvyP5Ytwci6zMiiIp/tpOzlXBRF7IGKuCRWjydlDeFJz1Jz2TrwcVpmthMADZwhEeSTTyHKwRUNKzLiz3ZPuDZh8wBzFzuBOcfGudpnw8q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722719616; c=relaxed/simple; bh=ok6PGsh/+Fs0qcgvUyNyMRF5vVVomjzdfg9xzoFAORo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EDitCgvyJS+z2dCNMSdepTSD7ntCwk5VzcMFPe5Q80tpR2a/XCZwlv1uT6AAUlbIym9X8RhfL+jg9ZCs6S3tBeSLf05LuIe0bI0q2x/ZSYXtKS2M5njH4zL0KFMtwSiHVNyD7xrRzjoBeiiV3+OgBmTJ0hsnaqZIdf0SYu9eK9U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMtjZvvr; 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="uMtjZvvr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E0B6C4AF1D; Sat, 3 Aug 2024 21:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722719615; bh=ok6PGsh/+Fs0qcgvUyNyMRF5vVVomjzdfg9xzoFAORo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMtjZvvr0G/yrL4T01dk6hUg3726zZlHsLGUTieKY0RB/Wb5t98AQqbFAQ8xVqr1M JN6M512kOxcqEWRuhXFY0QYrzWGhXPk6gL98RIKpW4kMmFwja0KvjiQl9CV6l3TCMv Lu2yatIlIp3lbPAY+0mk/nk17rynShp1NSqrr1AN5PNYjwBCHWvmMyX3zdyx/3ZJ0f eCjcf7hfDWf4NyfxPcafeTi5g7F3jLaXFN0edqEY8HlMPkG3i/+9wEBmHgxRRzmB+N J5d3hPCXZOtDar6mRRrUHjZwTkv1Z27JcE8JP/z+hEGeHT97bi5Q9dhOp8KbRWWil9 oeA569INLjTDA== 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/5] perf annotate: Use annotation__pcnt_width() consistently Date: Sat, 3 Aug 2024 14:13:30 -0700 Message-ID: <20240803211332.1107222-4-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240803211332.1107222-1-namhyung@kernel.org> References: <20240803211332.1107222-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 annotation__pcnt_width() calculates the screen width for the overhead (percent) area considering event groups properly. Use this function consistently so that we can make sure it has similar output in different modes. But there's a difference in stdio and tui output: stdio uses 8 and tui uses 7 for a percent. Let's use 8 and adjust the print width in __annotation_line__write() properly. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 14 +++++--------- tools/perf/util/annotate.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 09e6fdf344db..917897fe44a2 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -699,13 +699,13 @@ annotation_line__print(struct annotation_line *al, st= ruct symbol *sym, u64 start int percent_type) { struct disasm_line *dl =3D container_of(al, struct disasm_line, al); + struct annotation *notes =3D symbol__annotation(sym); static const char *prev_line; =20 if (al->offset !=3D -1) { double max_percent =3D 0.0; int i, nr_percent =3D 1; const char *color; - struct annotation *notes =3D symbol__annotation(sym); =20 for (i =3D 0; i < al->data_nr; i++) { double percent; @@ -775,14 +775,11 @@ annotation_line__print(struct annotation_line *al, st= ruct symbol *sym, u64 start } else if (max_lines && printed >=3D max_lines) return 1; else { - int width =3D symbol_conf.show_total_period ? 12 : 8; + int width =3D annotation__pcnt_width(notes); =20 if (queue) return -1; =20 - if (evsel__is_group_event(evsel)) - width *=3D evsel->core.nr_members; - if (!*al->line) printf(" %*s:\n", width, " "); else @@ -1111,7 +1108,7 @@ int symbol__annotate_printf(struct map_symbol *ms, st= ruct evsel *evsel) int more =3D 0; bool context =3D opts->context; u64 len; - int width =3D symbol_conf.show_total_period ? 12 : 8; + int width =3D annotation__pcnt_width(notes); int graph_dotted_len; char buf[512]; =20 @@ -1127,7 +1124,6 @@ int symbol__annotate_printf(struct map_symbol *ms, st= ruct evsel *evsel) len =3D symbol__size(sym); =20 if (evsel__is_group_event(evsel)) { - width *=3D evsel->core.nr_members; evsel__group_desc(evsel, buf, sizeof(buf)); evsel_name =3D buf; } @@ -1703,10 +1699,10 @@ static void __annotation_line__write(struct annotat= ion_line *al, struct annotati if (symbol_conf.show_total_period) { obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period); } else if (symbol_conf.show_nr_samples) { - obj__printf(obj, "%6" PRIu64 " ", + obj__printf(obj, "%7" PRIu64 " ", al->data[i].he.nr_samples); } else { - obj__printf(obj, "%6.2f ", percent); + obj__printf(obj, "%7.2f ", percent); } } } else { diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 9ba772f46270..64e70d716ff1 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -339,7 +339,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->src->nr_events; + return (symbol_conf.show_total_period ? 12 : 8) * notes->src->nr_events; } =20 static inline bool annotation_line__filter(struct annotation_line *al) --=20 2.46.0.rc2.264.g509ed76dc8-goog From nobody Sun Feb 8 11:55:54 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 3970812E1DB; Sat, 3 Aug 2024 21:13:36 +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=1722719616; cv=none; b=YvY4NMjwWACDNI0ZbETCBC3OyGszIcgn6E3fa80/9r6oNyTFvYE8Q+E+rWbh+MltGJyVxrVen4zs3vWzA7SE+aLswSCx3LKZd099b5fD2mV0z5edR3NXUxJli03ctD7ZF+qhtDGQtnPFOVKmXnR5feIYD5vbI/Ek/ca3EYANJd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722719616; c=relaxed/simple; bh=3Do5Nqsn5IpyIKiHPCwjz0+bX/709KjClVS+haHKStY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cBqenpz7cfGwEeePinIG4I/d3oDC0QkBurkoS8tmxUwRUO4B35tU2CCA+rOD9wrjTxLB2PrmPahoJ/3KMSn3woLx+81D2I3I50U6NrrOY/ZJLfB9MXsa2duEMfN33E3eEZvZzMH4/WsLLDMOUgcbRa6nOCL1XKj3SpHohjzo+VQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFprdLxV; 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="jFprdLxV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3A1AC4AF60; Sat, 3 Aug 2024 21:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722719616; bh=3Do5Nqsn5IpyIKiHPCwjz0+bX/709KjClVS+haHKStY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFprdLxVncAKuyLzrnPSHn5Z1jDjQmXNuu94arGNPMLXvMNVWCeAOhDlSKReBpI/A lyO9pb2obW3H8Jip1nX2m0Hv0jTqCOr5sUbjd+ezPZOcVGpSHfsjATjcGTBGnI9Vk8 ozcgcL4QBWLG8VidBTroCeTVLP44r7IH61NRHLV++b/Ap8jguaP6pALdyd24t0UHTt ESbUwfhGzPQctAulrSD+WB8e+6Rbmx0yXiVOJ2WYZImqHXa+3T8Z4JO04Rx6+GEUgw 8O23sOc8ajdB/UjNspF8cXD4/Ga3Ywo0cY+5uTytYYnxTz4BVLsyy4mlgG1JRZGcfb gmg4bWk3kR1dw== 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/5] perf annotate: Set al->data_nr using the notes->src->nr_events Date: Sat, 3 Aug 2024 14:13:31 -0700 Message-ID: <20240803211332.1107222-5-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240803211332.1107222-1-namhyung@kernel.org> References: <20240803211332.1107222-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" This is a preparation to support skipping empty events. Signed-off-by: Namhyung Kim --- tools/perf/util/disasm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 85fb0cfedf94..22289003e16d 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -1037,10 +1037,8 @@ static size_t disasm_line_size(int nr) struct disasm_line *disasm_line__new(struct annotate_args *args) { struct disasm_line *dl =3D NULL; - int nr =3D 1; - - if (evsel__is_group_event(args->evsel)) - nr =3D args->evsel->core.nr_members; + struct annotation *notes =3D symbol__annotation(args->ms.sym); + int nr =3D notes->src->nr_events; =20 dl =3D zalloc(disasm_line_size(nr)); if (!dl) --=20 2.46.0.rc2.264.g509ed76dc8-goog From nobody Sun Feb 8 11:55:54 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 0914B13A268; Sat, 3 Aug 2024 21:13:36 +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=1722719617; cv=none; b=UuirK7rFlo6IsdkVwoinROzBR7zYXF33LkJ326F77r38bMoCZb1EoW0R7H+VDR/DFNXa7gjLNddp3hrbgvcmI5/j7RJcXBcGT53SiWJTY1eaMSTa8J6CjAYzBCJ0IwpWsDKq9iAdlbfIvKpovPwWZq/wP9n7xHIyVZTEsK6+MeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722719617; c=relaxed/simple; bh=bzxWFY3qSDkeG5BTvniUSpMK/drRzTB6XLQAiW1I2O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ra9Xxs9Ux3oZ+FTddhwFYnPuuSc/uVycJi3SWpofkhjYoQOxTPXoBoKkG0GfVkY5B2Fkw/skmmwOZWPkhaYcA0HtmgpS/lNashYD5GOPsvkJlyVJCceOm2aiLN1WfyTSc/9i4Y6M8bx2xUlrX0dFzSqCx0Hg3ez6MZik+ZNAPDw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mkU2DGCi; 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="mkU2DGCi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 380B8C4AF0E; Sat, 3 Aug 2024 21:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722719616; bh=bzxWFY3qSDkeG5BTvniUSpMK/drRzTB6XLQAiW1I2O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mkU2DGCiQYdlEBQ0VHLWXGJXC2j4OM+frPhwBtjVTLrKp7s8ncHPmNp8WUgsIKenU YBYRZlUjOzpotcWlYouPkRu3dDRj30dfgSSp65AyuwdvkEPhtZyBiOQhHwsgOCVdH/ BteBxkseM0XFp8SFjvITnMyzbeZ3S7DXz5QlwLX3yaY0UrimORb751teVP+JAD3dwe HqMpoWW1fcaz06ggq4Gn/z+fNm9SFvTaytTC5bjdxCJRMjD/j5WH/qSDlT7tIbkhbj 14HasQ9Uh572Hp6OqlVQ5PCDcFfWnt2Sj6+4FrEjI6O42ceykZvQo98wvB5WVSZgGW UhTAqAmE3RucQ== 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/5] perf annotate: Add --skip-empty option Date: Sat, 3 Aug 2024 14:13:32 -0700 Message-ID: <20240803211332.1107222-6-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240803211332.1107222-1-namhyung@kernel.org> References: <20240803211332.1107222-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" Like in perf report, we want to hide empty events in the perf annotate output. This is consistent when the option is set in perf report. For example, the following command would use 3 events including dummy. $ perf mem record -a -- perf test -w noploop $ perf evlist cpu/mem-loads,ldlat=3D30/P cpu/mem-stores/P dummy:u Just using perf annotate with --group will show the all 3 events. $ perf annotate --group --stdio | head Percent | Source code & Disassembly of ... -------------------------------------------------------------- : 0 0xe060 <_dl_relocate_object>: 0.00 0.00 0.00 : e060: pushq %rbp 0.00 0.00 0.00 : e061: movq %rsp, %rbp 0.00 0.00 0.00 : e064: pushq %r15 0.00 0.00 0.00 : e066: movq %rdi, %r15 0.00 0.00 0.00 : e069: pushq %r14 0.00 0.00 0.00 : e06b: pushq %r13 0.00 0.00 0.00 : e06d: movl %edx, %r13d Now with --skip-empty, it'll hide the last dummy event. $ perf annotate --group --stdio --skip-empty | head Percent | Source code & Disassembly of ... ------------------------------------------------------ : 0 0xe060 <_dl_relocate_object>: 0.00 0.00 : e060: pushq %rbp 0.00 0.00 : e061: movq %rsp, %rbp 0.00 0.00 : e064: pushq %r15 0.00 0.00 : e066: movq %rdi, %r15 0.00 0.00 : e069: pushq %r14 0.00 0.00 : e06b: pushq %r13 0.00 0.00 : e06d: movl %edx, %r13d Signed-off-by: Namhyung Kim Reported-by: Arnaldo Carvalho de Melo Tested-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-annotate.txt | 3 +++ tools/perf/builtin-annotate.c | 2 ++ tools/perf/util/annotate.c | 22 +++++++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Docume= ntation/perf-annotate.txt index b95524bea021..156c5f37b051 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -165,6 +165,9 @@ include::itrace.txt[] --type-stat:: Show stats for the data type annotation. =20 +--skip-empty:: + Do not display empty (or dummy) events. + =20 SEE ALSO -------- diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index cf60392b1c19..efcadb7620b8 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -795,6 +795,8 @@ int cmd_annotate(int argc, const char **argv) "Show stats for the data type annotation"), OPT_BOOLEAN(0, "insn-stat", &annotate.insn_stat, "Show instruction stats for the data type annotation"), + OPT_BOOLEAN(0, "skip-empty", &symbol_conf.skip_empty, + "Do not display empty (or dummy) events in the output"), OPT_END() }; int ret; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 917897fe44a2..eafe8d65052e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -848,6 +848,10 @@ static void annotation__calc_percent(struct annotation= *notes, =20 BUG_ON(i >=3D al->data_nr); =20 + if (symbol_conf.skip_empty && + evsel__hists(evsel)->stats.nr_samples =3D=3D 0) + continue; + data =3D &al->data[i++]; =20 calc_percent(notes, evsel, data, al->offset, end); @@ -901,7 +905,7 @@ int symbol__annotate(struct map_symbol *ms, struct evse= l *evsel, .options =3D &annotate_opts, }; struct arch *arch =3D NULL; - int err; + int err, nr; =20 err =3D evsel__get_arch(evsel, &arch); if (err < 0) @@ -922,10 +926,18 @@ int symbol__annotate(struct map_symbol *ms, struct ev= sel *evsel, return -1; } =20 - if (evsel__is_group_event(evsel)) - notes->src->nr_events =3D evsel->core.nr_members; - else - notes->src->nr_events =3D 1; + nr =3D 0; + if (evsel__is_group_event(evsel)) { + struct evsel *pos; + + for_each_group_evsel(pos, evsel) { + if (symbol_conf.skip_empty && + evsel__hists(pos)->stats.nr_samples =3D=3D 0) + continue; + nr++; + } + } + notes->src->nr_events =3D nr ? nr : 1; =20 if (annotate_opts.full_addr) notes->src->start =3D map__objdump_2mem(ms->map, ms->sym->start); --=20 2.46.0.rc2.264.g509ed76dc8-goog