Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf dwarf-aux: Fix __die_find_scope_cb() for namespaces

Currently __die_find_scope_cb() goes to check siblings when the DIE
doesn't include the given PC.

However namespaces don't have a PC and could contain children that have
that PC.

When we encounter a namespace, we should check both its children and
siblings.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Zecheng Li <zecheng@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xu Liu <xliuprof@google.com>
Link: https://lore.kernel.org/r/20250825195817.226560-1-zecheng@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Zecheng Li and committed by
Arnaldo Carvalho de Melo
e7ace97f 4a6ce9ad

+9
+9
tools/perf/util/dwarf-aux.c
··· 1958 1958 static int __die_find_scope_cb(Dwarf_Die *die_mem, void *arg) 1959 1959 { 1960 1960 struct find_scope_data *data = arg; 1961 + int tag = dwarf_tag(die_mem); 1961 1962 1962 1963 if (dwarf_haspc(die_mem, data->pc)) { 1963 1964 Dwarf_Die *tmp; ··· 1972 1971 data->nr++; 1973 1972 return DIE_FIND_CB_CHILD; 1974 1973 } 1974 + 1975 + /* 1976 + * If the DIE doesn't have the PC, we still need to check its children 1977 + * and siblings if it's a container like a namespace. 1978 + */ 1979 + if (tag == DW_TAG_namespace) 1980 + return DIE_FIND_CB_CONTINUE; 1981 + 1975 1982 return DIE_FIND_CB_SIBLING; 1976 1983 } 1977 1984