Messages in this thread Patch in this message | | | From | Namhyung Kim <> | Subject | [PATCH/RFC 13/16] perf top: Protect the seen list using mutex | Date | Thu, 10 Dec 2015 16:53:32 +0900 |
| |
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
| |