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


Groups > linux.kernel > #1287005 > unrolled thread

[PATCH perf/core 11/22] perf: Make cgroup_sel to use refcnt for debug

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 11/22] perf: Make cgroup_sel to use refcnt for  debug Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:30 +0100

#1287005 — [PATCH perf/core 11/22] perf: Make cgroup_sel to use refcnt for debug

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-12-09 03:30 +0100
Subject[PATCH perf/core 11/22] perf: Make cgroup_sel to use refcnt for debug
Message-ID<qDCFZ-295-21@gated-at.bofh.it>
Make 'cgroup_sel' object to use refcnt interface for debug.
This can find refcnt related memory leaks.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/cgroup.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 32e12ec..d925f86 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -4,6 +4,7 @@
 #include "evsel.h"
 #include "cgroup.h"
 #include "evlist.h"
+#include "refcnt.h"
 
 int nr_cgroups;
 
@@ -103,6 +104,7 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
 			free(cgrp);
 			return -1;
 		}
+		refcnt__init_as(cgrp, refcnt, 0, "cgroup_sel");
 	}
 
 	/*
@@ -115,21 +117,24 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
 			goto found;
 		n++;
 	}
-	if (atomic_read(&cgrp->refcnt) == 0)
+	if (atomic_read(&cgrp->refcnt) == 0) {
+		refcnt__exit(cgrp, refcnt);
 		free(cgrp);
+	}
 
 	return -1;
 found:
-	atomic_inc(&cgrp->refcnt);
+	refcnt__get(cgrp, refcnt);
 	counter->cgrp = cgrp;
 	return 0;
 }
 
 void close_cgroup(struct cgroup_sel *cgrp)
 {
-	if (cgrp && atomic_dec_and_test(&cgrp->refcnt)) {
+	if (cgrp && refcnt__put(cgrp, refcnt)) {
 		close(cgrp->fd);
 		zfree(&cgrp->name);
+		refcnt__exit(cgrp, refcnt);
 		free(cgrp);
 	}
 }

--
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