lkml.org 
[lkml]   [2015]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH/RFC 13/16] perf top: Protect the seen list using mutex
Date
When perf didn't find a machine, it records its pid in the seen list.
With multi-thread enabled, it shoud be protected using a mutex.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-top.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a9b7461be4f0..5987986b5203 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -916,7 +916,9 @@ static void perf_event__process_sample(struct reader_arg *rarg,

if (!machine && perf_guest) {
static struct intlist *seen;
+ static pthread_mutex_t seen_lock = PTHREAD_MUTEX_INITIALIZER;

+ pthread_mutex_lock(&seen_lock);
if (!seen)
seen = intlist__new(NULL);

@@ -925,6 +927,7 @@ static void perf_event__process_sample(struct reader_arg *rarg,
sample->pid);
intlist__add(seen, sample->pid);
}
+ pthread_mutex_unlock(&seen_lock);
return;
}

--
2.6.2


\
 
 \ /
  Last update: 2015-12-10 09:41    [W:0.259 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site