Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4970733rdh; Wed, 29 Nov 2023 16:56:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGb0XNKfgwQCKBWCRcXRfo5PyiyO3fcUI/B0VxYgssKuyZv1tgUTKxdAQORZ13vvMWDagsr X-Received: by 2002:a05:6a20:6a07:b0:18a:6639:e331 with SMTP id p7-20020a056a206a0700b0018a6639e331mr31381201pzk.13.1701305775238; Wed, 29 Nov 2023 16:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701305775; cv=none; d=google.com; s=arc-20160816; b=cs+dAXe3DYI2F0KTRBJbugSeui6EVltzz6qt9wegRsSOryqB4FWzIibUF7nutq8BQf y+FpWEM/UHiBcdDQY1TJ6zogus2m8GTc8Sd+h1/k5waz6JLeZs5GXHlK1ywcUZqE4Z6V 86GX/m/+YTVBa1QYx2nRGyDhR2JdHjVLQEcnwc1DutIvbUEg68oHhIfD0IMf10YxqR5W R1C/sE4XE1BL2EB/xkDjXANxxBqmgZVMtaIx3TNAeHCZJ3/kaXrV1xu2ZxPVlifUVRPb MW1X3RKzZKgU+tW92qW0rpHuxeHeyxQf88BLUOsw+wQpZ6ZcdQaeDt4zLinkt08fcg3W XMog== 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=nnkJvaRQH5+lv/g4UiNRD6rwEImKXGYwgr9wcJPMkjM=; fh=aWa9tyepd0GWyBFjkZa5ys7uNwpZ1AjfSj0Mu1iuQbE=; b=JCgUACTc/TvDF2DU3PO9yPAvGXJY1id32Zy+CgnbyMBnpTiF843L8PeuBYvoGqXe+Q TlX9BGIE6/dcBqwOs21N/KfsZmH76FtB9Z7Fs7K0qEkLPAj6VA2IeY6ExIGdEx38DyrW 7bwqfhsRuINaNBhQI8+ljAQ+qsvLlO+z577YUIhudDHDUVuNThmFxptu1xormtSl5Yhs sfhcna8Tx2ZhtvnMl1H/IparT0hLmxAD/hxz7UZ+lpVfUINEE+SXP0dWSNZIiBsMVWmJ 36Hfml3z4ryq5KlcSSHMVj0I9WoboFuFV1+B0T5TakcoeiiyT+LFQL2atyR8DB61qk4Z yjow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n1-20020a63ee41000000b005acf0458523si65842pgk.612.2023.11.29.16.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 16:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 86DD7802C6A5; Wed, 29 Nov 2023 16:56:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbjK3Az6 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Nov 2023 19:55:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbjK3Az5 (ORCPT ); Wed, 29 Nov 2023 19:55:57 -0500 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE894D66; Wed, 29 Nov 2023 16:56:03 -0800 (PST) Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5c6263fce87so86548a12.0; Wed, 29 Nov 2023 16:56:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701305763; x=1701910563; 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=cmiAKCI1fSv/7HCnkC6OaMmQ8+p+YKtjiHGASgJDn84=; b=s/EE4uc3SQcyZYfgKlUNJSNAhJMH3sZWMO6uut7RMCmJrwvkFlDDlxaMAgWzENNu4H +AnxguUCeTN48ljQLyQirjiXRYpkbHpjHBFlbBMw46JMQa2vrONajY+BRNtYKmNU6qoG oK74Fdp8FiSNKBFdiQ1DNlkGrFR/em0Yf/jQBxAxJB5pOX4QUXB/Zi6ERWlKIzcqzsUm 6+HBJz7GD9u4RzukzvfnSLC32X8sxuY30edBkLKEF6Wu55HxVRiDUZT98uUocNcadDpb QlcLQo7mWQ+j199iv7KuI0ADqnVVdmQylojc5uUz4MqW33uBpKYczDdVGtmZveFtpyc0 YWCw== X-Gm-Message-State: AOJu0YwVbnMit9cOpcE7PyBtxoO8CkfwqvTg+KpUjpXa3SMnJsJdw/Oy U2c+4WFpy6N1fWo2SDGU8W9zraThMQZqnabuyeQ= X-Received: by 2002:a17:90b:310d:b0:286:1809:1517 with SMTP id gc13-20020a17090b310d00b0028618091517mr6586512pjb.7.1701305763212; Wed, 29 Nov 2023 16:56:03 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-2-irogers@google.com> In-Reply-To: <20231127220902.1315692-2-irogers@google.com> From: Namhyung Kim Date: Wed, 29 Nov 2023 16:55:52 -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.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 16:56:08 -0800 (PST) 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? > 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. 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 = __comm_str__findnew(str, root); > - up_write(&comm_str_lock); > + mutex_unlock(&comm_str_lock); > > return cs; > } > -- > 2.43.0.rc1.413.gea7ed67945-goog >