Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp553081rdb; Thu, 2 Nov 2023 10:58:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT59b24BD/u8kXuXA2H50FlMRl8IrjKgP91UMIDRZCgb9tYTmnRLQ1TLC8uOC2xFheyj2e X-Received: by 2002:a05:6a21:778a:b0:16b:7602:1837 with SMTP id bd10-20020a056a21778a00b0016b76021837mr20595107pzc.29.1698947907086; Thu, 02 Nov 2023 10:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698947907; cv=none; d=google.com; s=arc-20160816; b=nHeq6cxM9B4b4y47D6cA5XEruYGW2Y3L5n3hkM5USkeBj+tEOy5Csfl79MlQ9URru+ PMKYeViw4ZrhidhHj5rWLN//6IzrI/VY3vAAI1Kz9Ge0MvsE0vjWuiFQI2DNLsVP2rXj /RxPmvVTL1MyoPjhkoArc5vhZZJ8R99NxbkcUizImcwv/AGdYJLdw3eB3yMIfnu/gPr5 4AJPS3jUWv7FEE1U8Wn3di77kOPct9eyak0wLQUBXDOSu3owIh70n/luzNATCa2OQ2RG tOrVh/Zrn7r/CNThs9jcXl1Axs+23dbXZ9WEyEiuhOFdbncnE0TFLwj3QDRTVo0V0npV TLYg== 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 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id cb8-20020a056a02070800b00584b6af3b9fsi55112pgb.524.2023.11.02.10.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:58:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; 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 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 13ACC8135680; Thu, 2 Nov 2023 10:58:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345002AbjKBR6D (ORCPT + 99 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 02 Nov 2023 10:58:19 -0700 (PDT) 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 --- 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; } -- 2.42.0.869.gea05f2083d-goog