Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3427087rdh; Mon, 27 Nov 2023 14:09:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuiVlvuuPbbfaNxmHK4ZgW3Nji5bJX1hxpetBBDy2GxqIkVWsj/Tg5fYHMsBPzXDbp9PVe X-Received: by 2002:a05:6a20:5521:b0:187:9521:92a7 with SMTP id ko33-20020a056a20552100b00187952192a7mr13312565pzb.18.1701122982590; Mon, 27 Nov 2023 14:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701122982; cv=none; d=google.com; s=arc-20160816; b=oP22CZPDvjG3B7O9xI7gelKOGe44yawJRc/h2Gh3SGEWdpT0yaVfQkEckqshMzXrhT 9MWiiL3tRg8iIWhVm59LqgCt+AJcNniJ/BDlRAlu5zatkTq3l9Rrq7PocKU1c7/eEmhO IXmeri13wKpLgNIWvI5is24U6RXC/cYBzqSVDQTnpsrRxcH6AAf1cE9IGaYTHz6TVwWQ 8z2QFXtw3r9HtjbNS6IHgoCo90ngeqTedLY17acTtoM5H7IeN5cJwYUa47JYkclbgdtx OycAplgyo1fFjxGot15xRan++Ac4jgdTpqsZbAQCJI8dA8M4by+ri8Om7b+dsa9WS/Og ppOg== 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=qbPv4PyEdmBWH7WUrzt8/XaXbmHzexj4Rz5EFZB1OQM=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=PaIWvdZHfk+dKT6G2143LqwSSAy8eTTOl++wtProLQjc0I/4/j7sIvawC24RL826pp ZblWdVs3sKKZX226ErNRtUypUlACBEL3KaW6kenZPPR0kMfzJQZiLz/2J41jhx2YX9cH eBozJCOTshK6kKAUDjaFeOPUh1a9MYHKVMZYFxeiVdE8bOkSPc3a4L6BqlR3DMtm83rD 7w7P4qEc4iapXh/XzjqpHwlGvgOAn4K8RrG5EGu+WztXx9Csa1cuUAE/9PatmA5/m2rs EXWT5uiMd5BB/WONzJvgeVqLgo1qcLFLV68uvuUBC67FDcJe9DTFj3EwCJ+BGhLzPJOA G75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Km0rF0ZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id pb12-20020a17090b3c0c00b00285b9253401si4799760pjb.70.2023.11.27.14.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Km0rF0ZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BB78B80A138B; Mon, 27 Nov 2023 14:09:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233544AbjK0WJS (ORCPT + 99 others); Mon, 27 Nov 2023 17:09:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233490AbjK0WJR (ORCPT ); Mon, 27 Nov 2023 17:09:17 -0500 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 A4803EA for ; Mon, 27 Nov 2023 14:09:23 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5cdde93973aso57444107b3.1 for ; Mon, 27 Nov 2023 14:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701122963; x=1701727763; 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=qbPv4PyEdmBWH7WUrzt8/XaXbmHzexj4Rz5EFZB1OQM=; b=Km0rF0ZHW0TaTKx+npA8OJvPAtKyQKPO0A8M2mJ/DBBM41qhFvDyHLcEZxTP3w4vaS NwknOG+NnF1RF1aat0v7kfg2YfEpZn+q9ULMB4TONRjsECUCb8RdWk1SvrJjGGC2h3t7 jNmmImB82KKjBgexV9sN64hmZU85VFmA8SO5GNZnXKxbfsPcmnLVdZb79Y4U7X07Cyii R7R8wv9Pw/BsiSbhDOc/CmjIe/9diA7ZDgl/UMgusk9oDsMg4f0bEDNDf0wbhQfVLMY0 3uB5/YY3q1N5VdPdRG8gkqZV9iYZISz2aC1K7m9MJ0dNfvGx3N/4CqwWyc3ocgAzmdG/ pACA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701122963; x=1701727763; 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=qbPv4PyEdmBWH7WUrzt8/XaXbmHzexj4Rz5EFZB1OQM=; b=mKkISyRUplI6hENVjh9oDr3NTZkMhn6KSfQqUtu716Stu6qGcBDqTHptAQ+6LxYFyj MkIO0NPIYU7jTpEfsgwC1fOxZRSri2obp2i0ee8PkORKe2X866tsRTy7x5Op6TORZP1z mYTPwfE6E5rlzRzEvsV4KGyuHwxuEx/0KvDNSebyk3PLgxwWB7OUAW2xcUXef3R/yV7y YPsj7RrdT/ySlUzfpNvsgCP+hrXGS66qOOVhqghk1YpP/NyA8BPZpCkQmuIGhah6G/ua ug2UEhBl50Krh9ewTL33N2YIRuwCCDZR3GWxy0UYnnS3sUegCAnau2QAi0oBK19Oyai/ Dvuw== X-Gm-Message-State: AOJu0Ywn9kk4G8iqDGL4Kwz7QDQTlE1/QsrThJ/PYy7kYYW6fJCe2yUn BHwX8PFPot5kifgIBP2NzA00/XpbMXLG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:829:6e77:9093:f39b]) (user=irogers job=sendgmr) by 2002:a25:d081:0:b0:d9a:c946:c18c with SMTP id h123-20020a25d081000000b00d9ac946c18cmr452645ybg.6.1701122962825; Mon, 27 Nov 2023 14:09:22 -0800 (PST) Date: Mon, 27 Nov 2023 14:08:13 -0800 In-Reply-To: <20231127220902.1315692-1-irogers@google.com> Message-Id: <20231127220902.1315692-2-irogers@google.com> Mime-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v5 01/50] 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, Guilherme Amadio 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:09:39 -0800 (PST) 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.43.0.rc1.413.gea7ed67945-goog