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


Groups > linux.kernel > #1286982 > unrolled thread

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

Started byMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
First post2015-12-09 03:20 +0100
Last post2015-12-09 03:20 +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  08/22] perf: Make thread uses refcnt for debug Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:20 +0100

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

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-12-09 03:20 +0100
Subject[PATCH perf/core 08/22] perf: Make thread uses refcnt for debug
Message-ID<qDCwi-25G-1@gated-at.bofh.it>
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/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web