Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1684685rdf; Sun, 5 Nov 2023 09:32:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkZhvehBfHA40xNh784KMDIKFPcLv3AXrOKLjrvd62gEBMMv7FZt2tPzr7eyeOXB0jNIZd X-Received: by 2002:a17:90b:1c01:b0:280:280c:efe3 with SMTP id oc1-20020a17090b1c0100b00280280cefe3mr11298387pjb.14.1699205538453; Sun, 05 Nov 2023 09:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699205538; cv=none; d=google.com; s=arc-20160816; b=Z1HcCH1E0B0uQUPYyu8NbdaVS+CG1K7Zh9H/OOutJSfQPjALtfSmxc9ugmJQzsZzBV Z7kq8GTsNQ1h1JTNWaw4av1tftRJEH5EJ/444034MZW31QBH3Go8h5+y6ZwZOVBMN0mx I6SE2H5KXGEV7aNvQGcNlO7YRcqOiG/DWjchfnW0iUKS211cetzBlJrqcvG+OCZTFi/K i5tMlhn8+SlK+JzPvNYyv9Xe2CZdxhyayYHTWwW4aCsKpJXy4lSuM3RvRjCXxKhEJPfq iXO7YwMf2GEbeWUreVRCAgqnaa9AlJLaktgj3GJtyLO97gpi/P0Rz/tfZJbcjv2MtiLd c/nQ== 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=A0LWfQqRJC+cOlou59C4tC3ex2Yj/0sENabTOhwH/9w=; fh=mapERlogJ/cQt0xtLiOgnrZ5zpp0wMkpfbiUTcLZi4s=; b=AAGjBssTO5e0qAkFAOsyEjxBPp8WTfABJROJGTlVFFOUVNTOKWYbk2C4pMnlIMYJst ossMYDFh2+wVdmFQZeB9ppwPJhct+SFPu8xm7by+3AjT0pNN7Zv3BpwCOmITZMfWhTk/ t9ibfrmY8uREJfuV88AGWW+jagSb3TlDffv0ROApc1RBKyYna7lD2sse4L58mujbZ6/E idWQxlmQwKQqzCvo+bRj82qATAANpkn/5WO05y7U6TqLQS/ap55vHa2aVcELb6+rCYhB yUT48TKlcA7PvyVcuta4gcQMWz/XH491iKcQS2vEARxlaTEp7UnmoaCc2gFj2wAuQl68 UbyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fy1-20020a17090b020100b0027cead6f6b4si2699124pjb.1.2023.11.05.09.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 09:32:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id CC4838067E03; Sun, 5 Nov 2023 09:32:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbjKERcD convert rfc822-to-8bit (ORCPT + 99 others); Sun, 5 Nov 2023 12:32:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbjKERcB (ORCPT ); Sun, 5 Nov 2023 12:32:01 -0500 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D558C5; Sun, 5 Nov 2023 09:31:59 -0800 (PST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1cc3388621cso36816325ad.1; Sun, 05 Nov 2023 09:31:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699205519; x=1699810319; 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=RGzs0eC+XvZNsqZVAhz8siBL0+Ri4tF6SqjDCp2N3rM=; b=Cmz7xRbjbchBmjj7Upg1vdh+9FSLvNyZE0rB32fYtQsM6iWBwN+iipVJNC1GG2ORA9 ytSktphaFsnyv5E+xre/7BkNs8tNJShzbQvx87W66RsO8ES6RpT6Yo97U46xgt1Rg5rW SLjQVI6wHbNLbTnh+6VReaI1LZOdgfOrLsnk7xjbBHGcYUa3+P3AGj4V27YpsQq4DpLQ xfn1mJMKRkP9Gh4wUZPZ05adXi3jleX2qn29iLenz1SWQG4/++cQMPuwLlKrbr91VAMP O53uvR+lSQYbSzTrFqqTUcnfye3ePHiUCX2NOv/MywNBcVCo9g2wX2nVS6vrft0hTs60 +txA== X-Gm-Message-State: AOJu0YwvTZLwIE9xvaNe9iZTPGZmM4N2J7YpTaQpXitvSG4DTAQtZ7D0 7LpZocMCXpexHqToP6LBqsd+s8eeZPjAEAvTt4Y= X-Received: by 2002:a17:903:120e:b0:1cc:2518:ef02 with SMTP id l14-20020a170903120e00b001cc2518ef02mr11191699plh.14.1699205518672; Sun, 05 Nov 2023 09:31:58 -0800 (PST) MIME-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> <20231102175735.2272696-2-irogers@google.com> In-Reply-To: <20231102175735.2272696-2-irogers@google.com> From: Namhyung Kim Date: Sun, 5 Nov 2023 09:31:47 -0800 Message-ID: Subject: Re: [PATCH v4 01/53] 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 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 09:32:16 -0800 (PST) Hi Ian, On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers 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 Acked-by: Namhyung Kim 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 >