* [PATCH v1] perf test type profiling: Remote typedef on struct [not found] <jiwt5mjma2puv7kjbgploxx2l5tankjm4zu2tsa75qkckwnwjk@f7mz5vlvzpjz> @ 2026-03-02 23:58 ` Ian Rogers 2026-03-04 10:44 ` Dmitry Dolgov 2026-03-04 21:48 ` Namhyung Kim 0 siblings, 2 replies; 8+ messages in thread From: Ian Rogers @ 2026-03-02 23:58 UTC (permalink / raw) To: 9erthalion6 Cc: miguel.ojeda.sandonis, a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, irogers, linux-kernel, linux-perf-users, lossin, namhyung, ojeda, rust-for-linux, tmgross The typedef creates an issue where the struct or the typedef may appear in the output and cause the "perf data type profiling tests" to fail. Let's remove the typedef to keep the test passing. Fixes: 335047109d7d ("perf tests: Test annotate with data type profiling and C") Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/tests/shell/data_type_profiling.sh | 2 +- tools/perf/tests/workloads/datasym.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/data_type_profiling.sh b/tools/perf/tests/shell/data_type_profiling.sh index 2a7f8f7c42d0..fb47b7213b33 100755 --- a/tools/perf/tests/shell/data_type_profiling.sh +++ b/tools/perf/tests/shell/data_type_profiling.sh @@ -8,7 +8,7 @@ set -e # data type profiling manifestation # Values in testtypes and testprogs should match -testtypes=("# data-type: struct Buf" "# data-type: struct _buf") +testtypes=("# data-type: struct Buf" "# data-type: struct buf") testprogs=("perf test -w code_with_type" "perf test -w datasym") err=0 diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c index 1d0b7d64e1ba..19242c7255c0 100644 --- a/tools/perf/tests/workloads/datasym.c +++ b/tools/perf/tests/workloads/datasym.c @@ -4,14 +4,14 @@ #include <linux/compiler.h> #include "../tests.h" -typedef struct _buf { +struct buf { char data1; char reserved[55]; char data2; -} buf __attribute__((aligned(64))); +} __attribute__((aligned(64))); /* volatile to try to avoid the compiler seeing reserved as unused. */ -static volatile buf workload_datasym_buf1 = { +static volatile struct buf workload_datasym_buf1 = { /* to have this in the data section */ .reserved[0] = 1, }; -- 2.53.0.473.g4a7958ca14-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-02 23:58 ` [PATCH v1] perf test type profiling: Remote typedef on struct Ian Rogers @ 2026-03-04 10:44 ` Dmitry Dolgov 2026-03-04 20:34 ` Arnaldo Carvalho de Melo 2026-03-29 16:18 ` Dmitry Dolgov 2026-03-04 21:48 ` Namhyung Kim 1 sibling, 2 replies; 8+ messages in thread From: Dmitry Dolgov @ 2026-03-04 10:44 UTC (permalink / raw) To: Ian Rogers Cc: miguel.ojeda.sandonis, a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, namhyung, ojeda, rust-for-linux, tmgross > On Mon, Mar 02, 2026 at 03:58:21PM -0800, Ian Rogers wrote: > The typedef creates an issue where the struct or the typedef may > appear in the output and cause the "perf data type profiling tests" to > fail. Let's remove the typedef to keep the test passing. Yes, makes sense to me, thanks. As mentioned in the previous message, it sounds fishy to me that perf record and perf mem record capture different data type -- I'll try to get to the bottom of it (I was sort of hoping to finish the cross compilation topic first, but since it's not moving that fast, why not do some debugging here). Reviewed-by: Dmitrii Dolgov <9erthalion6@gmail.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-04 10:44 ` Dmitry Dolgov @ 2026-03-04 20:34 ` Arnaldo Carvalho de Melo 2026-03-29 16:18 ` Dmitry Dolgov 1 sibling, 0 replies; 8+ messages in thread From: Arnaldo Carvalho de Melo @ 2026-03-04 20:34 UTC (permalink / raw) To: Dmitry Dolgov Cc: Ian Rogers, miguel.ojeda.sandonis, a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, namhyung, ojeda, rust-for-linux, tmgross On Wed, Mar 04, 2026 at 11:44:16AM +0100, Dmitry Dolgov wrote: > > On Mon, Mar 02, 2026 at 03:58:21PM -0800, Ian Rogers wrote: > > The typedef creates an issue where the struct or the typedef may > > appear in the output and cause the "perf data type profiling tests" to > > fail. Let's remove the typedef to keep the test passing. > > Yes, makes sense to me, thanks. As mentioned in the previous message, it > sounds fishy to me that perf record and perf mem record capture > different data type -- I'll try to get to the bottom of it (I was sort > of hoping to finish the cross compilation topic first, but since it's > not moving that fast, why not do some debugging here). > > Reviewed-by: Dmitrii Dolgov <9erthalion6@gmail.com> Thanks, applied to perf-tools, for v7.0. - Arnaldo ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-04 10:44 ` Dmitry Dolgov 2026-03-04 20:34 ` Arnaldo Carvalho de Melo @ 2026-03-29 16:18 ` Dmitry Dolgov 2026-03-31 6:42 ` Namhyung Kim 1 sibling, 1 reply; 8+ messages in thread From: Dmitry Dolgov @ 2026-03-29 16:18 UTC (permalink / raw) To: Ian Rogers Cc: miguel.ojeda.sandonis, a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, namhyung, ojeda, rust-for-linux, tmgross > On Wed, Mar 04, 2026 at 11:44:16AM +0100, Dmitry Dolgov wrote: > > On Mon, Mar 02, 2026 at 03:58:21PM -0800, Ian Rogers wrote: > > The typedef creates an issue where the struct or the typedef may > > appear in the output and cause the "perf data type profiling tests" to > > fail. Let's remove the typedef to keep the test passing. > > Yes, makes sense to me, thanks. As mentioned in the previous message, it > sounds fishy to me that perf record and perf mem record capture > different data type -- I'll try to get to the bottom of it. I think I figured it out. To reiterate, the problem was that in my environment this: $ perf record ... $ perf annotate --code-with-type ... was showing a different data structure for workload_datasym_buf1 (buf vs struct _buf) than: $ perf mem record ... $ perf annotate --code-with-type ... It turns out that the type_die for this variable was derived differently: for "record" it was going through check_variable, for "mem record" through global_var__collect. If the type tag is DW_TAG_typedef, check_variable tries to figure out a real data type via die_get_real_type, which says this: /** * [...] * If the type is qualifiers (e.g. const) or typedef, this skips it * and tries to find real type (structure or basic types, e.g. int). */ But the underlying implementation doesn't actually check for DW_TAG_typedef for some reason: while (tag == DW_TAG_const_type || tag == DW_TAG_restrict_type || tag == DW_TAG_volatile_type || tag == DW_TAG_shared_type); By itself it doesn't look problematic, but for some reason datasym test was producing such a code, that had a chain of two DW_TAG_typedef in a row, so that die_get_real_type was returning a DW_TAG_typedef again. It looks to me like a deficiency of die_get_real_type, and the following code change fixes the problem for me: diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 9267af204c7..de152fae1d9 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -279,6 +279,7 @@ Dwarf_Die *__die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) } while (tag == DW_TAG_const_type || tag == DW_TAG_restrict_type || tag == DW_TAG_volatile_type || + tag == DW_TAG_typedef || tag == DW_TAG_shared_type); return vr_die; Does this change sound reasonable? ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-29 16:18 ` Dmitry Dolgov @ 2026-03-31 6:42 ` Namhyung Kim 2026-03-31 19:22 ` Dmitry Dolgov 0 siblings, 1 reply; 8+ messages in thread From: Namhyung Kim @ 2026-03-31 6:42 UTC (permalink / raw) To: Dmitry Dolgov Cc: Ian Rogers, miguel.ojeda.sandonis, a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, ojeda, rust-for-linux, tmgross Hello, On Sun, Mar 29, 2026 at 06:18:52PM +0200, Dmitry Dolgov wrote: > > On Wed, Mar 04, 2026 at 11:44:16AM +0100, Dmitry Dolgov wrote: > > > On Mon, Mar 02, 2026 at 03:58:21PM -0800, Ian Rogers wrote: > > > The typedef creates an issue where the struct or the typedef may > > > appear in the output and cause the "perf data type profiling tests" to > > > fail. Let's remove the typedef to keep the test passing. > > > > Yes, makes sense to me, thanks. As mentioned in the previous message, it > > sounds fishy to me that perf record and perf mem record capture > > different data type -- I'll try to get to the bottom of it. > > I think I figured it out. To reiterate, the problem was that in my environment > this: > > $ perf record ... > $ perf annotate --code-with-type ... > > was showing a different data structure for workload_datasym_buf1 (buf vs struct > _buf) than: > > $ perf mem record ... > $ perf annotate --code-with-type ... > > It turns out that the type_die for this variable was derived differently: for > "record" it was going through check_variable, for "mem record" through > global_var__collect. If the type tag is DW_TAG_typedef, check_variable tries to > figure out a real data type via die_get_real_type, which says this: > > /** > * [...] > * If the type is qualifiers (e.g. const) or typedef, this skips it > * and tries to find real type (structure or basic types, e.g. int). > */ > > But the underlying implementation doesn't actually check for DW_TAG_typedef for > some reason: > > while (tag == DW_TAG_const_type || > tag == DW_TAG_restrict_type || > tag == DW_TAG_volatile_type || > tag == DW_TAG_shared_type); > > By itself it doesn't look problematic, but for some reason datasym test was > producing such a code, that had a chain of two DW_TAG_typedef in a row, so that > die_get_real_type was returning a DW_TAG_typedef again. > > It looks to me like a deficiency of die_get_real_type, and the following code > change fixes the problem for me: > > diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c > index 9267af204c7..de152fae1d9 100644 > --- a/tools/perf/util/dwarf-aux.c > +++ b/tools/perf/util/dwarf-aux.c > @@ -279,6 +279,7 @@ Dwarf_Die *__die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) > } while (tag == DW_TAG_const_type || > tag == DW_TAG_restrict_type || > tag == DW_TAG_volatile_type || > + tag == DW_TAG_typedef || > tag == DW_TAG_shared_type); > > return vr_die; > > Does this change sound reasonable? We have this: Dwarf_Die *die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) { do { vr_die = __die_get_real_type(vr_die, die_mem); } while (vr_die && dwarf_tag(vr_die) == DW_TAG_typedef); return vr_die; } Thanks, Namhyung ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-31 6:42 ` Namhyung Kim @ 2026-03-31 19:22 ` Dmitry Dolgov 0 siblings, 0 replies; 8+ messages in thread From: Dmitry Dolgov @ 2026-03-31 19:22 UTC (permalink / raw) To: Namhyung Kim Cc: Ian Rogers, miguel.ojeda.sandonis, a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, ojeda, rust-for-linux, tmgross > On Mon, Mar 30, 2026 at 11:42:25PM -0700, Namhyung Kim wrote: > > We have this: > > Dwarf_Die *die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) > { > do { > vr_die = __die_get_real_type(vr_die, die_mem); > } while (vr_die && dwarf_tag(vr_die) == DW_TAG_typedef); > > return vr_die; > } Indeed, I didn't finish the analysis, fooled that the diff was solving the issue. Adding DW_TAG_typedef into __die_get_real_type still fixes the problem, but due to different reasons: * check_variable calls __die_get_real_type directly at the beginning and stores the result in type_die, which is the result of the function. * if it doesn't resolve DW_TAG_typedef, the flow goes into the die_get_real_type, which stores the result in the local variable sized_type. But it never copied into the type_die, and never returned as a result of the check_variable. Hence we either need to add DW_TAG_typedef into __die_get_real_type, or copy sized_type into type_die. After some testing both seems to be achieving the goal. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-02 23:58 ` [PATCH v1] perf test type profiling: Remote typedef on struct Ian Rogers 2026-03-04 10:44 ` Dmitry Dolgov @ 2026-03-04 21:48 ` Namhyung Kim 2026-03-04 22:04 ` Arnaldo Carvalho de Melo 1 sibling, 1 reply; 8+ messages in thread From: Namhyung Kim @ 2026-03-04 21:48 UTC (permalink / raw) To: 9erthalion6, Ian Rogers Cc: a.hindborg, acme, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, ojeda, rust-for-linux, tmgross, Miguel Ojeda On Mon, 02 Mar 2026 15:58:21 -0800, Ian Rogers wrote: > The typedef creates an issue where the struct or the typedef may > appear in the output and cause the "perf data type profiling tests" to > fail. Let's remove the typedef to keep the test passing. > > Applied to perf-tools-next, thanks! Best regards, Namhyung ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] perf test type profiling: Remote typedef on struct 2026-03-04 21:48 ` Namhyung Kim @ 2026-03-04 22:04 ` Arnaldo Carvalho de Melo 0 siblings, 0 replies; 8+ messages in thread From: Arnaldo Carvalho de Melo @ 2026-03-04 22:04 UTC (permalink / raw) To: Namhyung Kim Cc: 9erthalion6, Ian Rogers, a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, linux-kernel, linux-perf-users, lossin, ojeda, rust-for-linux, tmgross On Wed, Mar 04, 2026 at 01:48:53PM -0800, Namhyung Kim wrote: > On Mon, 02 Mar 2026 15:58:21 -0800, Ian Rogers wrote: > > The typedef creates an issue where the struct or the typedef may > > appear in the output and cause the "perf data type profiling tests" to > > fail. Let's remove the typedef to keep the test passing. > > > > > Applied to perf-tools-next, thanks! I applied this to perf-tools as well, for now just at tmp.perf-tools tho. - Arnaldo ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-03-31 19:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <jiwt5mjma2puv7kjbgploxx2l5tankjm4zu2tsa75qkckwnwjk@f7mz5vlvzpjz>
2026-03-02 23:58 ` [PATCH v1] perf test type profiling: Remote typedef on struct Ian Rogers
2026-03-04 10:44 ` Dmitry Dolgov
2026-03-04 20:34 ` Arnaldo Carvalho de Melo
2026-03-29 16:18 ` Dmitry Dolgov
2026-03-31 6:42 ` Namhyung Kim
2026-03-31 19:22 ` Dmitry Dolgov
2026-03-04 21:48 ` Namhyung Kim
2026-03-04 22:04 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox