Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1287004 > unrolled thread

[PATCH perf/core 07/22] perf: Make map_groups to use refcnt

Started byMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
First post2015-12-09 03:30 +0100
Last post2015-12-09 03:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH perf/core  07/22] perf: Make map_groups to use refcnt Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:30 +0100

#1287004 — [PATCH perf/core 07/22] perf: Make map_groups to use refcnt

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-12-09 03:30 +0100
Subject[PATCH perf/core 07/22] perf: Make map_groups to use refcnt
Message-ID<qDCFY-295-13@gated-at.bofh.it>
Make 'map_groups' object to use refcnt interface for debug.
This can find refcnt related memory leaks.
 E.g.
  ----
  # ./perf top --stdio
  ^q
  REFCNT: BUG: Unreclaimed objects found.
  REFCNT: Total 3615 objects are not reclaimed.
    "map" leaks 3373 objects
    "dso" leaks 232 objects
    "map_groups" leaks 10 objects
     To see all backtraces, rerun with -v option
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/map.c |    5 +++--
 tools/perf/util/map.h |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 72fcc54..7859216 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -471,7 +471,7 @@ void map_groups__init(struct map_groups *mg, struct machine *machine)
 		maps__init(&mg->maps[i]);
 	}
 	mg->machine = machine;
-	atomic_set(&mg->refcnt, 1);
+	refcnt__init_as(mg, refcnt, 1, "map_groups");
 }
 
 static void __maps__purge(struct maps *maps)
@@ -501,6 +501,7 @@ void map_groups__exit(struct map_groups *mg)
 
 	for (i = 0; i < MAP__NR_TYPES; ++i)
 		maps__exit(&mg->maps[i]);
+	refcnt__exit(mg, refcnt);
 }
 
 bool map_groups__empty(struct map_groups *mg)
@@ -533,7 +534,7 @@ void map_groups__delete(struct map_groups *mg)
 
 void map_groups__put(struct map_groups *mg)
 {
-	if (mg && atomic_dec_and_test(&mg->refcnt))
+	if (mg && refcnt__put(mg, refcnt))
 		map_groups__delete(mg);
 }
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index fcdc7d6..4667d67 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -78,7 +78,7 @@ bool map_groups__empty(struct map_groups *mg);
 static inline struct map_groups *map_groups__get(struct map_groups *mg)
 {
 	if (mg)
-		atomic_inc(&mg->refcnt);
+		refcnt__get(mg, refcnt);
 	return mg;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web