Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1769619rdf; Sun, 5 Nov 2023 13:36:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUJrYDfDhcU9t84da7lcT7Vsk+077eE3tK4yQbFF/BbyyPxkruX7R2f/JDyOK/qifVnWoN X-Received: by 2002:a05:6a20:748b:b0:17a:de5d:1d7e with SMTP id p11-20020a056a20748b00b0017ade5d1d7emr33918437pzd.55.1699220175805; Sun, 05 Nov 2023 13:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699220175; cv=none; d=google.com; s=arc-20160816; b=YueIrIfDcPWu+jtWj4vMc5fFxJqoiiyC+b/j8FdEsqkyiJszoJXrBoWVdWsSng1kCG fLlYQI8lKozMl6VLn5bBRXiNsAADMyZBiTA6/p+eq6r84L8W5cElSjmvCgFXw4Nef/de 4yl4dyx4GhqtEzVFgQd8r62gckRmhB+jbkRwgUyvrioW4ytP+V3AiLDRFlr9FWq2R5Wa o86dL4l1aNf32J03OUi1zfQkwNPbqvz8TwOUF1akJshFHoFaf7kUgTI+0IQUrl0pMBLs Fepzuzi6sF/+tyaaMEKl4xsJS3qUGZbjAG/Gmxlk7KWukl20uwyIuFDNa3u2T/Dz9nR1 4XdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BGeltO/gzLsqyEX0SrHGG26aXCsJybxah3Ci9XWI5Ng=; fh=ZP5rkIgi+sgQyvA0Nb5diyJQn/QILptIgBv8r67XkSs=; b=hbhobVmeDPIj5wlVz1FisVWGOQDaxTyz+Sgt2mcrEEzTikOfQ5dijSWuSzgY0glBZ1 I2fb45F+HYb8E7E+3Cb4DFDjHt2J3kO0Vc1M+cAuil0S6aq8WNFSzZnCpvlVYCEkJ6Gg oGolONdjyPGKBaFsujppudjyp7nwpGa8zzWg/ljbI6jXeOVueS1pFE+mrGxzpbLsi45t eTxl8/yC8/TA1Z8wyZETImGG1Dy6Zw85r/YgZ9tp7X4Uh7aVQuAXAhhmmBUxfSCBhWGE Z2tjDPLpW09SHCFP1j2ktrhBUq1vIjciI2R6FMaYZ6A5C8W2XuxzCJD8ohKR5p1b/k/C Jtvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HavltlP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b7-20020a056a000a8700b006933caa6f03si6783437pfl.165.2023.11.05.13.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 13:36:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HavltlP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5715B80965A2; Sun, 5 Nov 2023 13:36:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbjKEVgA (ORCPT + 99 others); Sun, 5 Nov 2023 16:36:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjKEVf6 (ORCPT ); Sun, 5 Nov 2023 16:35:58 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD55FCF for ; Sun, 5 Nov 2023 13:35:55 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-53eeb28e8e5so6067a12.1 for ; Sun, 05 Nov 2023 13:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699220154; x=1699824954; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BGeltO/gzLsqyEX0SrHGG26aXCsJybxah3Ci9XWI5Ng=; b=HavltlP+54SpgEywcwPZwidLHCpxRUk159YMAvMYoD44B33KDht8aIUFXdIjPL8eLx r4ivEPxvi7HrR42Oe1bUcYV9Jz9k36mzJI4kgRHsfG/tg52WA2ZYPNTPOlo/b1Vvs3qT e//lc88xj2n/bWHYtHha3hdUm9nTq0reYgbzAIC67wzXL5gD2DjR0XnfhIJ/2Pva4ByT qox8msuG+2wCk9EGi81tjCN61auCW3mmUhf19nMUfkLq6pbpsK1Sgzw9Lpjl1urfs97u RGjvqRIAtlMLKK1CH2c8zrBEWqKlygaeKyLqMnYPQ3yRpY6gKAOsPsGlFU9aDK4D3gcY fISg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699220154; x=1699824954; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BGeltO/gzLsqyEX0SrHGG26aXCsJybxah3Ci9XWI5Ng=; b=Gt6+3GlWvx2Reqo+0ilumaAnt/Nt5BoziAd+2dJvLa3AvuQsqWyUWg+43f8X3Bgnc5 gV7UwMVT9elpnN5INiZMZ3R3i1G04SoCSOVjyrdy1NAjBXE9WFOe8tfBBcC8kI7b9sj3 Rmt2NqT4QL5N1qIpgZNiH3dvzyHyptlfC9DCYbRSlsWgrc5bVq9EBqF5ijTN7Bm9CVZu uWEBOJtam/EAOZaohgcIaM5ildrfEnPl3T2V/IKS2nW6zPxS9oFityNh69w5WgWXWk+d yzqNINGV6LbxH2LgjKH4HOYRQqQOxA3yKkfPxG+8DaN3vus/aMUUCd1Jbg+7d0C6onMN rmFg== X-Gm-Message-State: AOJu0YxrBsTq+nUKq2KLj700kYqZpd6wlZApARzsH+VgsrtxNft0Z3B9 P/oA0lLZdKaWRXlHOJ5fb7NiPF5fOPQLloq9xYu5hA== X-Received: by 2002:a50:ccd5:0:b0:543:fb17:1a8 with SMTP id b21-20020a50ccd5000000b00543fb1701a8mr68243edj.3.1699220154063; Sun, 05 Nov 2023 13:35:54 -0800 (PST) MIME-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> <20231102175735.2272696-2-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Sun, 5 Nov 2023 13:35:42 -0800 Message-ID: Subject: Re: [PATCH v4 01/53] perf comm: Use regular mutex To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: quoted-printable 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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 05 Nov 2023 13:36:13 -0800 (PST) On Sun, Nov 5, 2023 at 9:32=E2=80=AFAM Namhyung Kim w= rote: > > Hi Ian, > > On Thu, Nov 2, 2023 at 10:58=E2=80=AFAM Ian Rogers w= rote: > > > > The rwsem is only after used for writing so switch to a mutex that has > > better error checking. > > Hmm.. ok. It doesn't make sense to use rwsem without readers. > > > > > Fixes: 7a8f349e9d14 ("perf rwsem: Add debug mode that uses a mutex") > > But I'm not sure this is a fix. Other than that, Thanks Namhyung, it fixes the case that you enable RWS_ERRORCHECK in rwsem.h as the rwsem static initialization is wrong for a mutex. Ian > > Signed-off-by: Ian Rogers > > Acked-by: Namhyung Kim > > Thanks, > Namhyung > > > > --- > > 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 =3D {.lock =3D PTHREAD_RWLOCK= _INITIALIZER,}; > > +static struct mutex comm_str_lock =3D {.lock =3D PTHREAD_ERRORCHECK_MU= TEX_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 =3D __comm_str__findnew(str, root); > > - up_write(&comm_str_lock); > > + mutex_unlock(&comm_str_lock); > > > > return cs; > > } > > -- > > 2.42.0.869.gea05f2083d-goog > >