From patchwork Thu Nov 2 17:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 161004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp533006vqu; Thu, 2 Nov 2023 10:58:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq3vkriV464PbfyiJwSq6MmQmMaqtyeOSfWlJv1xoMu/LgzZ91Wi8eKLXgMeBbZUebSgC6 X-Received: by 2002:a05:6a00:21c9:b0:68a:4103:9938 with SMTP id t9-20020a056a0021c900b0068a41039938mr18331475pfj.0.1698947911693; Thu, 02 Nov 2023 10:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698947911; cv=none; d=google.com; s=arc-20160816; b=WQqZ2m357xVfbINVgNZ8mvHx3ERAQfxKWkZgSMALUwLTB/pao1SMXaW9/O9Abll4KT 78HYmsmIIi9rsPYU/zEUgNIYSvOQugBN3X1RAkvAIbbovnUGRdjw5f2tMMzQqyZrKWXF hfV20v14ga6+7U5CxJmCyLh0gjiIrxVVAbHPO9y0LHI3NUq65LICDgQwCZ2kelEF/u5D tlpBf9hYtQcwLLali3D/bBsJRkOSsK4IbzWHOQXJ1McCto75LJbsBzrhOPZWpyWRTkLI FzjzFjeyVdrBq3YqO0i8ySuGteKu6++ndj/9pWQwXGMa8+kQyZHZiCY1lqS0xrif/yCL BMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=tLOyEqhtWIBHG2lRVm3pZ8C52Er3pwFgveZXPDrf6/W2msdBsWyPRYu1sYUB8LBhq/ jXv15I0H+4ahFgnsTr7Ylo5xtFDgYlIWEw1aiaZIuj53KYRyOx6ghDjI1/YIJJjzNB9D 4NtPZC2NV2mrpee3iOvIoEzvaO24KVMbwn+zdEyYRBwFU1LfqpsjUldTy9LxLAbTMItu tqmPy4Wo/T8uJ89tkkMZNn4iziX+vHCeI/pIpt4lFWCyaUKMrsvWoxzY3y4lKN8X1Rrj 61nMh7SP1zdlYkeca2HxeiN1Th4Khar+4wdSzm/7BiCFrlECaJGFSNEKbcnr26RDF7oz tBcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Pch6qaGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v8-20020a056a00148800b006b0cfed2c77si73360pfu.135.2023.11.02.10.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Pch6qaGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 88E8082B1C42; Thu, 2 Nov 2023 10:58:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344535AbjKBR6D (ORCPT + 35 others); Thu, 2 Nov 2023 13:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344142AbjKBR6B (ORCPT ); Thu, 2 Nov 2023 13:58:01 -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 22453197 for ; Thu, 2 Nov 2023 10:57:59 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5afa77f9a33so18040277b3.0 for ; Thu, 02 Nov 2023 10:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947878; x=1699552678; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; b=Pch6qaGemODBCqyrH5aOelNKvoPmI9l2vhAndRxNF9h1qkm4FhiwfpAYppJOSpALZt nqMPF4TT5FwMENns2m8sRAQh16j5Me8G3WsfdQedMLnwuSEXbMKs3nK0GmANkht0b7EQ s926VY26rXyGqY1CXjWTE/qxyxX67QRVAh8w6/sOuKUL8bo1e65FC4+Yl5bSA2/CVMux oA6j8Fnh3IGqAMXMxKW0xaaFJ28d1vMoXWUvQSo9/MlDiWmG6+K/zM2rwBChqd+a8opC IS4RiZgmGmVQqK2HNUYMfVq2s7sO2SjJ0rwSQBCmyN0u5BhRnHt6hzBhndBKYzNdTtqH ZaVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947878; x=1699552678; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; b=mE8etABlWEqoTIuahMFQY1KOc3xTvSiqUWyG1/u8TeQjiD3tQXQS1HgQ/0ZUmeErOZ 8vlrcSJAONV13U0HrwwbOO9uqCZPXkEJvuEDfhlu6TfIb14rOjT/BvaenPQibejhiqF9 1Tf2Rs5FBRrKufZSPLIGIDTQbOA/Zx6iXDM7NS5xiiA1V3UanxodVvYs4HjuA4JclIpp b2E+y1Kih7bCQzT/A710wGxOy7HMkVvDjTt3hcywNqZKPQasn4DlxXcIQis/i4pqz5UC ji88AvSGXXdfizJ+Nae1sgfIZPu0IJdmlFd8bI3bBBz+MdBX14CMt02xeT+kgvHccIi6 gabg== X-Gm-Message-State: AOJu0YwOzDsqA2lS1ewKLLOZDnGzTQd3C4NbUfz++PQLxYLL5LWXrtwX MJcjfrJqJN6dEAdCvzgNE+xhPIwWnWZc X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a0d:ea95:0:b0:5a7:b575:49c3 with SMTP id t143-20020a0dea95000000b005a7b57549c3mr8687ywe.4.1698947878251; Thu, 02 Nov 2023 10:57:58 -0700 (PDT) Date: Thu, 2 Nov 2023 10:56:43 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-2-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 01/53] perf comm: Use regular mutex From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nick Terrell , Kan Liang , Andi Kleen , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org 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_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 10:58:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781476005163740026 X-GMAIL-MSGID: 1781476005163740026 The rwsem is only after used for writing so switch to a mutex that has better error checking. Fixes: 7a8f349e9d14 ("perf rwsem: Add debug mode that uses a mutex") Signed-off-by: Ian Rogers Acked-by: Namhyung Kim --- tools/perf/util/comm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index afb8d4fd2644..4ae7bc2aa9a6 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c @@ -17,7 +17,7 @@ struct comm_str { /* Should perhaps be moved to struct machine */ static struct rb_root comm_str_root; -static struct rw_semaphore comm_str_lock = {.lock = PTHREAD_RWLOCK_INITIALIZER,}; +static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; static struct comm_str *comm_str__get(struct comm_str *cs) { @@ -30,9 +30,9 @@ static struct comm_str *comm_str__get(struct comm_str *cs) static void comm_str__put(struct comm_str *cs) { if (cs && refcount_dec_and_test(&cs->refcnt)) { - down_write(&comm_str_lock); + mutex_lock(&comm_str_lock); rb_erase(&cs->rb_node, &comm_str_root); - up_write(&comm_str_lock); + mutex_unlock(&comm_str_lock); zfree(&cs->str); free(cs); } @@ -98,9 +98,9 @@ static struct comm_str *comm_str__findnew(const char *str, struct rb_root *root) { struct comm_str *cs; - down_write(&comm_str_lock); + mutex_lock(&comm_str_lock); cs = __comm_str__findnew(str, root); - up_write(&comm_str_lock); + mutex_unlock(&comm_str_lock); return cs; }