Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1332901rdb; Wed, 6 Dec 2023 16:07:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQeizS7+sErnBi4L+OHtr9eNEUiUK3sIeBnJpYH4rfaa2ybTbkA31pF23d3zjZ9O6YuTXF X-Received: by 2002:a05:6a20:2449:b0:18c:3a58:fcd3 with SMTP id t9-20020a056a20244900b0018c3a58fcd3mr2330578pzc.23.1701907621131; Wed, 06 Dec 2023 16:07:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701907621; cv=none; d=google.com; s=arc-20160816; b=OMCS70/75WwRYb76FCAL3VQkX7BhXlgvzAppjvBEjFj3k48BQk7HDhFeM+ZeFHP5Zx qDvM6elhj170jrmyRDzobM6YCC2eoKDhPBjPBLQqB6ij6cqbB5vCugEKbcJNzVps3x/M rImRG/cEp7wbYBX9iC4gpJC3lccM6/X4dQCypXHDXIZnoQY8/COf7v/P0UiULZlLCdkb DfqtjWEfLF2mK9PGei9mvWuCbDymJB9MItBIMwfxi8AY/OxrK0duoxeYHy0BGive3yZU OPL/mDMSU5IxiLJoCijRVOcF2Hd1wm/HLtIux6L6C9yFrYwaJFePBdDrl45JzemlgWyM JKDA== 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=/k2IKvmRw3JV6Mu9BGLsJLEfNzigcqLo+aqtqyuGelw=; fh=zt+aMtm74o2VDnWd+fyn50LeDgsHvuUMqskurVhx6uc=; b=h4bExKGQLvD49qz27iKWniYN4wX+X4dJqXoYX5lGkIV5UCaavAm67yaQvSqrmzyUb6 USFW+NcmGIVgzfLZbeproS0SN7Wgq56vTruGwFB5axt5pbQ6nAJ1of+ZPgJA+QL1CG5h af+HGsi8OI5dqHW1XVu0J9BvFqGfFM6FRHgZqk0QR4hSMjyPkrYwLChl3MK+/M9bGHFj 32lj4cDSW/B1TIcA7d69bzY2wnERCOE7D5wTyy89jY9jP1+utFjXXFA9jrJ/BmOFUYMn gQl3cgifSacy0SDWTXQDRxEhgIh0e5QcmtPB9aL0F+qwtvmDUUXBsEn5xocOQ5AGBtWh cClg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=z96xXkvk; 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 d3-20020a631d43000000b005c67791904bsi100244pgm.777.2023.12.06.16.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:07:01 -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=z96xXkvk; 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 5662380D6A02; Wed, 6 Dec 2023 16:06:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441850AbjLGAGV (ORCPT + 99 others); Wed, 6 Dec 2023 19:06:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbjLGAGC (ORCPT ); Wed, 6 Dec 2023 19:06:02 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6212D1989 for ; Wed, 6 Dec 2023 16:05:52 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50bf09be81bso679e87.1 for ; Wed, 06 Dec 2023 16:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701907550; x=1702512350; 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=/k2IKvmRw3JV6Mu9BGLsJLEfNzigcqLo+aqtqyuGelw=; b=z96xXkvkiWFV1Yd+AeDWXio5WKTfYnVpdhNAJ1Iv/BinHENhd0b++pcO7pdujm8jL6 6tsI9Qha3B1iUPzyXG8hrTv41H6X0zU/j0i9lH2UmEcp6rhUMHZhJhlXc5O4nVPyn3YM NKtX9Wj+xBgXeddjZDyfGTGp09jKlj5FsndtgiBwjvKwCEJ+epSTOdav6ggfCpsc6SWg wPXQ8jzc3mJkPJsW41kfaseM6grKK4bIdnSjRnrmPG4a9xSnmA1LYvJIP264q3Vqsbvt C9d0gZ/cm6TztaS1G+0CwXdyIYMkWGKGAOyx8nWLH7CT80ygJo8LgMokcmSdftGcEpsl /T5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701907550; x=1702512350; 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=/k2IKvmRw3JV6Mu9BGLsJLEfNzigcqLo+aqtqyuGelw=; b=N98zxQYPu9cEPlISQBQp24NSr/FMEcdmQ+FxFo/x7kkZXV3rNH3xjT2ObrJKEeKN/O WKnV5/O6kvnQbdeHNr9Fp7HBfgE/Y7VgjSk71pcIThDeppLVB514DJAPzKuaW0C0K+o1 CWMoEbF7QE9HTqzu+/WR9zcdxTUZYBJ8feTJtAMxLMXmeHQ4FkwK9u98algTQSHi4n+u jvHb0GPXAxFjHISVqJNZW685czJ2CkT0ZLHEI85q3k6jnc6Lo5kDS2yYipXk+aITvsm/ HGNrpmioGiobLp7NJcuJD58jxGVrH91n7fk2MkUPVvevttOB7PITnT2emSqMIu/EdKJB BVLA== X-Gm-Message-State: AOJu0YyubyXe4az2MNBB5yBhcwzm2jutdcLzrx4NmbmKeKxvzrwv6RZV fk9wuoJC6SpAXHC6KxUHMsWvcrP/Vk9f9I1C9Xk+Cg== X-Received: by 2002:a05:6512:2314:b0:50c:e19:b658 with SMTP id o20-20020a056512231400b0050c0e19b658mr87546lfu.1.1701907550214; Wed, 06 Dec 2023 16:05:50 -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: Wed, 6 Dec 2023 16:05:38 -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 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]); Wed, 06 Dec 2023 16:06:38 -0800 (PST) On Sat, Dec 2, 2023 at 3:55=E2=80=AFPM Namhyung Kim w= rote: > > On Thu, Nov 30, 2023 at 10:28=E2=80=AFAM Ian Rogers = wrote: > > > > 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 wrote: > > > > > > > > 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. > > Can it be like this? > > #ifdef RWS_ERRORCHECK > #define RWSEM_INITIALIZER { .lock =3D PTHREAD_MUTEX_INITIALIZER, } > #else > #define RWSEM_INITIALIZER { .lock =3D PTHREAD_RWLOCK_INITIALIZER, } > #endif > > > > > > > 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_RW= LOCK_INITIALIZER,}; > > > > +static struct mutex comm_str_lock =3D {.lock =3D PTHREAD_ERRORCHEC= K_MUTEX_INITIALIZER_NP,}; > > > > > > IIUC it has a problem with musl libc. Actually I think it's better t= o > > > 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. > > I don't know but there might be a reason to use global locks. > Then we need to support the initialization and it'd be better > to make it easier to handle internal changes like this. Right. So you are suggesting I make a macro for initialization but when this change is applied it will remove the only user of the macro. The macro would clearly be redundant which is why I didn't do a separate fix for that before doing this change - to use a mutex as the rwsem here is only ever used as a write lock. If we're looking to improve rwsem I don't think adding unused macros is the best thing, for example, we could remove references to perf_singlethreaded which is an idea that has had its day. Thanks, Ian > Thanks, > Namhyung