Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754495AbbLJHya (ORCPT ); Thu, 10 Dec 2015 02:54:30 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:46349 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753801AbbLJHxp (ORCPT ); Thu, 10 Dec 2015 02:53:45 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Frederic Weisbecker , Andi Kleen , Stephane Eranian , Adrian Hunter Subject: [PATCH/RFC 13/16] perf top: Protect the seen list using mutex Date: Thu, 10 Dec 2015 16:53:32 +0900 Message-Id: <1449734015-9148-14-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449734015-9148-1-git-send-email-namhyung@kernel.org> References: <1449734015-9148-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1178 Lines: 38 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 --- 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 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/