From: Zecheng Li Date: Mon, 25 Aug 2025 19:58:17 +0000 (+0000) Subject: perf dwarf-aux: Fix __die_find_scope_cb() for namespaces X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e7ace97fcf6d2eb458bd7e16bba8e3f24d396e9b;p=users%2Fhch%2Fmisc.git 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 Signed-off-by: Zecheng Li Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ian Rogers Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Xu Liu Link: https://lore.kernel.org/r/20250825195817.226560-1-zecheng@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 6fd2db5d9381..9267af204c7d 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1958,6 +1958,7 @@ struct find_scope_data { static int __die_find_scope_cb(Dwarf_Die *die_mem, void *arg) { struct find_scope_data *data = arg; + int tag = dwarf_tag(die_mem); if (dwarf_haspc(die_mem, data->pc)) { Dwarf_Die *tmp; @@ -1971,6 +1972,14 @@ static int __die_find_scope_cb(Dwarf_Die *die_mem, void *arg) data->nr++; return DIE_FIND_CB_CHILD; } + + /* + * If the DIE doesn't have the PC, we still need to check its children + * and siblings if it's a container like a namespace. + */ + if (tag == DW_TAG_namespace) + return DIE_FIND_CB_CONTINUE; + return DIE_FIND_CB_SIBLING; }