aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2014-03-25 14:26:44 -0400
committerJiri Olsa <jolsa@kernel.org>2014-04-28 07:43:26 -0400
commita26ca6716a6c683f40bd676cea7e89704653b98d (patch)
treeaa5fdacbf7eecbd959686d2ab3d28ed1cfebba83
parent93d5731dcb5b8cb7fa56ee11a5891f10c96c2a45 (diff)
perf tools: Reference count map_groups objects
We will share it among threads in the same process. Adding map_groups__get/map_groups__put interface for that. Signed-off-by: Arnaldo Carvalho de Melo <acme@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1397490723-1992-4-git-send-email-jolsa@redhat.com Signed-off-by: Jiri Olsa <jolsa@kernel.org>
-rw-r--r--tools/perf/util/map.c7
-rw-r--r--tools/perf/util/map.h9
-rw-r--r--tools/perf/util/thread.c2
3 files changed, 17 insertions, 1 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ae4c5e12debd..ba5f5c0c838b 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)
323 INIT_LIST_HEAD(&mg->removed_maps[i]); 323 INIT_LIST_HEAD(&mg->removed_maps[i]);
324 } 324 }
325 mg->machine = NULL; 325 mg->machine = NULL;
326 mg->refcnt = 1;
326} 327}
327 328
328static void maps__delete(struct rb_root *maps) 329static void maps__delete(struct rb_root *maps)
@@ -374,6 +375,12 @@ void map_groups__delete(struct map_groups *mg)
374 free(mg); 375 free(mg);
375} 376}
376 377
378void map_groups__put(struct map_groups *mg)
379{
380 if (--mg->refcnt == 0)
381 map_groups__delete(mg);
382}
383
377void map_groups__flush(struct map_groups *mg) 384void map_groups__flush(struct map_groups *mg)
378{ 385{
379 int type; 386 int type;
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 1073e2d8b797..d6445b27d672 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -59,11 +59,20 @@ struct map_groups {
59 struct rb_root maps[MAP__NR_TYPES]; 59 struct rb_root maps[MAP__NR_TYPES];
60 struct list_head removed_maps[MAP__NR_TYPES]; 60 struct list_head removed_maps[MAP__NR_TYPES];
61 struct machine *machine; 61 struct machine *machine;
62 int refcnt;
62}; 63};
63 64
64struct map_groups *map_groups__new(void); 65struct map_groups *map_groups__new(void);
65void map_groups__delete(struct map_groups *mg); 66void map_groups__delete(struct map_groups *mg);
66 67
68static inline struct map_groups *map_groups__get(struct map_groups *mg)
69{
70 ++mg->refcnt;
71 return mg;
72}
73
74void map_groups__put(struct map_groups *mg);
75
67static inline struct kmap *map__kmap(struct map *map) 76static inline struct kmap *map__kmap(struct map *map)
68{ 77{
69 return (struct kmap *)(map + 1); 78 return (struct kmap *)(map + 1);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index dc51d1632e92..b501848a8424 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -50,7 +50,7 @@ void thread__delete(struct thread *thread)
50{ 50{
51 struct comm *comm, *tmp; 51 struct comm *comm, *tmp;
52 52
53 map_groups__delete(thread->mg); 53 map_groups__put(thread->mg);
54 thread->mg = NULL; 54 thread->mg = NULL;
55 list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { 55 list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) {
56 list_del(&comm->list); 56 list_del(&comm->list);