From patchwork Thu Jun 8 23:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13273009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B8C8C7EE23 for ; Thu, 8 Jun 2023 23:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bvSczSbn+l9UMcLQSvyaoNWEfIONZcwQ/WGoOX79M+E=; b=ouDm5m6FdGZXRN 1VoBZNOykuREAKSMjsHvOVQBMfkv9LZIN+yyLISuDcgaOnu+aVIE8pasNX/3lpcZadieif2NeC7EW CaLfYYBncozalrO2SNobubjEu1p92AkvtaqhGs1z8KzBGy3QaxF3oh3HivbIEbj1OK48tozIBwf2a sfbl3LIKiiavOJb1NUpt+OACe/tefclgKoYJgjTNtGk9vDpIui+CGv4DJtaLdV8KAYVnlSELFmFSK 4BdJPi7836FiSdenUX/8vVVgFr/fkEoDdAdGy0cfmsNJwCmcFCBlbKT4KyelIhsJ6HfRou5EfT+Rd /migZ7A3Dg9fgCITv9QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7P4N-00Auzj-0s; Thu, 08 Jun 2023 23:29:31 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7P4H-00AuvE-0s for linux-arm-kernel@lists.infradead.org; Thu, 08 Jun 2023 23:29:27 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bb39aebdd87so2572229276.0 for ; Thu, 08 Jun 2023 16:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686266964; x=1688858964; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=RGWgSynrOj/PLbqXNX2x48CdvWEXkGjqwrkmdfXHnVY=; b=PrpWinbTvoRzHNWvPNJNF33aAhfQd7XYp6Mxz2JjnjGgD8hI7sAxAVnVZFZDbqx9k7 kBAnswjlFIBVG/RzWzMZIKXQfjzOrDd1B3UW7qog5wXqFHCXPG6Mmah1WywxM6x/M/4M gul2G31zudV0rOyTH/RXGBdTG2oKj2vY491Nxf3Q9wIhew3j5F8lhsWhEkvPkb0V3L5K W0fkpz8PSLCd/K7qSh58D8nJ4WQoeqAEX79ukhshv7jrub3IYKPcPc8zlkyZzfpJUqNr 6wwNxnm+d0ExADXV7eCLubh9bpPLQmLVfYKVHroa9zm9SARHlihF7QiGILGCPxB/Yweb E5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686266964; x=1688858964; 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=RGWgSynrOj/PLbqXNX2x48CdvWEXkGjqwrkmdfXHnVY=; b=LQeK7q3oIvdNxtgfhjm3lI+81xNwZbms5cy38UB+B0brV55VnJZ+WFQ3N3xF8Aaifl aEp+q46OznrO16HertX8SVL3giMBAz0V2Ho/1fC7JBNFph2AGNBkDP/k5rIMSjHhDtF2 V8D9jWHkctx1IsV/W1Cep3RGwKGEAb+cu+dqOX453/IOc41zJN20vH3d9HYwc73U9nLF 8pmzpBKGRS1WpEtJ5oCEyKyFaxbxapdDcVelKveIUzDLxTqBECxyzPxSC0GrjO87ULC4 8uMz7ERNDKMGO9uLCtZAYS+lpw0v1Oqvop0tPIga5Ng0dXHzzKy74og5f2qe/jNZExXX Dxqg== X-Gm-Message-State: AC+VfDwJzXS5chaCRPArWdIx60114ytPxjvVn5r24ICNCE1Ys+9S3Hze 6+Hcc9Jw4Fi7YTG8xj/d3PH67nchZwW5 X-Google-Smtp-Source: ACHHUZ73d7KA7YvKZlm+FTDRrvHKTW9MdriwohP40DR/Hzk2z5mXwezVFmP5a91auPb6VSCYNi8uC90GmFzP X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:c3e5:ebc6:61e5:c73f]) (user=irogers job=sendgmr) by 2002:a05:6902:38a:b0:ba8:381b:f764 with SMTP id f10-20020a056902038a00b00ba8381bf764mr51238ybs.3.1686266963896; Thu, 08 Jun 2023 16:29:23 -0700 (PDT) Date: Thu, 8 Jun 2023 16:28:02 -0700 In-Reply-To: <20230608232823.4027869-1-irogers@google.com> Message-Id: <20230608232823.4027869-6-irogers@google.com> Mime-Version: 1.0 References: <20230608232823.4027869-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v2 05/26] perf addr_location: Move to its own header From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , "Naveen N. Rao" , Kan Liang , German Gomez , Ali Saidi , Jing Zhang , Athira Rajeev , Miguel Ojeda , ye xingchen , Liam Howlett , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , K Prateek Nayak , Changbin Du , Ravi Bangoria , Sean Christopherson , Andi Kleen , "Steinar H. Gunderson" , Yuan Can , Brian Robbins , liuwenyu , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230608_162925_315975_BB1D8537 X-CRM114-Status: GOOD ( 21.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org addr_location is a common abstraction, move it into its own header and source file in preparation for wider clean up. Signed-off-by: Ian Rogers --- tools/perf/util/Build | 1 + tools/perf/util/addr_location.c | 16 ++++++++++++++++ tools/perf/util/addr_location.h | 28 ++++++++++++++++++++++++++++ tools/perf/util/event.c | 12 ------------ tools/perf/util/symbol.h | 17 +---------------- 5 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 tools/perf/util/addr_location.c create mode 100644 tools/perf/util/addr_location.h diff --git a/tools/perf/util/Build b/tools/perf/util/Build index c449741adf30..ff2fd1a36bb8 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -1,4 +1,5 @@ perf-y += arm64-frame-pointer-unwind-support.o +perf-y += addr_location.o perf-y += annotate.o perf-y += block-info.o perf-y += block-range.o diff --git a/tools/perf/util/addr_location.c b/tools/perf/util/addr_location.c new file mode 100644 index 000000000000..c73fc2aa236c --- /dev/null +++ b/tools/perf/util/addr_location.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "addr_location.h" +#include "map.h" +#include "thread.h" + +/* + * The preprocess_sample method will return with reference counts for the + * in it, when done using (and perhaps getting ref counts if needing to + * keep a pointer to one of those entries) it must be paired with + * addr_location__put(), so that the refcounts can be decremented. + */ +void addr_location__put(struct addr_location *al) +{ + map__zput(al->map); + thread__zput(al->thread); +} diff --git a/tools/perf/util/addr_location.h b/tools/perf/util/addr_location.h new file mode 100644 index 000000000000..7dfa7417c0fe --- /dev/null +++ b/tools/perf/util/addr_location.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_ADDR_LOCATION +#define __PERF_ADDR_LOCATION 1 + +#include + +struct thread; +struct maps; +struct map; +struct symbol; + +struct addr_location { + struct thread *thread; + struct maps *maps; + struct map *map; + struct symbol *sym; + const char *srcline; + u64 addr; + char level; + u8 filtered; + u8 cpumode; + s32 cpu; + s32 socket; +}; + +void addr_location__put(struct addr_location *al); + +#endif /* __PERF_ADDR_LOCATION */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index e1ce7cb5e421..6ee23145ee7e 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -767,18 +767,6 @@ int machine__resolve(struct machine *machine, struct addr_location *al, return 0; } -/* - * The preprocess_sample method will return with reference counts for the - * in it, when done using (and perhaps getting ref counts if needing to - * keep a pointer to one of those entries) it must be paired with - * addr_location__put(), so that the refcounts can be decremented. - */ -void addr_location__put(struct addr_location *al) -{ - map__zput(al->map); - thread__zput(al->thread); -} - bool is_bts_event(struct perf_event_attr *attr) { return attr->type == PERF_TYPE_HARDWARE && diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 7558735543c2..5ca8665dd2c1 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -9,6 +9,7 @@ #include #include #include +#include "addr_location.h" #include "path.h" #include "symbol_conf.h" #include "spark.h" @@ -120,22 +121,6 @@ struct ref_reloc_sym { u64 unrelocated_addr; }; -struct addr_location { - struct thread *thread; - struct maps *maps; - struct map *map; - struct symbol *sym; - const char *srcline; - u64 addr; - char level; - u8 filtered; - u8 cpumode; - s32 cpu; - s32 socket; -}; - -void addr_location__put(struct addr_location *al); - int dso__load(struct dso *dso, struct map *map); int dso__load_vmlinux(struct dso *dso, struct map *map, const char *vmlinux, bool vmlinux_allocated);