To aggregate accesses to the same data type, add 'data_types' tree in DSO to maintain data types and find it by name and size. It might have different data types that happen to have the same name, so it also compares the size of the type. Even if it doesn't 100% guarantee, it reduces the possibility of mis-handling of such conflicts. And I don't think it's common to have different types with the same name. Committer notes: Very few cases on the Linux kernel, but there are some different types with the same name, unsure if there is a debug mode in libbpf dedup that warns about such cases, but there are provisions in pahole for that, see: "emit: Notice type shadowing, i.e. multiple types with the same name (enum, struct, union, etc)" https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=4f332dbfd02072e4f410db7bdcda8d6e3422974b $ pahole --compile > vmlinux.h $ rm -f a ; make a cc a.c -o a $ grep __[0-9] vmlinux.h union irte__1 { struct map_info__1; struct map_info__1 { struct map_info__1 * next; /* 0 8 */ $ drivers/iommu/amd/amd_iommu_types.h 'union irte' include/linux/dmar.h 'struct irte' include/linux/device-mapper.h: union map_info { void *ptr; }; include/linux/mtd/map.h: struct map_info { const char *name; unsigned long size; resource_size_t phys; <SNIP> kernel/events/uprobes.c: struct map_info { struct map_info *next; struct mm_struct *mm; unsigned long vaddr; }; Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: linux-toolchains@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/r/20231213001323.718046-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _PERF_ANNOTATE_DATA_H
|
|
#define _PERF_ANNOTATE_DATA_H
|
|
|
|
#include <errno.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/rbtree.h>
|
|
#include <linux/types.h>
|
|
|
|
struct map_symbol;
|
|
|
|
/**
|
|
* struct annotated_data_type - Data type to profile
|
|
* @type_name: Name of the data type
|
|
* @type_size: Size of the data type
|
|
*
|
|
* This represents a data type accessed by samples in the profile data.
|
|
*/
|
|
struct annotated_data_type {
|
|
struct rb_node node;
|
|
char *type_name;
|
|
int type_size;
|
|
};
|
|
|
|
#ifdef HAVE_DWARF_SUPPORT
|
|
|
|
/* Returns data type at the location (ip, reg, offset) */
|
|
struct annotated_data_type *find_data_type(struct map_symbol *ms, u64 ip,
|
|
int reg, int offset);
|
|
|
|
/* Release all data type information in the tree */
|
|
void annotated_data_type__tree_delete(struct rb_root *root);
|
|
|
|
#else /* HAVE_DWARF_SUPPORT */
|
|
|
|
static inline struct annotated_data_type *
|
|
find_data_type(struct map_symbol *ms __maybe_unused, u64 ip __maybe_unused,
|
|
int reg __maybe_unused, int offset __maybe_unused)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline void annotated_data_type__tree_delete(struct rb_root *root __maybe_unused)
|
|
{
|
|
}
|
|
|
|
#endif /* HAVE_DWARF_SUPPORT */
|
|
|
|
#endif /* _PERF_ANNOTATE_DATA_H */
|