From: Namhyung Kim <namhyung@kernel.org>
To: Zecheng Li <zecheng@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Xu Liu <xliuprof@google.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 08/10] perf dwarf-aux: Skip check_variable for die_find_variable_by_reg
Date: Fri, 5 Sep 2025 13:09:03 -0700 [thread overview]
Message-ID: <aLtDX0W0DMMr6BE4@google.com> (raw)
In-Reply-To: <CAJUgMy+jTTAQ+=F=ddryLrftyB0h==pezZdvnZAT-UHmSU994w@mail.gmail.com>
On Wed, Sep 03, 2025 at 05:23:01PM -0400, Zecheng Li wrote:
> On Sat, Aug 30, 2025 at 3:31 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > > - In match_var_offset, use __die_get_real_type instead of
> > > die_get_real_type to preserve typedefs. Move the (offset == 0) branch
> >
> > Why do you want to preserve typedefs? I think a variable type can be
> > typedef to a pointer then now it won't resolve that target type anymore.
>
> check_variable preserves the typedefs. It would sometimes resolve to
> an unnamed struct if we remove the typedefs.
Ah, that's unfortunate.
> Let me test if it will
> affect the dwarf_tag(&data->type) == DW_TAG_pointer_type check. Also I
> found calling dwarf_aggregate_size on typedef'd types gives the
> correct result, so maybe we don't need the sized_type in
> check_variable?
You're right.
>
> > > - When comparing types from different scopes, first compare their type
> > > offsets. A larger offset means the field belongs to an outer
> > > (enclosing) struct. This helps resolve cases where a pointer is found
> > > in an inner scope, but a struct containing that pointer exists in an
> > > outer scope. Previously, is_better_type would prefer the pointer type,
> > > but the struct type is actually more complete and should be chosen.
> >
> > Can we improve is_better_type() then?
>
> Here we are comparing two types with the extra access offset
> information. In other contexts, the calls to is_better_type compares
> two types only, so I think we don't need to add two new parameters to
> is_better_type?
Right, I meant just about pointer type and struct type. It compares two
types take the same location so I didn't expect they can be a pointer
and a struct. My intention was about a pointer and a base type.
Also you may consider typedef and struct. I think we prefer struct
since it can access the member field. But as you said we should use
typedef if it's an unnamed struct. It'd be great if we can get members
even for typedefs (for structs).
>
> > > - if (!found || is_better_type(type_die, &mem_die)) {
> > > + if (!found || dloc->type_offset < type_offset ||
> > > + (dloc->type_offset == type_offset &&
> > > + is_better_type(type_die, &mem_die))) {
> > > *type_die = mem_die;
> > > dloc->type_offset = type_offset;
> > > found = true;
>
> I find changing the is_better_type call to !is_better_type(&mem_die,
> type_die) would yield better results: prefer types from outer scope if
> the current one is not "better" than the new one.
Ok, sounds good.
Thanks,
Namhyung
prev parent reply other threads:[~2025-09-05 20:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 19:58 [PATCH v2 08/10] perf dwarf-aux: Skip check_variable for die_find_variable_by_reg Zecheng Li
2025-08-30 7:31 ` Namhyung Kim
2025-09-03 21:23 ` Zecheng Li
2025-09-05 20:09 ` Namhyung Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLtDX0W0DMMr6BE4@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=xliuprof@google.com \
--cc=zecheng@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).