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


Groups > linux.kernel > #1286982

[PATCH perf/core 08/22] perf: Make thread uses refcnt for debug

From Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Newsgroups linux.kernel
Subject [PATCH perf/core 08/22] perf: Make thread uses refcnt for debug
Date 2015-12-09 03:20 +0100
Message-ID <qDCwi-25G-1@gated-at.bofh.it> (permalink)
References <qDCwi-25G-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Make 'thread' 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 3525 objects are not reclaimed.
    "map" leaks 3285 objects
    "dso" leaks 225 objects
    "thread" leaks 8 objects
    "map_groups" leaks 7 objects
     To see all backtraces, rerun with -v option
  ----

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

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 0a9ae80..392fc32 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -53,7 +53,7 @@ struct thread *thread__new(pid_t pid, pid_t tid)
 			goto err_thread;
 
 		list_add(&comm->list, &thread->comm_list);
-		atomic_set(&thread->refcnt, 0);
+		refcnt__init(thread, refcnt, 0);
 		RB_CLEAR_NODE(&thread->rb_node);
 	}
 
@@ -81,6 +81,7 @@ void thread__delete(struct thread *thread)
 		comm__free(comm);
 	}
 	unwind__finish_access(thread);
+	refcnt__exit(thread, refcnt);
 
 	free(thread);
 }
@@ -88,13 +89,13 @@ void thread__delete(struct thread *thread)
 struct thread *thread__get(struct thread *thread)
 {
 	if (thread)
-		atomic_inc(&thread->refcnt);
+		refcnt__get(thread, refcnt);
 	return thread;
 }
 
 void thread__put(struct thread *thread)
 {
-	if (thread && atomic_dec_and_test(&thread->refcnt)) {
+	if (thread && refcnt__put(thread, refcnt)) {
 		list_del_init(&thread->node);
 		thread__delete(thread);
 	}

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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH perf/core  08/22] perf: Make thread uses refcnt for debug Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:20 +0100

csiph-web