Message ID | 20231102175735.2272696-2-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp533006vqu; Thu, 2 Nov 2023 10:58:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq3vkriV464PbfyiJwSq6MmQmMaqtyeOSfWlJv1xoMu/LgzZ91Wi8eKLXgMeBbZUebSgC6 X-Received: by 2002:a05:6a00:21c9:b0:68a:4103:9938 with SMTP id t9-20020a056a0021c900b0068a41039938mr18331475pfj.0.1698947911693; Thu, 02 Nov 2023 10:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698947911; cv=none; d=google.com; s=arc-20160816; b=WQqZ2m357xVfbINVgNZ8mvHx3ERAQfxKWkZgSMALUwLTB/pao1SMXaW9/O9Abll4KT 78HYmsmIIi9rsPYU/zEUgNIYSvOQugBN3X1RAkvAIbbovnUGRdjw5f2tMMzQqyZrKWXF hfV20v14ga6+7U5CxJmCyLh0gjiIrxVVAbHPO9y0LHI3NUq65LICDgQwCZ2kelEF/u5D tlpBf9hYtQcwLLali3D/bBsJRkOSsK4IbzWHOQXJ1McCto75LJbsBzrhOPZWpyWRTkLI FzjzFjeyVdrBq3YqO0i8ySuGteKu6++ndj/9pWQwXGMa8+kQyZHZiCY1lqS0xrif/yCL BMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=tLOyEqhtWIBHG2lRVm3pZ8C52Er3pwFgveZXPDrf6/W2msdBsWyPRYu1sYUB8LBhq/ jXv15I0H+4ahFgnsTr7Ylo5xtFDgYlIWEw1aiaZIuj53KYRyOx6ghDjI1/YIJJjzNB9D 4NtPZC2NV2mrpee3iOvIoEzvaO24KVMbwn+zdEyYRBwFU1LfqpsjUldTy9LxLAbTMItu tqmPy4Wo/T8uJ89tkkMZNn4iziX+vHCeI/pIpt4lFWCyaUKMrsvWoxzY3y4lKN8X1Rrj 61nMh7SP1zdlYkeca2HxeiN1Th4Khar+4wdSzm/7BiCFrlECaJGFSNEKbcnr26RDF7oz tBcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Pch6qaGe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v8-20020a056a00148800b006b0cfed2c77si73360pfu.135.2023.11.02.10.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:58:31 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20230601 header.b=Pch6qaGe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 88E8082B1C42; Thu, 2 Nov 2023 10:58:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344535AbjKBR6D (ORCPT <rfc822;heyuhang3455@gmail.com> + 35 others); Thu, 2 Nov 2023 13:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344142AbjKBR6B (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Nov 2023 13:58:01 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22453197 for <linux-kernel@vger.kernel.org>; Thu, 2 Nov 2023 10:57:59 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5afa77f9a33so18040277b3.0 for <linux-kernel@vger.kernel.org>; Thu, 02 Nov 2023 10:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947878; x=1699552678; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; b=Pch6qaGemODBCqyrH5aOelNKvoPmI9l2vhAndRxNF9h1qkm4FhiwfpAYppJOSpALZt nqMPF4TT5FwMENns2m8sRAQh16j5Me8G3WsfdQedMLnwuSEXbMKs3nK0GmANkht0b7EQ s926VY26rXyGqY1CXjWTE/qxyxX67QRVAh8w6/sOuKUL8bo1e65FC4+Yl5bSA2/CVMux oA6j8Fnh3IGqAMXMxKW0xaaFJ28d1vMoXWUvQSo9/MlDiWmG6+K/zM2rwBChqd+a8opC IS4RiZgmGmVQqK2HNUYMfVq2s7sO2SjJ0rwSQBCmyN0u5BhRnHt6hzBhndBKYzNdTtqH ZaVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947878; x=1699552678; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wm2Wlx9LDH2uZyz0Nou/I5Qg1x4UBSoUiB/FkPORelQ=; b=mE8etABlWEqoTIuahMFQY1KOc3xTvSiqUWyG1/u8TeQjiD3tQXQS1HgQ/0ZUmeErOZ 8vlrcSJAONV13U0HrwwbOO9uqCZPXkEJvuEDfhlu6TfIb14rOjT/BvaenPQibejhiqF9 1Tf2Rs5FBRrKufZSPLIGIDTQbOA/Zx6iXDM7NS5xiiA1V3UanxodVvYs4HjuA4JclIpp b2E+y1Kih7bCQzT/A710wGxOy7HMkVvDjTt3hcywNqZKPQasn4DlxXcIQis/i4pqz5UC ji88AvSGXXdfizJ+Nae1sgfIZPu0IJdmlFd8bI3bBBz+MdBX14CMt02xeT+kgvHccIi6 gabg== X-Gm-Message-State: AOJu0YwOzDsqA2lS1ewKLLOZDnGzTQd3C4NbUfz++PQLxYLL5LWXrtwX MJcjfrJqJN6dEAdCvzgNE+xhPIwWnWZc X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a0d:ea95:0:b0:5a7:b575:49c3 with SMTP id t143-20020a0dea95000000b005a7b57549c3mr8687ywe.4.1698947878251; Thu, 02 Nov 2023 10:57:58 -0700 (PDT) Date: Thu, 2 Nov 2023 10:56:43 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-2-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 01/53] perf comm: Use regular mutex From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Nick Terrell <terrelln@fb.com>, Kan Liang <kan.liang@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Kajol Jain <kjain@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Huacai Chen <chenhuacai@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com>, "Steinar H. Gunderson" <sesse@google.com>, Liam Howlett <liam.howlett@oracle.com>, Miguel Ojeda <ojeda@kernel.org>, Colin Ian King <colin.i.king@gmail.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Ming Wang <wangming01@loongson.cn>, James Clark <james.clark@arm.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Sean Christopherson <seanjc@google.com>, Leo Yan <leo.yan@linaro.org>, Ravi Bangoria <ravi.bangoria@amd.com>, German Gomez <german.gomez@arm.com>, Changbin Du <changbin.du@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, Li Dong <lidong@vivo.com>, Sandipan Das <sandipan.das@amd.com>, liuwenyu <liuwenyu7@huawei.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> 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]); Thu, 02 Nov 2023 10:58:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781476005163740026 X-GMAIL-MSGID: 1781476005163740026 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 2, 2023, 5:56 p.m. UTC
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")
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/comm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Comments
Hi Ian, On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > 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, > Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> 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 = {.lock = PTHREAD_RWLOCK_INITIALIZER,}; > +static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_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 = __comm_str__findnew(str, root); > - up_write(&comm_str_lock); > + mutex_unlock(&comm_str_lock); > > return cs; > } > -- > 2.42.0.869.gea05f2083d-goog >
On Sun, Nov 5, 2023 at 9:32 AM Namhyung Kim <namhyung@kernel.org> wrote: > > Hi Ian, > > On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > > > 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 <irogers@google.com> > > Acked-by: Namhyung Kim <namhyung@kernel.org> > > 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 = {.lock = PTHREAD_RWLOCK_INITIALIZER,}; > > +static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_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 = __comm_str__findnew(str, root); > > - up_write(&comm_str_lock); > > + mutex_unlock(&comm_str_lock); > > > > return cs; > > } > > -- > > 2.42.0.869.gea05f2083d-goog > >
On Sun, Nov 5, 2023 at 1:35 PM Ian Rogers <irogers@google.com> wrote: > > On Sun, Nov 5, 2023 at 9:32 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > Hi Ian, > > > > On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > > > > > 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. Sounds like we need a separate fix. Maybe you need to add a static initializer macro depending on the config. Thanks, Namhyung
On Sun, Nov 5, 2023 at 7:59 PM Namhyung Kim <namhyung@kernel.org> wrote: > > On Sun, Nov 5, 2023 at 1:35 PM Ian Rogers <irogers@google.com> wrote: > > > > On Sun, Nov 5, 2023 at 9:32 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > Hi Ian, > > > > > > On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > > > > > > > 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. > > Sounds like we need a separate fix. Maybe you need to > add a static initializer macro depending on the config. Agreed, but the only use would be here and switching this case to a mutex gives extra error checking such as the mutex being taken recursively. Given that, I prefer the existing change and the static initializer for rwsem can be a follow up when needed. Thanks, Ian > Thanks, > Namhyung
Em Sun, Nov 05, 2023 at 09:31:47AM -0800, Namhyung Kim escreveu: > Hi Ian, > > On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > > > 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. Well, the only reader is a findnew method, that will primarily read, but possibly write if it doesn't find it there, so converting to a regular mutex seems sensible. - Arnaldo > > Fixes: 7a8f349e9d14 ("perf rwsem: Add debug mode that uses a mutex") > > But I'm not sure this is a fix. Other than that, Yeah, agreed, will remove the fixes. > > Signed-off-by: Ian Rogers <irogers@google.com> > > Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, - Arnaldo
Em Mon, Nov 27, 2023 at 06:53:19PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Sun, Nov 05, 2023 at 09:31:47AM -0800, Namhyung Kim escreveu: > > Hi Ian, > > > > On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> wrote: > > > > > > 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. > > Well, the only reader is a findnew method, that will primarily read, > but possibly write if it doesn't find it there, so converting to a > regular mutex seems sensible. To be fixed tomorrow: 3 32.71 alpine:3.15 : FAIL gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027) util/comm.c:20:46: error: 'PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP' undeclared here (not in a function) 20 | static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-6.6.0-rc1/tools/build/Makefile.build:158: util] Error 2 4 32.17 alpine:3.16 : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219) util/comm.c:20:46: error: 'PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP' undeclared here (not in a function) 20 | static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-6.6.0-rc1/tools/build/Makefile.build:158: util] Error 2 5 25.82 alpine:3.17 : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) util/comm.c:20:46: error: 'PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP' undeclared here (not in a function) 20 | static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-6.6.0-rc1/tools/build/Makefile.build:158: util] Error 2 6 26.64 alpine:3.18 : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10) util/comm.c:20:46: error: 'PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP' undeclared here (not in a function) 20 | static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-6.6.0-rc1/tools/build/Makefile.build:158: util] Error 2 7 29.66 alpine:edge : FAIL gcc version 13.1.1 20230722 (Alpine 13.1.1_git20230722) util/comm.c:20:46: error: 'PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP' undeclared here (not in a function) 20 | static struct mutex comm_str_lock = {.lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-6.6.0-rc1/tools/build/Makefile.build:158: util] Error 2 I.e. doesn't play well with musl libc. - Arnaldo
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,}; 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; }