linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 09/10] perf dwarf-aux: fix __die_find_scope_cb for namespaces
@ 2025-08-25 19:58 Zecheng Li
  2025-08-30  7:32 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Zecheng Li @ 2025-08-25 19:58 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Masami Hiramatsu
  Cc: Xu Liu, linux-perf-users, linux-kernel, Zecheng Li

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.

Signed-off-by: Zecheng Li <zecheng@google.com>
---
 tools/perf/util/dwarf-aux.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 56e1b5690dc4..013862ea8924 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1962,6 +1962,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;
@@ -1975,6 +1976,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;
 }
 
-- 
2.51.0.261.g7ce5a0a67e-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 09/10] perf dwarf-aux: fix __die_find_scope_cb for namespaces
  2025-08-25 19:58 [PATCH v2 09/10] perf dwarf-aux: fix __die_find_scope_cb for namespaces Zecheng Li
@ 2025-08-30  7:32 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2025-08-30  7:32 UTC (permalink / raw)
  To: Zecheng Li
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, Masami Hiramatsu, Xu Liu,
	linux-perf-users, linux-kernel

On Mon, Aug 25, 2025 at 07:58:17PM +0000, Zecheng Li wrote:
> 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.
> 
> Signed-off-by: Zecheng Li <zecheng@google.com>

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

Thanks,
Namhyung

> ---
>  tools/perf/util/dwarf-aux.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index 56e1b5690dc4..013862ea8924 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1962,6 +1962,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;
> @@ -1975,6 +1976,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;
>  }
>  
> -- 
> 2.51.0.261.g7ce5a0a67e-goog
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-30  7:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 19:58 [PATCH v2 09/10] perf dwarf-aux: fix __die_find_scope_cb for namespaces Zecheng Li
2025-08-30  7:32 ` Namhyung Kim

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).