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 <namhy...@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

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

Reply via email to