perf tools: Add refcnt into struct mem_info
It's passed along several hists entries in --hierarchy mode, so it's better we keep track of it. The current fail I see is that it gets removed in hierarchy --mem-mode mode, where it's shared in the different hierarchies, but removed from the template hist entry, so the report crashes. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180307155020.32613-6-jolsa@kernel.org [ Rename mem_info__aloc() to mem_info__new(), to fix the typo and use the convention for constructors ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
915b4e27f1
commit
9f87498f1c
@@ -2221,3 +2221,25 @@ int symbol__config_symfs(const struct option *opt __maybe_unused,
|
||||
free(bf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mem_info *mem_info__get(struct mem_info *mi)
|
||||
{
|
||||
if (mi)
|
||||
refcount_inc(&mi->refcnt);
|
||||
return mi;
|
||||
}
|
||||
|
||||
void mem_info__put(struct mem_info *mi)
|
||||
{
|
||||
if (mi && refcount_dec_and_test(&mi->refcnt))
|
||||
free(mi);
|
||||
}
|
||||
|
||||
struct mem_info *mem_info__new(void)
|
||||
{
|
||||
struct mem_info *mi = zalloc(sizeof(*mi));
|
||||
|
||||
if (mi)
|
||||
refcount_set(&mi->refcnt, 1);
|
||||
return mi;
|
||||
}
|
||||
|
Reference in New Issue
Block a user