Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp778558rwe; Wed, 24 Aug 2022 08:51:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4VCnem8m9vu+mV69UH5N6UOxOUHGaMW6/nrN8TrBCz4cZVYUS+3/fnQHhwUPyRdXgbQvhL X-Received: by 2002:a05:6402:51cf:b0:447:2c7d:4dc3 with SMTP id r15-20020a05640251cf00b004472c7d4dc3mr6047631edd.369.1661356269504; Wed, 24 Aug 2022 08:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661356269; cv=none; d=google.com; s=arc-20160816; b=EJjUwubcGNli8VNdmYe3YRdcwLslavSd88HlhtzE+CDp7Ew42i1pE53MDj+oHagGI/ wLxCjFJxSMvus/1KcOLGgYJajv5It1AmzUiyaoGAgP7MZ2+pRby+cA9BHXNceKkjQE2h GiISxRCApxAHDZBWnlXp63tuAXrpfOu7sZ+FgOp/CsyFTTISkVppxxdF5l1QbFo6Kj88 ZzrlwnyHTFYz+MgbsE/EKPEdlE5PsKNNf9JhWaNeQ0d6qEKkFbfSy7vKQD6Zv1SAGorq qPEq7gBZLKxVsMg7pFTpGBcNYIwzupg+F+/H4sgQVy0ymcujZDGqtNlCgoBtpc4rjWQH PdSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=pZo3ybA6ZsEryuXOn4d62Wz0dp/bgVjWOiLvTRxWsEY=; b=jRsctD3F+f6RHgK9L/QxkVLcigWjZ9Wd6dDooLopp+Side4SEgBmcw6A+sHG+S1SSe SnXgu3scDRbXUH330Pkrk9O7ZnISuSnb0xUOQ1XaPfMMUkxC75XdOkW/7SzBJFO0Xs8T 49cjOaGz1V0g76fr8WB4KS2+WWSBFfB1Qrfm/0TffIagRPvkIkdorAdpDuuAHAaLY+Tw jXwi05DWRkWHH+RuuPVxKDdHh3nnCoWpVkijhZaXgK8fhH0jH81NOz3VfFot0wgVy/c3 +ZZphq/PJPy5ehs8ImhqdzrkqmA/OcTlnOly0reZPs7Wz6KcIEvWOg6mF+ljrJlwGRFJ GWcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=p4FyE0yx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a056402268f00b004464fef9fc8si4309773edd.57.2022.08.24.08.50.43; Wed, 24 Aug 2022 08:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=p4FyE0yx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239174AbiHXPkB (ORCPT + 99 others); Wed, 24 Aug 2022 11:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239163AbiHXPjx (ORCPT ); Wed, 24 Aug 2022 11:39:53 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9D06570 for ; Wed, 24 Aug 2022 08:39:49 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-333b218f2cbso295901487b3.0 for ; Wed, 24 Aug 2022 08:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=pZo3ybA6ZsEryuXOn4d62Wz0dp/bgVjWOiLvTRxWsEY=; b=p4FyE0yxqJ0gcs0rMvffg6i8ThfPwPcAljBGiNianeiQxxwR+phlIvdN5J9vNVpW9g bd/jJ0UJhsTdeRuorHlWZSrwSTj9O6lWcGxzDYf6mzx7TK12x2uarwy3PGX7492fp9h+ T4wDQmswJnu0QgrIO6/vMkoZqNdpF6T9OW1bfyTi6zeEe7SdXKiB5g0rxnr13iWlpjx5 BOqHGJ3OO5PUprSAACnApPH4B5sQGfs4LYqziheWbgiYL/S775FuPKuYXKC/khyqZJku VySmlvYULOQGHxpsZthpWOB95hTku6eotWHWkO5psZLhXsxLLr2VsRYCrXD6Pl7T5hQI 4kOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=pZo3ybA6ZsEryuXOn4d62Wz0dp/bgVjWOiLvTRxWsEY=; b=hnjsw/uUtwDg2b5rCWTyISaSvpT+ELWRv1w+qgzLmRoudLA9TVMkIQvhwCN1WtJ6cW 23aOorDIPZdp/lZb1WMf62BFHRK273XPKxyU+KLj5VZGn9FtiuWG9nZDTE51oEOFvSkJ cBpPtPbiDPBh1OAwfHXILBC8bgTDo9G+STpBY6zr3rhSr/WbgpEuvJCT4JVQwOv/bZpP CbJ5Qvg4zVrApcZTd++n5St7bLW0Ucye0+otYLMJLADPhS/WJFXnFiBW5v2kTztsW4aY QPvzrGDdtiaQ1odYgpWJs3RkLnF/seQZsF2cX/GPrCKwRqb0e+6xIvsK6c7YmCUdBKyi kV9A== X-Gm-Message-State: ACgBeo2WeytsPFed8bH8fnFgExLoHbSu2k96UEk5S3n4FS+h4eHDlAr0 n9pMT1g8IsNx/JsOS2apACX0WI165vop X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:ab82:a348:500d:1fc4]) (user=irogers job=sendgmr) by 2002:a25:becd:0:b0:690:a05c:8103 with SMTP id k13-20020a25becd000000b00690a05c8103mr28098386ybm.381.1661355588791; Wed, 24 Aug 2022 08:39:48 -0700 (PDT) Date: Wed, 24 Aug 2022 08:38:47 -0700 In-Reply-To: <20220824153901.488576-1-irogers@google.com> Message-Id: <20220824153901.488576-5-irogers@google.com> Mime-Version: 1.0 References: <20220824153901.488576-1-irogers@google.com> X-Mailer: git-send-email 2.37.2.609.g9ff673ca1a-goog Subject: [PATCH v3 04/18] perf hist: Update use of pthread mutex From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , Nathan Chancellor , Nick Desaulniers , Tom Rix , Weiguo Li , Athira Rajeev , Thomas Richter , Ravi Bangoria , Dario Petrillo , Hewenliang , yaowenbin , Wenyu Liu , Song Liu , Andrii Nakryiko , Dave Marchevsky , Leo Yan , Kim Phillips , Pavithra Gurushankar , Alexandre Truong , Quentin Monnet , William Cohen , Andres Freund , Adrian Hunter , "=?UTF-8?q?Martin=20Li=C5=A1ka?=" , Colin Ian King , James Clark , Fangrui Song , Stephane Eranian , Kajol Jain , Alexey Bayduraev , Riccardo Mancini , Andi Kleen , Masami Hiramatsu , Zechuan Chen , Jason Wang , Christophe JAILLET , Remi Bernon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Cc: Ian Rogers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch to the use of mutex wrappers that provide better error checking. Signed-off-by: Ian Rogers --- tools/perf/builtin-top.c | 8 ++++---- tools/perf/util/hist.c | 6 +++--- tools/perf/util/hist.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index fd8fd913c533..14e60f6f219c 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -220,7 +220,7 @@ static void perf_top__record_precise_ip(struct perf_top *top, * This function is now called with he->hists->lock held. * Release it before going to sleep. */ - pthread_mutex_unlock(&he->hists->lock); + mutex_unlock(&he->hists->lock); if (err == -ERANGE && !he->ms.map->erange_warned) ui__warn_map_erange(he->ms.map, sym, ip); @@ -230,7 +230,7 @@ static void perf_top__record_precise_ip(struct perf_top *top, sleep(1); } - pthread_mutex_lock(&he->hists->lock); + mutex_lock(&he->hists->lock); } } @@ -836,12 +836,12 @@ static void perf_event__process_sample(struct perf_tool *tool, else iter.ops = &hist_iter_normal; - pthread_mutex_lock(&hists->lock); + mutex_lock(&hists->lock); if (hist_entry_iter__add(&iter, &al, top->max_stack, top) < 0) pr_err("Problem incrementing symbol period, skipping event\n"); - pthread_mutex_unlock(&hists->lock); + mutex_unlock(&hists->lock); } addr_location__put(&al); diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 1c085ab56534..698add038cec 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1622,13 +1622,13 @@ struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists) { struct rb_root_cached *root; - pthread_mutex_lock(&hists->lock); + mutex_lock(&hists->lock); root = hists->entries_in; if (++hists->entries_in > &hists->entries_in_array[1]) hists->entries_in = &hists->entries_in_array[0]; - pthread_mutex_unlock(&hists->lock); + mutex_unlock(&hists->lock); return root; } @@ -2805,7 +2805,7 @@ int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list) hists->entries_in = &hists->entries_in_array[0]; hists->entries_collapsed = RB_ROOT_CACHED; hists->entries = RB_ROOT_CACHED; - pthread_mutex_init(&hists->lock, NULL); + mutex_init(&hists->lock); hists->socket_filter = -1; hists->hpp_list = hpp_list; INIT_LIST_HEAD(&hists->hpp_formats); diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 7ed4648d2fc2..508428b2c1b2 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -4,10 +4,10 @@ #include #include -#include #include "evsel.h" #include "color.h" #include "events_stats.h" +#include "mutex.h" struct hist_entry; struct hist_entry_ops; @@ -98,7 +98,7 @@ struct hists { const struct dso *dso_filter; const char *uid_filter_str; const char *symbol_filter_str; - pthread_mutex_t lock; + struct mutex lock; struct hists_stats stats; u64 event_stream; u16 col_len[HISTC_NR_COLS]; -- 2.37.2.609.g9ff673ca1a-goog