From d8e40b58ad4701198bfe83b860a29153d17dc478 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Fri, 26 Aug 2022 09:42:37 -0700 Subject: perf top: Update use of pthread mutex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch to the use of mutex wrappers that provide better error checking. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: Alexandre Truong Cc: Alexey Bayduraev Cc: Andi Kleen Cc: Andres Freund Cc: Andrii Nakryiko Cc: André Almeida Cc: Athira Jajeev Cc: Christophe JAILLET Cc: Colin Ian King Cc: Dario Petrillo Cc: Darren Hart Cc: Dave Marchevsky Cc: Davidlohr Bueso Cc: Fangrui Song Cc: Hewenliang Cc: Ingo Molnar Cc: James Clark Cc: Jason Wang Cc: Jiri Olsa Cc: Kajol Jain Cc: Kim Phillips Cc: Leo Yan Cc: Mark Rutland Cc: Martin Liška Cc: Masami Hiramatsu Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Pavithra Gurushankar Cc: Peter Zijlstra Cc: Quentin Monnet Cc: Ravi Bangoria Cc: Remi Bernon Cc: Riccardo Mancini Cc: Song Liu Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Thomas Richter Cc: Tom Rix Cc: Weiguo Li Cc: Wenyu Liu Cc: William Cohen Cc: Zechuan Chen Cc: bpf@vger.kernel.org Cc: llvm@lists.linux.dev Cc: yaowenbin Link: https://lore.kernel.org/r/20220826164242.43412-14-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-top.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tools/perf/builtin-top.c') diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index b96bb9a23ac0..5af3347eedc1 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -893,10 +893,10 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) perf_mmap__consume(&md->core); if (top->qe.rotate) { - pthread_mutex_lock(&top->qe.mutex); + mutex_lock(&top->qe.mutex); top->qe.rotate = false; - pthread_cond_signal(&top->qe.cond); - pthread_mutex_unlock(&top->qe.mutex); + cond_signal(&top->qe.cond); + mutex_unlock(&top->qe.mutex); } } @@ -1100,10 +1100,10 @@ static void *process_thread(void *arg) out = rotate_queues(top); - pthread_mutex_lock(&top->qe.mutex); + mutex_lock(&top->qe.mutex); top->qe.rotate = true; - pthread_cond_wait(&top->qe.cond, &top->qe.mutex); - pthread_mutex_unlock(&top->qe.mutex); + cond_wait(&top->qe.cond, &top->qe.mutex); + mutex_unlock(&top->qe.mutex); if (ordered_events__flush(out, OE_FLUSH__TOP)) pr_err("failed to process events\n"); @@ -1217,8 +1217,8 @@ static void init_process_thread(struct perf_top *top) ordered_events__set_copy_on_queue(&top->qe.data[0], true); ordered_events__set_copy_on_queue(&top->qe.data[1], true); top->qe.in = &top->qe.data[0]; - pthread_mutex_init(&top->qe.mutex, NULL); - pthread_cond_init(&top->qe.cond, NULL); + mutex_init(&top->qe.mutex); + cond_init(&top->qe.cond); } static int __cmd_top(struct perf_top *top) @@ -1349,7 +1349,7 @@ static int __cmd_top(struct perf_top *top) out_join: pthread_join(thread, NULL); out_join_thread: - pthread_cond_signal(&top->qe.cond); + cond_signal(&top->qe.cond); pthread_join(thread_process, NULL); return ret; } -- cgit v1.2.3-59-g8ed1b