Re: [PATCHSET 0/9] perf annotate-data: Update data-type profiling quality (v1)
From: Arnaldo Carvalho de Melo
Date: Mon Aug 19 2024 - 15:35:17 EST
On Fri, Aug 16, 2024 at 04:58:30PM -0700, Namhyung Kim wrote:
> Hello,
>
> I've found a couple of bugs in the DWARF location handling and had
> some updates to improve the quality of the type resolution.
>
> The current code only checks the first variable it found in the
> closest scope but sometimes it's not good because macro expansions
> like container_of (which is used by many list/rb tree manipulation
> routines) only gives a very limited information (like void *) with
> type cast. So it needs to lookup other variables in the upper scope.
> See the patch 8 for more details.
>
> Also sometimes it can have more information for the parent type if the
> pointer is for an embedded type. For example, a list_head is
> typically a part of bigger struct. Even if it found a variable for
> the list_head, it'd be nice if it can tell which list it is.
>
> To compare two type information in general, I've added a heuristic to
> take a pointer to a bigger data type.
>
> This is an example data, the portion of unknown type went down a bit
> and the atomic_t turned out to be _mapcount in the struct page.
>
> Before:
> #
> # Overhead Data Type
> # ........ .........
> #
> 37.24% (unknown)
> 14.40% atomic_t
> 8.81% (stack operation)
> 5.54% struct psi_group_cpu
> 3.40% struct task_struct
> 2.99% struct pcpu_hot
> 2.99% struct cfs_rq
> 2.18% struct audit_krule
> 1.93% struct psi_group
> 1.62% struct sched_entity
>
> After:
> #
> # Overhead Data Type
> # ........ .........
> #
> 36.87% (unknown)
> 14.40% struct page
> 8.81% (stack operation)
> 6.00% struct psi_group_cpu
> 3.40% struct task_struct
> 3.36% struct cfs_rq
> 2.99% struct pcpu_hot
> 2.18% struct audit_krule
> 1.93% struct psi_group
> 1.62% struct sched_entity
>
> Also updated the debug message and the statistics to help debugging.
>
> The code is available at 'perf/data-profile-update-v1' branch in
> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
Thanks, applied to perf-tools-next,
- Arnaldo