perf annotate: Initialize the priv are in symbol__new()
We need to initializa some fields (right now just a mutex) when we allocate the per symbol annotation struct, so do it at the symbol constructor instead of (ab)using the filter mechanism for that. This way we remove one of the few cases we have for that symbol filter, which will eventually led to removing it. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-cvz34avlz1lez888lob95390@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
ffe67c2fab
commit
b01141f4f5
|
@ -204,8 +204,6 @@ static int __cmd_annotate(struct perf_annotate *ann)
|
||||||
struct perf_evsel *pos;
|
struct perf_evsel *pos;
|
||||||
u64 total_nr_samples;
|
u64 total_nr_samples;
|
||||||
|
|
||||||
machines__set_symbol_filter(&session->machines, symbol__annotate_init);
|
|
||||||
|
|
||||||
if (ann->cpu_list) {
|
if (ann->cpu_list) {
|
||||||
ret = perf_session__cpu_bitmap(session, ann->cpu_list,
|
ret = perf_session__cpu_bitmap(session, ann->cpu_list,
|
||||||
ann->cpu_bitmap);
|
ann->cpu_bitmap);
|
||||||
|
@ -367,7 +365,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
if (annotate.session == NULL)
|
if (annotate.session == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
symbol_conf.priv_size = sizeof(struct annotation);
|
ret = symbol__annotation_init();
|
||||||
|
if (ret < 0)
|
||||||
|
goto out_delete;
|
||||||
|
|
||||||
symbol_conf.try_vmlinux_path = true;
|
symbol_conf.try_vmlinux_path = true;
|
||||||
|
|
||||||
ret = symbol__init(&annotate.session->header.env);
|
ret = symbol__init(&annotate.session->header.env);
|
||||||
|
|
|
@ -984,9 +984,9 @@ repeat:
|
||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
if (ui__has_annotation()) {
|
if (ui__has_annotation()) {
|
||||||
symbol_conf.priv_size = sizeof(struct annotation);
|
ret = symbol__annotation_init();
|
||||||
machines__set_symbol_filter(&session->machines,
|
if (ret < 0)
|
||||||
symbol__annotate_init);
|
goto error;
|
||||||
/*
|
/*
|
||||||
* For searching by name on the "Browse map details".
|
* For searching by name on the "Browse map details".
|
||||||
* providing it only in verbose mode not to bloat too
|
* providing it only in verbose mode not to bloat too
|
||||||
|
|
|
@ -1324,7 +1324,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
|
if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
|
||||||
callchain_param.order = ORDER_CALLER;
|
callchain_param.order = ORDER_CALLER;
|
||||||
|
|
||||||
symbol_conf.priv_size = sizeof(struct annotation);
|
status = symbol__annotation_init();
|
||||||
|
if (status < 0)
|
||||||
|
goto out_delete_evlist;
|
||||||
|
|
||||||
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
|
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
|
||||||
if (symbol__init(NULL) < 0)
|
if (symbol__init(NULL) < 0)
|
||||||
|
|
|
@ -491,13 +491,6 @@ static struct ins *ins__find(const char *name)
|
||||||
return bsearch(name, instructions, nmemb, sizeof(struct ins), ins__key_cmp);
|
return bsearch(name, instructions, nmemb, sizeof(struct ins), ins__key_cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int symbol__annotate_init(struct map *map __maybe_unused, struct symbol *sym)
|
|
||||||
{
|
|
||||||
struct annotation *notes = symbol__annotation(sym);
|
|
||||||
pthread_mutex_init(¬es->lock, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int symbol__alloc_hist(struct symbol *sym)
|
int symbol__alloc_hist(struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct annotation *notes = symbol__annotation(sym);
|
struct annotation *notes = symbol__annotation(sym);
|
||||||
|
|
|
@ -177,7 +177,6 @@ enum symbol_disassemble_errno {
|
||||||
int symbol__strerror_disassemble(struct symbol *sym, struct map *map,
|
int symbol__strerror_disassemble(struct symbol *sym, struct map *map,
|
||||||
int errnum, char *buf, size_t buflen);
|
int errnum, char *buf, size_t buflen);
|
||||||
|
|
||||||
int symbol__annotate_init(struct map *map, struct symbol *sym);
|
|
||||||
int symbol__annotate_printf(struct symbol *sym, struct map *map,
|
int symbol__annotate_printf(struct symbol *sym, struct map *map,
|
||||||
struct perf_evsel *evsel, bool full_paths,
|
struct perf_evsel *evsel, bool full_paths,
|
||||||
int min_pcnt, int max_lines, int context);
|
int min_pcnt, int max_lines, int context);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include "annotate.h"
|
||||||
#include "build-id.h"
|
#include "build-id.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -235,8 +236,13 @@ struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name)
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (symbol_conf.priv_size)
|
if (symbol_conf.priv_size) {
|
||||||
|
if (symbol_conf.init_annotation) {
|
||||||
|
struct annotation *notes = (void *)sym;
|
||||||
|
pthread_mutex_init(¬es->lock, NULL);
|
||||||
|
}
|
||||||
sym = ((void *)sym) + symbol_conf.priv_size;
|
sym = ((void *)sym) + symbol_conf.priv_size;
|
||||||
|
}
|
||||||
|
|
||||||
sym->start = start;
|
sym->start = start;
|
||||||
sym->end = len ? start + len : start;
|
sym->end = len ? start + len : start;
|
||||||
|
@ -1948,6 +1954,23 @@ static bool symbol__read_kptr_restrict(void)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int symbol__annotation_init(void)
|
||||||
|
{
|
||||||
|
if (symbol_conf.initialized) {
|
||||||
|
pr_err("Annotation needs to be init before symbol__init()\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symbol_conf.init_annotation) {
|
||||||
|
pr_warning("Annotation being initialized multiple times\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
symbol_conf.priv_size += sizeof(struct annotation);
|
||||||
|
symbol_conf.init_annotation = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int symbol__init(struct perf_env *env)
|
int symbol__init(struct perf_env *env)
|
||||||
{
|
{
|
||||||
const char *symfs;
|
const char *symfs;
|
||||||
|
|
|
@ -88,6 +88,7 @@ struct symbol_conf {
|
||||||
unsigned short priv_size;
|
unsigned short priv_size;
|
||||||
unsigned short nr_events;
|
unsigned short nr_events;
|
||||||
bool try_vmlinux_path,
|
bool try_vmlinux_path,
|
||||||
|
init_annotation,
|
||||||
force,
|
force,
|
||||||
ignore_vmlinux,
|
ignore_vmlinux,
|
||||||
ignore_vmlinux_buildid,
|
ignore_vmlinux_buildid,
|
||||||
|
@ -277,6 +278,8 @@ struct perf_env;
|
||||||
int symbol__init(struct perf_env *env);
|
int symbol__init(struct perf_env *env);
|
||||||
void symbol__exit(void);
|
void symbol__exit(void);
|
||||||
void symbol__elf_init(void);
|
void symbol__elf_init(void);
|
||||||
|
int symbol__annotation_init(void);
|
||||||
|
|
||||||
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
|
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
|
||||||
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
||||||
const struct addr_location *al,
|
const struct addr_location *al,
|
||||||
|
|
Loading…
Reference in a new issue