public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Zecheng Li <zli94@ncsu.edu>
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>,
	James Clark <james.clark@linaro.org>,
	xliuprof@google.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org, Zecheng Li <zecheng@google.com>
Subject: Re: [PATCH v1 04/11] perf annotate-data: Improve type comparison from different scopes
Date: Tue, 10 Feb 2026 18:25:53 -0800	[thread overview]
Message-ID: <aYvosW_R6XjGmVSm@google.com> (raw)
In-Reply-To: <20260127020617.2804780-5-zli94@ncsu.edu>

On Mon, Jan 26, 2026 at 09:04:57PM -0500, Zecheng Li wrote:
> From: Zecheng Li <zecheng@google.com>
> 
> 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.
> 
> Prefer types from outer scopes when is_better_type cannot determine
> a better type. This is a heuristic for the case `struct A { struct B; }`
> where A and B have the same size but I think in most cases A is in the
> outer scope and should be preferred.
> 
> Signed-off-by: Zecheng Li <zecheng@google.com>
> Signed-off-by: Zecheng Li <zli94@ncsu.edu>

Reviewed-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/util/annotate-data.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> index 8ff1972981b7..8ea3e8b024e8 100644
> --- a/tools/perf/util/annotate-data.c
> +++ b/tools/perf/util/annotate-data.c
> @@ -1634,7 +1634,9 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die)
>  				pr_debug_dtp("type_offset=%#x\n", type_offset);
>  			}
>  
> -			if (!found || is_better_type(type_die, &mem_die)) {
> +			if (!found || dloc->type_offset < type_offset ||
> +			    (dloc->type_offset == type_offset &&
> +			     !is_better_type(&mem_die, type_die))) {
>  				*type_die = mem_die;
>  				dloc->type_offset = type_offset;
>  				found = true;
> -- 
> 2.52.0
> 

  reply	other threads:[~2026-02-11  2:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27  2:04 [PATCH v1 00/11] perf tools: Improvements to data type profiler Zecheng Li
2026-01-27  2:04 ` [PATCH v1 01/11] perf dwarf-aux: Skip check_variable for die_find_variable_by_reg Zecheng Li
2026-02-11  2:08   ` Namhyung Kim
2026-01-27  2:04 ` [PATCH v1 02/11] perf dwarf-aux: Add die_get_pointer_type to get pointer types Zecheng Li
2026-02-11  2:17   ` Namhyung Kim
2026-01-27  2:04 ` [PATCH v1 03/11] perf dwarf-aux: Preserve typedefs in match_var_offset Zecheng Li
2026-02-11  2:23   ` Namhyung Kim
2026-01-27  2:04 ` [PATCH v1 04/11] perf annotate-data: Improve type comparison from different scopes Zecheng Li
2026-02-11  2:25   ` Namhyung Kim [this message]
2026-01-27  2:04 ` [PATCH v1 05/11] perf dwarf-aux: Handle array types in die_get_member_type Zecheng Li
2026-01-27  2:04 ` [PATCH v1 06/11] perf annotate-data: Collect global variables without name Zecheng Li
2026-02-11  2:29   ` Namhyung Kim
2026-01-27  2:05 ` [PATCH v1 07/11] perf annotate-data: Handle global variable access with const register Zecheng Li
2026-02-11  2:37   ` Namhyung Kim
2026-01-27  2:05 ` [PATCH v1 08/11] perf annotate-data: Add invalidate_reg_state() helper for x86 Zecheng Li
2026-02-11  2:38   ` Namhyung Kim
2026-01-27  2:05 ` [PATCH v1 09/11] perf annotate-data: Invalidate caller-saved regs for all calls Zecheng Li
2026-01-27  2:05 ` [PATCH v1 10/11] perf annotate-data: Use DWARF location ranges to preserve reg state Zecheng Li
2026-01-27  2:05 ` [PATCH v1 11/11] perf dwarf-aux: Collect all variable locations for insn tracking Zecheng Li

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=aYvosW_R6XjGmVSm@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=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=xliuprof@google.com \
    --cc=zecheng@google.com \
    --cc=zli94@ncsu.edu \
    /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