Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp513803rdb; Thu, 30 Nov 2023 10:28:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk1c9at+OCuaOXgg9u4Gf/NcImO72JrF19Qjz0VMYRvpx7doWIJq+OnDA1XfQ2edVqqvom X-Received: by 2002:a17:902:d88b:b0:1cf:7666:4dd0 with SMTP id b11-20020a170902d88b00b001cf76664dd0mr22566245plz.39.1701368908975; Thu, 30 Nov 2023 10:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701368908; cv=none; d=google.com; s=arc-20160816; b=LNV2b/ZOmCymIlR1HRSMKusxOO28/Ha2h9yvgF669oHChUu4gAGBrFD7sM9hUmxZ3X FISAwFXgZmrBuIeMKi5TMo+32bDMl1WbBdgzLlWmNFvhdqg/tAVOVpWQpEqZswnByt/U jJ4OG5/z1X8oKt1f+osYqrxaLilwzg5NKjSz1netEeb6VDluWakWqHggu++j17peHIWt MIeh814cabXNnUsc8Q4dwuYBCTj3I8RkP7l7PVZnoMW82ZJKSD6mYhIGwAe1+vIsdyQg PNCNDXGo2WsiQ7jY3AIWaTHj4LFF2hag6ESF0cDeZTOb3r/o73GW9c5tTvs5QahZYs5o xAxw== 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=MQnDDplBo/xl6TSnDTzhQLPLA7PVAh8kIH3hmpt4VIo=; fh=zt+aMtm74o2VDnWd+fyn50LeDgsHvuUMqskurVhx6uc=; b=ZcGoHMdwxowtkR+4FuhNvd3wRvcCHKR+VV5J1bOROAeOZ1RdTinHl34IBXr+S/l+4k IDz8X+jRpgwMPA0Kl79eoTe92Hs8rEhKtTMokRZBxYKy8bK8oDglYREuyLnjS0WCZpWz YxlRQ1j9tIdecD5vWwsizJHA34gQokeY42yhwdtm6zSl0dEPzy4TL+ff9m5nS2prgrCu FYp+v9RU1kaOs1dmkeuab/5hHYaXn9eTP5DtmHizmpRaQgd8EA1wrPyGdb+TWEcVIeiS t0heMSFl0RE9bUoBzCzPyl0GGJ/Wco9eJty/FoB4PFNx3umB7jsE7GS2GqP60c+o3WV2 hHCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KmwuZucq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u15-20020a17090341cf00b001cf688a2854si1794897ple.371.2023.11.30.10.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 10:28:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KmwuZucq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id B83F08297C65; Thu, 30 Nov 2023 10:28:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbjK3S2F (ORCPT + 99 others); Thu, 30 Nov 2023 13:28:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjK3S2E (ORCPT ); Thu, 30 Nov 2023 13:28:04 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D4AD6C for ; Thu, 30 Nov 2023 10:28:09 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40b51e26a7aso13615e9.1 for ; Thu, 30 Nov 2023 10:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701368888; x=1701973688; 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=MQnDDplBo/xl6TSnDTzhQLPLA7PVAh8kIH3hmpt4VIo=; b=KmwuZucqW16iZcPXuZ9CKNpoJ7tTag643kqrHwLMuQbBh6GvfT/Do1AycmiQ/HMhWY DmSBNC9EVe7S4An/XcSR1HYsld1t0p2N2XvhE1y9gAy7E8AUdKwTUvuo4D5GiV+8LbIa BUgq374jE6Oaaw7JHPz7XNPIB0aLe5HbdWCXUHuFfA4o8ajeu/a2/ncL60ju06ejIdrf EScd+gKMz9YnlBSCxX4D8mDssafAjS+cYdnqSNXP7p80UvO6MkiycuX3L7Xlb+w6RVHD a/gwzIxLBh5yNO5ZDg8NcnH/dTwGiAw+rvelIgOSmtNg1BaPhxo7++GZZZNy8bNMluS3 dtlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701368888; x=1701973688; 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=MQnDDplBo/xl6TSnDTzhQLPLA7PVAh8kIH3hmpt4VIo=; b=tFah87Hqo3uxrQ2n+Qv7qlqURdxVrHxmrP8CfiB3BbC3Pjo5/6e1l7G74FzsOykyWN 1soGsLHtHkmo47ODRzM7pf08gPvx4gRbn8eVAoCLstVIY0P2N+7TnZqhZu7fpBfhhkk6 qi3XZCNzaI6tUgxCsN7t1ZYCp5gpmW6BoWk42Q6JncbCr7H611vPpnkwxa3vEXd5dfST NmH4frLEXdPLpgN/FyfNyTBAo5pQr890t6adLj5qoU+DlkBnXEJTQRO41avnGS83l3hx FD6CEE79xsv5ab+hZyI2aBdcw+6mUn2LIib8+7JZvibO7VioiotBONTeXGTXPY8vLaF+ 9vQA== X-Gm-Message-State: AOJu0Yy24p/C3W+kw6YRC58U+5vCBOaEDTWEro/cN8WLVy0ATyZG6VF9 GCdp377pS0TSoZyOQ7FzDF4qZ87gq81Hn+ygGBuxFg== X-Received: by 2002:a05:600c:a686:b0:40b:4355:a04b with SMTP id ip6-20020a05600ca68600b0040b4355a04bmr214963wmb.6.1701368888211; Thu, 30 Nov 2023 10:28:08 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-2-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Thu, 30 Nov 2023 10:27:56 -0800 Message-ID: Subject: Re: [PATCH v5 01/50] 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, Guilherme Amadio 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 30 Nov 2023 10:28:26 -0800 (PST) On Wed, Nov 29, 2023 at 4:56=E2=80=AFPM Namhyung Kim = wrote: > > On Mon, Nov 27, 2023 at 2:09=E2=80=AFPM Ian Rogers w= rote: > > > > 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") > > I think we talked about fixing this separately, no? Sorry, I'm unclear on an action to do. Currently changing the RWS_ERRORCHECK in tools/perf/util/rwsem.h will break the build without this change. > > 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 =3D {.lock =3D PTHREAD_RWLOCK= _INITIALIZER,}; > > +static struct mutex comm_str_lock =3D {.lock =3D PTHREAD_ERRORCHECK_MU= TEX_INITIALIZER_NP,}; > > IIUC it has a problem with musl libc. Actually I think it's better to > hide the field and the pthread initializer under some macro like > MUTEX_INITIALIZER or DEFINE_MUTEX() like in the kernel. Will there be enough use to justify this? I think ideally we'd not be having global locks needing global initializers as we run into problems like we see in metrics needing to mix counting and sampling. Thanks, Ian > Thanks, > Namhyung > > > > > 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.43.0.rc1.413.gea7ed67945-goog > >