Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1928693rdb; Sat, 2 Dec 2023 15:55:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwHdzwz6RTrc1Fw4NMsHa+gGxLR+4W0tStxb10cKxWqDKVocrpR+NEBYbVNw1Fp7u5CMq5 X-Received: by 2002:a05:6870:a68f:b0:1fa:fe81:2fd with SMTP id i15-20020a056870a68f00b001fafe8102fdmr2389252oam.33.1701561347670; Sat, 02 Dec 2023 15:55:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701561347; cv=none; d=google.com; s=arc-20160816; b=BKpmJhoVET+kPCiA7WNMVglNBkXDbojUhUhuiDm6f8wZzYnALWwlPdhrbZpghK+mLY v6xEwqQd9/aDaExOHT3ZWMzte1YxdQPiCnCCgJ+QUqQWuhtH17ObwTMfvGCYikqXdRsH 1fog/9PcfasbMUfwF76Z0bZ5j1h8BLsJit7g8NFz+YWYLKu2exL0e+ZOHrCmfQJedX9p QYIetXe+hP4xm8nqehp6iWPFn5ykfjVxHR9vldd49qkMpK/Gjijy0XX0CuBbfffIBxNa 54s5WofXj4yj310DNrosi4mIV3B4qEC4rGOVLl8vRLorz47W+sTdmjF4zeW9dI8JPqRP WRhA== 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; bh=V8nuM2xBQ/j+VdbK+xUzEOtgFOaFhKaktvQ6MJfE5no=; fh=aWa9tyepd0GWyBFjkZa5ys7uNwpZ1AjfSj0Mu1iuQbE=; b=Oq7uO6U+Iu6E/HUEgt3RL9boyjdk96J0dVwlFidVbEEbKMFFKMeXzVPFtz7zCjT8CJ HlKcj9emirwoomvLJr0WC51bz0NIUSb5Be8aSlhLt4UBY/8djJe4KyUYAM10lz3S7PZ9 n4jYaxmVNBeXjaA4lgrkjmGYDPamFE7hntPjHG2LesN7ALTqKIN2jYAr1ZE3GY/bLa9L qYFO8xmhQ3MMg/shxaIF6wpSHJMz94c7YeUbLSxffkZD1zHo74DVSYTQAwJL5RYmzvxu P4xf7mKFaw+U+Sl9KQ29yOCvoSVmXkZQEEe9TzO58vLX/maiHUPJgGDkninP8YmX2mYR RvWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h20-20020a63f914000000b005b90af1943asi5443626pgi.807.2023.12.02.15.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 15:55:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5A6498082916; Sat, 2 Dec 2023 15:55:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232600AbjLBXzG convert rfc822-to-8bit (ORCPT + 99 others); Sat, 2 Dec 2023 18:55:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLBXzE (ORCPT ); Sat, 2 Dec 2023 18:55:04 -0500 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6343BC8; Sat, 2 Dec 2023 15:55:11 -0800 (PST) Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-58d956c8c38so2217451eaf.2; Sat, 02 Dec 2023 15:55:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701561310; x=1702166110; 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=yvPGCQtpM8COGZWcKiIG7o+AKmKAg3mE1nqD/jJyBKM=; b=TeTEtjpggNXJQqNW60aYkthEfkil+xaZ3ZXzEUBz2QoX1cBOCa7w4hnq9YSnDxzPcP Nf0UDjWX8QqHvD4GmwmuPAGNvGYjNwCmWIx4rXB9av2z+/4bKvA0A6fVj6A7jieHPP3O Ky2IU219HNQUdPMoRkeTgXXj98iAPTM0fit7swU92qzM25+nYCG0GW6htDR73EB7F5sv ejKK6IjZ/EJY/x06n1cBIuKPfSfrpR5Z/CPLiylqCVPDAtT9fWdmqmm6Gc9QkbbwH+Zv oGd6UmwPzLMC4KnzaWev6e9m8jQahqAlK9V0Fcgou2OewkWfrjjMboeA/9BMNSkW6Q0j QezA== X-Gm-Message-State: AOJu0Yzia/HL/Wl6PWuktYg6UD6bIymJTTSTrqTkv3Vw4PRBA6sQPgf8 /tLBjQeGahSWrM7BegnouIyHc9IeM9tYYWr87LA= X-Received: by 2002:a05:6358:7e98:b0:16e:283:665d with SMTP id o24-20020a0563587e9800b0016e0283665dmr2591404rwn.15.1701561310428; Sat, 02 Dec 2023 15:55:10 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-2-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Sat, 2 Dec 2023 15:54:59 -0800 Message-ID: Subject: Re: [PATCH v5 01/50] perf comm: Use regular mutex To: Ian Rogers 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: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sat, 02 Dec 2023 15:55:20 -0800 (PST) On Thu, Nov 30, 2023 at 10:28 AM Ian Rogers wrote: > > On Wed, Nov 29, 2023 at 4:56 PM Namhyung Kim wrote: > > > > On Mon, Nov 27, 2023 at 2:09 PM 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 = PTHREAD_MUTEX_INITIALIZER, } #else #define RWSEM_INITIALIZER { .lock = 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 = {.lock = PTHREAD_RWLOCK_INITIALIZER,}; > > > +static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_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. 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. Thanks, Namhyung