lkml.org 
[lkml]   [2014]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] perf tools: Reference count map_groups objects
On 4/14/14, 9:52 AM, Jiri Olsa wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> We will share it among threads in the same process.
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Don Zickus <dzickus@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Stephane Eranian <eranian@google.com>
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> ---
> tools/perf/util/map.c | 7 +++++++
> tools/perf/util/map.h | 9 +++++++++
> tools/perf/util/thread.c | 2 +-
> 3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index ae4c5e1..ba5f5c0c 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -323,6 +323,7 @@ void map_groups__init(struct map_groups *mg)
> INIT_LIST_HEAD(&mg->removed_maps[i]);
> }
> mg->machine = NULL;
> + mg->refcnt = 1;
> }
>
> static void maps__delete(struct rb_root *maps)
> @@ -374,6 +375,12 @@ void map_groups__delete(struct map_groups *mg)
> free(mg);
> }
>
> +void map_groups__put(struct map_groups *mg)
> +{
> + if (--mg->refcnt == 0)
> + map_groups__delete(mg);
> +}
> +
> void map_groups__flush(struct map_groups *mg)
> {
> int type;
> diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
> index 1073e2d..d6445b2 100644
> --- a/tools/perf/util/map.h
> +++ b/tools/perf/util/map.h
> @@ -59,11 +59,20 @@ struct map_groups {
> struct rb_root maps[MAP__NR_TYPES];
> struct list_head removed_maps[MAP__NR_TYPES];
> struct machine *machine;
> + int refcnt;
> };


atomic for refcnt? This is part of a libperf; would be good to support
multithreaded users.

David


\
 
 \ /
  Last update: 2014-04-14 20:01    [W:0.136 / U:72.860 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site