2019-08-30 11:11:01 -03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __PERF_DSOS
|
|
|
|
#define __PERF_DSOS
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rbtree.h>
|
|
|
|
#include "rwsem.h"
|
|
|
|
|
|
|
|
struct dso;
|
perf dso: Move dso_id from 'struct map' to 'struct dso'
And take it into account when looking up DSOs when we have the dso_id
fields obtained from somewhere, like from PERF_RECORD_MMAP2 records.
Instances of struct map pointing to the same DSO pathname but with
anything in dso_id different are in fact different DSOs, so better have
different 'struct dso' instances to reflect that. At some point we may
want to get copies of the contents of the different objects if we want
to do correct annotation or other analysis.
With this we get 'struct map' 24 bytes leaner:
$ pahole -C map ~/bin/perf
struct map {
union {
struct rb_node rb_node __attribute__((__aligned__(8))); /* 0 24 */
struct list_head node; /* 0 16 */
} __attribute__((__aligned__(8))); /* 0 24 */
u64 start; /* 24 8 */
u64 end; /* 32 8 */
_Bool erange_warned:1; /* 40: 0 1 */
_Bool priv:1; /* 40: 1 1 */
/* XXX 6 bits hole, try to pack */
/* XXX 3 bytes hole, try to pack */
u32 prot; /* 44 4 */
u64 pgoff; /* 48 8 */
u64 reloc; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
u64 (*map_ip)(struct map *, u64); /* 64 8 */
u64 (*unmap_ip)(struct map *, u64); /* 72 8 */
struct dso * dso; /* 80 8 */
refcount_t refcnt; /* 88 4 */
u32 flags; /* 92 4 */
/* size: 96, cachelines: 2, members: 13 */
/* sum members: 92, holes: 1, sum holes: 3 */
/* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 6 bits */
/* forced alignments: 1 */
/* last cacheline: 32 bytes */
} __attribute__((__aligned__(8)));
$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-g4hxxmraplo7wfjmk384mfsb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-11-19 18:44:22 -03:00
|
|
|
struct dso_id;
|
2024-04-09 23:42:04 -07:00
|
|
|
struct kmod_path;
|
|
|
|
struct machine;
|
2019-08-30 11:11:01 -03:00
|
|
|
|
|
|
|
/*
|
2024-05-04 14:37:57 -07:00
|
|
|
* Collection of DSOs as an array for iteration speed, but sorted for O(n)
|
|
|
|
* lookup.
|
2019-08-30 11:11:01 -03:00
|
|
|
*/
|
|
|
|
struct dsos {
|
|
|
|
struct rw_semaphore lock;
|
2024-05-04 14:37:57 -07:00
|
|
|
struct dso **dsos;
|
|
|
|
unsigned int cnt;
|
|
|
|
unsigned int allocated;
|
|
|
|
bool sorted;
|
2019-08-30 11:11:01 -03:00
|
|
|
};
|
|
|
|
|
2024-04-09 23:42:03 -07:00
|
|
|
void dsos__init(struct dsos *dsos);
|
|
|
|
void dsos__exit(struct dsos *dsos);
|
|
|
|
|
2024-05-04 14:37:57 -07:00
|
|
|
int __dsos__add(struct dsos *dsos, struct dso *dso);
|
|
|
|
int dsos__add(struct dsos *dsos, struct dso *dso);
|
2024-04-09 23:42:04 -07:00
|
|
|
struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
|
2019-08-30 11:11:01 -03:00
|
|
|
|
perf dso: Move dso_id from 'struct map' to 'struct dso'
And take it into account when looking up DSOs when we have the dso_id
fields obtained from somewhere, like from PERF_RECORD_MMAP2 records.
Instances of struct map pointing to the same DSO pathname but with
anything in dso_id different are in fact different DSOs, so better have
different 'struct dso' instances to reflect that. At some point we may
want to get copies of the contents of the different objects if we want
to do correct annotation or other analysis.
With this we get 'struct map' 24 bytes leaner:
$ pahole -C map ~/bin/perf
struct map {
union {
struct rb_node rb_node __attribute__((__aligned__(8))); /* 0 24 */
struct list_head node; /* 0 16 */
} __attribute__((__aligned__(8))); /* 0 24 */
u64 start; /* 24 8 */
u64 end; /* 32 8 */
_Bool erange_warned:1; /* 40: 0 1 */
_Bool priv:1; /* 40: 1 1 */
/* XXX 6 bits hole, try to pack */
/* XXX 3 bytes hole, try to pack */
u32 prot; /* 44 4 */
u64 pgoff; /* 48 8 */
u64 reloc; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
u64 (*map_ip)(struct map *, u64); /* 64 8 */
u64 (*unmap_ip)(struct map *, u64); /* 72 8 */
struct dso * dso; /* 80 8 */
refcount_t refcnt; /* 88 4 */
u32 flags; /* 92 4 */
/* size: 96, cachelines: 2, members: 13 */
/* sum members: 92, holes: 1, sum holes: 3 */
/* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 6 bits */
/* forced alignments: 1 */
/* last cacheline: 32 bytes */
} __attribute__((__aligned__(8)));
$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-g4hxxmraplo7wfjmk384mfsb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-11-19 18:44:22 -03:00
|
|
|
struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, struct dso_id *id);
|
|
|
|
|
2024-04-09 23:42:07 -07:00
|
|
|
bool dsos__read_build_ids(struct dsos *dsos, bool with_hits);
|
2024-04-09 23:42:03 -07:00
|
|
|
|
2024-04-09 23:42:07 -07:00
|
|
|
size_t dsos__fprintf_buildid(struct dsos *dsos, FILE *fp,
|
2019-08-30 11:11:01 -03:00
|
|
|
bool (skip)(struct dso *dso, int parm), int parm);
|
2024-04-09 23:42:07 -07:00
|
|
|
size_t dsos__fprintf(struct dsos *dsos, FILE *fp);
|
2024-04-09 23:42:03 -07:00
|
|
|
|
2024-04-09 23:42:07 -07:00
|
|
|
int dsos__hit_all(struct dsos *dsos);
|
2019-08-30 11:11:01 -03:00
|
|
|
|
2024-04-09 23:42:04 -07:00
|
|
|
struct dso *dsos__findnew_module_dso(struct dsos *dsos, struct machine *machine,
|
|
|
|
struct kmod_path *m, const char *filename);
|
|
|
|
|
|
|
|
struct dso *dsos__find_kernel_dso(struct dsos *dsos);
|
|
|
|
|
2024-04-09 23:42:05 -07:00
|
|
|
int dsos__for_each_dso(struct dsos *dsos, int (*cb)(struct dso *dso, void *data), void *data);
|
|
|
|
|
2019-08-30 11:11:01 -03:00
|
|
|
#endif /* __PERF_DSOS */
|