From: Adrian Hunter <adrian.hunter@intel.com>
To: Changbin Du <changbin.du@huawei.com>
Cc: 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>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Hui Wang <hw.huiwang@huawei.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v5 2/3] perf: add helper map__fprintf_dsoname_dsoff
Date: Thu, 20 Apr 2023 11:39:21 +0300 [thread overview]
Message-ID: <ff8bc134-853d-a9d9-901b-2c20beed8d05@intel.com> (raw)
In-Reply-To: <20230420025511.fkd7upvuoxfz2xih@M910t>
On 20/04/23 05:55, Changbin Du wrote:
> On Wed, Apr 19, 2023 at 09:58:10PM +0300, Adrian Hunter wrote:
>> On 18/04/23 06:18, Changbin Du wrote:
>>> This adds a helper function map__fprintf_dsoname_dsoff() to print dsoname
>>> with optional dso offset.
>>>
>>> Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
>>> Signed-off-by: Changbin Du <changbin.du@huawei.com>
>>> ---
>>> tools/perf/util/map.c | 13 +++++++++++++
>>> tools/perf/util/map.h | 1 +
>>> 2 files changed, 14 insertions(+)
>>>
>>> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
>>> index d81b6ca18ee9..7da96b41100f 100644
>>> --- a/tools/perf/util/map.c
>>> +++ b/tools/perf/util/map.c
>>> @@ -445,6 +445,19 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
>>> return fprintf(fp, "%s", dsoname);
>>> }
>>>
>>> +size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp)
>>> +{
>>> + int printed = 0;
>>> +
>>> + printed += fprintf(fp, " (");
>>> + printed += map__fprintf_dsoname(map, fp);
>>> + if (print_off && map && map__dso(map) && !map__dso(map)->kernel)
>>
>> That will also block vmlinux offsets not just [kernel.kallsyms]
>> Is that what was intended?
>>
> Not only vmlinux, modules are also blocked. We'd better print offset for
> vmlinux and modules.
>
> $ sudo perf script -k vmlinux -F +dsoff
> perf-exec 2531039 4120893.685967: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux)
> perf-exec 2531039 4120893.685970: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux)
> perf-exec 2531039 4120893.685972: 9 cycles: ffffffff99094ec4 [unknown] (vmlinux)
> perf-exec 2531039 4120893.685973: 194 cycles: ffffffff99094ec6 [unknown] (vmlinux)
> perf-exec 2531039 4120893.685974: 4605 cycles: ffffffff99094ec4 [unknown] (vmlinux)
> perf-exec 2531039 4120893.685976: 108083 cycles: ffffffff9928e8d0 [unknown] (vmlinux)
> ls 2531039 4120893.686003: 2197682 cycles: ffffffff993c92bc [unknown] (vmlinux)
> ls 2531039 4120893.686554: 4497190 cycles: ffffffffc159692b strcasestr+0x7b (/lib/modules/5.15.0-60-generic/extra/isac_ipc.ko)
> ls 2531039 4120893.687700: 4189758 cycles: ffffffffc18a5d66 delete_net_reject_cache+0x76 (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko)
> ls 2531039 4120893.688786: 3780376 cycles: ffffffffc18a67de delete_net_process_info+0x5e (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko)
> ls 2531039 4120893.689716: 3416607 cycles: ffffffffc18a67de delete_net_process_info+0x5e (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko)
>
> But I found addr returned by map__dso_map_ip() for 'vmlinux' is not a 'dso
> offset'.
>
> $ sudo perf script -k vmlinux -F +dsoff
> perf-exec 2531039 4120893.685967: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4)
> perf-exec 2531039 4120893.685970: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4)
> perf-exec 2531039 4120893.685972: 9 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4)
> perf-exec 2531039 4120893.685973: 194 cycles: ffffffff99094ec6 [unknown] (vmlinux+0xffffffff99094ec6)
>
> Do you have better idea?
>
What do you get if you try below diff on top of
your patches:
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c7bf1ac14e90..df0d21141185 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -576,8 +576,11 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
if (PRINT_FIELD(DSO))
output[type].print_ip_opts |= EVSEL__PRINT_DSO;
- if (PRINT_FIELD(DSOFF))
+ if (PRINT_FIELD(DSOFF)) {
output[type].print_ip_opts |= EVSEL__PRINT_DSOFF;
+ /* DSO offset is relative to dso->longname */
+ symbol_conf.show_kernel_path = true;
+ }
if (PRINT_FIELD(SYMOFFSET))
output[type].print_ip_opts |= EVSEL__PRINT_SYMOFFSET;
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a86614599269..19ebfd3468cc 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -67,6 +67,42 @@ char dso__symtab_origin(const struct dso *dso)
return origin[dso->symtab_type];
}
+bool dso__is_file(const struct dso *dso)
+{
+ switch (dso->binary_type) {
+ case DSO_BINARY_TYPE__KALLSYMS:
+ case DSO_BINARY_TYPE__GUEST_KALLSYMS:
+ return false;
+ case DSO_BINARY_TYPE__VMLINUX:
+ case DSO_BINARY_TYPE__GUEST_VMLINUX:
+ return true;
+ case DSO_BINARY_TYPE__JAVA_JIT:
+ return false;
+ case DSO_BINARY_TYPE__DEBUGLINK:
+ case DSO_BINARY_TYPE__BUILD_ID_CACHE:
+ case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
+ case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
+ case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
+ case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO:
+ case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
+ case DSO_BINARY_TYPE__GUEST_KMODULE:
+ case DSO_BINARY_TYPE__GUEST_KMODULE_COMP:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP:
+ case DSO_BINARY_TYPE__KCORE:
+ case DSO_BINARY_TYPE__GUEST_KCORE:
+ case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
+ return true;
+ case DSO_BINARY_TYPE__BPF_PROG_INFO:
+ case DSO_BINARY_TYPE__BPF_IMAGE:
+ case DSO_BINARY_TYPE__OOL:
+ case DSO_BINARY_TYPE__NOT_FOUND:
+ default:
+ return false;
+ }
+}
+
int dso__read_binary_type_filename(const struct dso *dso,
enum dso_binary_type type,
char *root_dir, char *filename, size_t size)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 0b7c7633b9f6..fb33f5224fb6 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -396,6 +396,8 @@ static inline bool dso__is_kallsyms(struct dso *dso)
return dso->kernel && dso->long_name[0] != '/';
}
+bool dso__is_file(const struct dso *dso);
+
void dso__free_a2l(struct dso *dso);
enum dso_type dso__type(struct dso *dso, struct machine *machine);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 7da96b41100f..9b79f88d371c 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -447,11 +447,12 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp)
{
+ const struct dso *dso = map ? map__dso(map) : NULL;
int printed = 0;
printed += fprintf(fp, " (");
printed += map__fprintf_dsoname(map, fp);
- if (print_off && map && map__dso(map) && !map__dso(map)->kernel)
+ if (print_off && dso && dso__is_file(dso))
printed += fprintf(fp, "+0x%" PRIx64, addr);
printed += fprintf(fp, ")");
next prev parent reply other threads:[~2023-04-20 8:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 3:18 [PATCH v5 0/3] perf script: Have consistent output for symbol address Changbin Du
2023-04-18 3:18 ` [PATCH v5 1/3] perf script: print raw ip instead of binary offset for callchain Changbin Du
2023-04-24 5:24 ` Adrian Hunter
2023-04-18 3:18 ` [PATCH v5 2/3] perf: add helper map__fprintf_dsoname_dsoff Changbin Du
2023-04-19 18:58 ` Adrian Hunter
2023-04-20 2:55 ` Changbin Du
2023-04-20 8:39 ` Adrian Hunter [this message]
2023-04-21 5:04 ` Changbin Du
2023-04-21 7:30 ` Adrian Hunter
2023-04-23 4:32 ` Changbin Du
2023-04-24 5:25 ` Adrian Hunter
2023-04-24 5:25 ` Adrian Hunter
2023-04-18 3:18 ` [PATCH v5 3/3] perf: script: add new output field 'dsoff' to print dso offset Changbin Du
2023-04-24 5:26 ` Adrian Hunter
2023-04-29 1:40 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ff8bc134-853d-a9d9-901b-2c20beed8d05@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=changbin.du@huawei.com \
--cc=hw.huiwang@huawei.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).