From patchwork Thu Dec 7 01:17:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 174851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4488733vqy; Wed, 6 Dec 2023 17:21:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGq3wkEnxvsbKZZ4n+QLBJvAg+VCBFzmvWQfSduB63iO9x+NMmHus7T5PkevjSUzERthRsh X-Received: by 2002:a17:903:5ce:b0:1cf:cf34:d4fa with SMTP id kf14-20020a17090305ce00b001cfcf34d4famr1545588plb.28.1701912086234; Wed, 06 Dec 2023 17:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701912086; cv=none; d=google.com; s=arc-20160816; b=hPZtpW+ExKNPLKuJU2zNqhxDuV4XoUw8lYW81xybR4PymiIxIxOXge4DWFKFkZvPLe 0JyNuyM6pJPECfc4Ew6BkPhEfrGdv1TzkuR0nIC+7S98X4VUM2AN/0FTh9//wwYTwuYo AiwiFnir9w2Wejexr7C557OL+UboYJYQFOL9inoqe3lP8qnPP6/5zEccgwgbpMS6zxvl DNW/WOnynrxYEjxw8jFU0cKOXGPbPvm/A/wag2ROCeckkTHKW+QGH6i0srnvzWSy/i+m wU41DimQiRxK5mIH+ZEuhtQ9/62rLeH1CCqaEukKmuyE45gyuXk9n/4LBTniHyprEXOg 9aig== 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=CIMmx6J4S5TjSiB/ARtZ96SubuSk4U5KCdyouo2+dj8=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=NKxFpD+abEFDt13m0rxpKoVU9ToxpTevA3IvHbLEBc9QmZ2yhwMRRGBU3UNEEjro/N XuTfMd0Wqc0dfvU+NHEaVRpcq7MqZWoxNJH4Ztx3wnSlsFsEN036lCeF0cLW68JUNYLX EtarMVtn+wPi9bm/rOKwqc36vxs32IXxQU1Kl6XC6vZqGmIuqZcjpJ/JL1ccieKradDb zMua1xVnRO7FRVqQ9uoHlJuRGCDeSCtHCeldqNI7b61J6PQLWa/YE71Tqzj7DdRzIo7h xrflbRn78ZZu9B3/wAwAwtUMnu4CjCLcoudm25c7xaa12JYxS7v4tWhEa9u6SExwykBD 0jEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="XwW/NesN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j9-20020a17090276c900b001d065c68f06si150122plt.494.2023.12.06.17.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:21:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="XwW/NesN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 2F0718023EDB; Wed, 6 Dec 2023 17:21:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442962AbjLGBU5 (ORCPT + 99 others); Wed, 6 Dec 2023 20:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443050AbjLGBUD (ORCPT ); Wed, 6 Dec 2023 20:20:03 -0500 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 CAADB30CB for ; Wed, 6 Dec 2023 17:19:08 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5d0c4ba7081so1840507b3.0 for ; Wed, 06 Dec 2023 17:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701911947; x=1702516747; 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=CIMmx6J4S5TjSiB/ARtZ96SubuSk4U5KCdyouo2+dj8=; b=XwW/NesNloI3p5JOl+wTVcotV+t1Fm2xfaVYiVWLlZ9X/SpQt9bXm93CYgJ71rvV1o c4os/66RBAF1978j7coXjrnFl5LX9r3vuDvyCAy16MBVJWAGKsE3hVXYleexd+RtIjNw rbfBYo0QdKVdu0azT+J7Cb+QT/2Erlm4zAGiw4ZTuW+7NdMUJv5Uj/Fhaj9mUgWG7iz2 yvSTSIefdQy8XdZ/gVfrCAlu5ZxK3h63OaY8gQikA8Xf5+dl6qQpxu8HuhaZNn0zi4LC 3Ky01xhRIVorMPtReVi7xiPcPiYT/mO8YMGpllDM2s57n8jyq6XDFwkp3iM4m+LHnklp c1zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701911947; x=1702516747; 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=CIMmx6J4S5TjSiB/ARtZ96SubuSk4U5KCdyouo2+dj8=; b=wMdCwN+n1hKbekwv/8DjSTvq6e8zk5VvQPFlGCy7KUQPjNoRMdsTw902/WhbLRXURK mzByBBQxBdkCCijLLvAPvGm/6Dk1kGEWH8cgFcJqHXkExljem+sI3ygP8n6JVq35fU2q WzN6eVXNQ6Q4UkWePm9Ua+Wy9vu+MpXaG5FuD9hn95N1BYpWeXw4FgG3jQjgUZyMkpjv Bw9Dh9h8UrtZjDzx8/OzVvR53LHpIC3njS7djQgvsSL3GO04P3yJZ/rvo7/3v3CVNCFC H9ZijMmegLURyIDHCT9+i44VaXl8kKOHDqc+DcR9RsO+beoSZirA95KfrcwrmW8W6FlW Ar3g== X-Gm-Message-State: AOJu0YxYm0hqOAHjLE/RVpLlo8S/I+v9JKrsfaZA663SzRYe8+9eJj/y h2whmeNnln+55WAU8SXMFmVYRsfo8+qH X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a81:b617:0:b0:5d8:394d:a8f4 with SMTP id u23-20020a81b617000000b005d8394da8f4mr33615ywh.10.1701911947046; Wed, 06 Dec 2023 17:19:07 -0800 (PST) Date: Wed, 6 Dec 2023 17:17:17 -0800 In-Reply-To: <20231207011722.1220634-1-irogers@google.com> Message-Id: <20231207011722.1220634-44-irogers@google.com> Mime-Version: 1.0 References: <20231207011722.1220634-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v6 43/47] perf dsos: Remove __dsos__findnew_link_by_longname_id From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , 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 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 17:21:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784584167604461693 X-GMAIL-MSGID: 1784584167604461693 Function was only called in dsos.c with the dso parameter as NULL. Remove the function and specialize for the dso being NULL case removing other unused functions along the way. Signed-off-by: Ian Rogers --- tools/perf/util/dsos.c | 51 +++++++++--------------------------------- tools/perf/util/dsos.h | 6 ----- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c index 1495ab1cd7a0..e4110438841b 100644 --- a/tools/perf/util/dsos.c +++ b/tools/perf/util/dsos.c @@ -119,11 +119,6 @@ static int __dso__cmp_short_name(const char *short_name, struct dso_id *id, stru return rc ?: dso_id__cmp(id, &b->id); } -static int dso__cmp_short_name(struct dso *a, struct dso *b) -{ - return __dso__cmp_short_name(a->short_name, &a->id, b); -} - static int dsos__cmp_long_name_id_short_name(const void *va, const void *vb) { const struct dso *a = *((const struct dso **)va); @@ -143,20 +138,21 @@ static int dsos__cmp_long_name_id_short_name(const void *va, const void *vb) * Either one of the dso or name parameter must be non-NULL or the * function will not work. */ -struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, - struct dso *dso, - const char *name, - struct dso_id *id, - bool write_locked) +static struct dso *__dsos__find_by_longname_id(struct dsos *dsos, + const char *name, + struct dso_id *id, + bool write_locked) { int low = 0, high = dsos->cnt - 1; if (!dsos->sorted) { if (!write_locked) { + struct dso *dso; + up_read(&dsos->lock); down_write(&dsos->lock); - dso = __dsos__findnew_link_by_longname_id(dsos, dso, name, id, - /*write_locked=*/true); + dso = __dsos__find_by_longname_id(dsos, name, id, + /*write_locked=*/true); up_write(&dsos->lock); down_read(&dsos->lock); return dso; @@ -166,9 +162,6 @@ struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, dsos->sorted = true; } - if (!name) - name = dso->long_name; - /* * Find node with the matching name */ @@ -178,31 +171,13 @@ struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, int rc = __dso__cmp_long_name(name, id, this); if (rc == 0) { - /* - * In case the new DSO is a duplicate of an existing - * one, print a one-time warning & put the new entry - * at the end of the list of duplicates. - */ - if (!dso || (dso == this)) - return dso__get(this); /* Find matching dso */ - /* - * The core kernel DSOs may have duplicated long name. - * In this case, the short name should be different. - * Comparing the short names to differentiate the DSOs. - */ - rc = dso__cmp_short_name(dso, this); - if (rc == 0) { - pr_err("Duplicated dso name: %s\n", name); - return NULL; - } + return dso__get(this); /* Find matching dso */ } if (rc < 0) high = mid - 1; else low = mid + 1; } - if (dso) - __dsos__add(dsos, dso); return NULL; } @@ -240,12 +215,6 @@ int dsos__add(struct dsos *dsos, struct dso *dso) return ret; } -static struct dso *__dsos__findnew_by_longname_id(struct dsos *dsos, const char *name, - struct dso_id *id, bool write_locked) -{ - return __dsos__findnew_link_by_longname_id(dsos, NULL, name, id, write_locked); -} - struct dsos__find_id_cb_args { const char *name; struct dso_id *id; @@ -279,7 +248,7 @@ static struct dso *__dsos__find_id(struct dsos *dsos, const char *name, struct d __dsos__for_each_dso(dsos, dsos__find_id_cb, &args); return args.res; } - res = __dsos__findnew_by_longname_id(dsos, name, id, write_locked); + res = __dsos__find_by_longname_id(dsos, name, id, write_locked); return res; } diff --git a/tools/perf/util/dsos.h b/tools/perf/util/dsos.h index d1497b11d64c..6c13b65648bc 100644 --- a/tools/perf/util/dsos.h +++ b/tools/perf/util/dsos.h @@ -36,12 +36,6 @@ struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, struct dso_id bool dsos__read_build_ids(struct dsos *dsos, bool with_hits); -struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, - struct dso *dso, - const char *name, - struct dso_id *id, - bool write_locked); - size_t dsos__fprintf_buildid(struct dsos *dsos, FILE *fp, bool (skip)(struct dso *dso, int parm), int parm); size_t dsos__fprintf(struct dsos *dsos, FILE *fp);