From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH 1/3] perf machine: Add machine->has_data_mmap field
Date: Tue, 20 Jun 2023 13:18:16 -0700 [thread overview]
Message-ID: <20230620201818.1670753-1-namhyung@kernel.org> (raw)
So that it can indicate the it needs to collect data mappings. This is
needed especially for kernel maps.
At first, I just wanted to add it to struct machines only and to use the
machine->machines to check the value. But it turned out that some of
machine didn't belong to any machines (eg. some test codes), so I just
copied the value to individual struct machine.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-inject.c | 2 +-
tools/perf/builtin-record.c | 2 +-
tools/perf/tests/vmlinux-kallsyms.c | 4 ++--
tools/perf/util/machine.c | 12 +++++++-----
tools/perf/util/machine.h | 10 ++++++++--
tools/perf/util/session.c | 4 ++--
tools/perf/util/session.h | 4 ++--
7 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index c8cf2fdd9cff..481adaa97a68 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -2325,7 +2325,7 @@ int cmd_inject(int argc, const char **argv)
}
inject.session = __perf_session__new(&data, repipe,
- output_fd(&inject),
+ output_fd(&inject), false,
&inject.tool);
if (IS_ERR(inject.session)) {
ret = PTR_ERR(inject.session);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index aec18db7ff23..b4d0154dcb18 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -2373,7 +2373,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
signal(SIGUSR2, SIG_IGN);
}
- session = perf_session__new(data, tool);
+ session = __perf_session__new(data, false, -1, rec->opts.sample_address, tool);
if (IS_ERR(session)) {
pr_err("Perf session creation failed.\n");
return PTR_ERR(session);
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 1078a93b01aa..1f1ba3ae88aa 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -131,8 +131,8 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
* Init the machines that will hold kernel, modules obtained from
* both vmlinux + .ko files and from /proc/kallsyms split by modules.
*/
- machine__init(&kallsyms, "", HOST_KERNEL_ID);
- machine__init(&vmlinux, "", HOST_KERNEL_ID);
+ machine__init(&kallsyms, "", HOST_KERNEL_ID, false);
+ machine__init(&vmlinux, "", HOST_KERNEL_ID, false);
maps = machine__kernel_maps(&vmlinux);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 4e62843d51b7..ddc0a2130caf 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -110,7 +110,7 @@ static void thread__set_guest_comm(struct thread *thread, pid_t pid)
thread__set_comm(thread, comm, 0);
}
-int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
+int machine__init(struct machine *machine, const char *root_dir, pid_t pid, bool has_data_mmap)
{
int err = -ENOMEM;
@@ -128,6 +128,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
machine->env = NULL;
machine->pid = pid;
+ machine->has_data_mmap = has_data_mmap;
machine->id_hdr_size = 0;
machine->kptr_restrict_warned = false;
@@ -170,7 +171,7 @@ struct machine *machine__new_host(void)
struct machine *machine = malloc(sizeof(*machine));
if (machine != NULL) {
- machine__init(machine, "", HOST_KERNEL_ID);
+ machine__init(machine, "", HOST_KERNEL_ID, false);
if (machine__create_kernel_maps(machine) < 0)
goto out_delete;
@@ -272,10 +273,11 @@ void machine__delete(struct machine *machine)
}
}
-void machines__init(struct machines *machines)
+void __machines__init(struct machines *machines, bool have_data_mmap)
{
- machine__init(&machines->host, "", HOST_KERNEL_ID);
+ machine__init(&machines->host, "", HOST_KERNEL_ID, have_data_mmap);
machines->guests = RB_ROOT_CACHED;
+ machines->have_data_mmaps = have_data_mmap;
}
void machines__exit(struct machines *machines)
@@ -295,7 +297,7 @@ struct machine *machines__add(struct machines *machines, pid_t pid,
if (machine == NULL)
return NULL;
- if (machine__init(machine, root_dir, pid) != 0) {
+ if (machine__init(machine, root_dir, pid, machines->have_data_mmaps) != 0) {
free(machine);
return NULL;
}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index d034ecaf89c1..f54e5c888a99 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -46,6 +46,7 @@ struct machine {
bool comm_exec;
bool kptr_restrict_warned;
bool single_address_space;
+ bool has_data_mmap;
char *root_dir;
char *mmap_name;
char *kallsyms_filename;
@@ -160,9 +161,14 @@ typedef void (*machine__process_t)(struct machine *machine, void *data);
struct machines {
struct machine host;
struct rb_root_cached guests;
+ bool have_data_mmaps;
};
-void machines__init(struct machines *machines);
+void __machines__init(struct machines *machines, bool data_mmap);
+static inline void machines__init(struct machines *machines)
+{
+ __machines__init(machines, false);
+}
void machines__exit(struct machines *machines);
void machines__process_guests(struct machines *machines,
@@ -181,7 +187,7 @@ void machines__set_comm_exec(struct machines *machines, bool comm_exec);
struct machine *machine__new_host(void);
struct machine *machine__new_kallsyms(void);
-int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
+int machine__init(struct machine *machine, const char *root_dir, pid_t pid, bool has_data_mmap);
void machine__exit(struct machine *machine);
void machine__delete_threads(struct machine *machine);
void machine__delete(struct machine *machine);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 00d18c74c090..e09a02ec8f28 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -191,7 +191,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
}
struct perf_session *__perf_session__new(struct perf_data *data,
- bool repipe, int repipe_fd,
+ bool repipe, int repipe_fd, bool data_mmap,
struct perf_tool *tool)
{
int ret = -ENOMEM;
@@ -205,7 +205,7 @@ struct perf_session *__perf_session__new(struct perf_data *data,
session->decomp_data.zstd_decomp = &session->zstd_data;
session->active_decomp = &session->decomp_data;
INIT_LIST_HEAD(&session->auxtrace_index);
- machines__init(&session->machines);
+ __machines__init(&session->machines, data_mmap);
ordered_events__init(&session->ordered_events,
ordered_events__deliver_event, NULL);
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index ee3715e8563b..465610e81e95 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -64,13 +64,13 @@ struct decomp {
struct perf_tool;
struct perf_session *__perf_session__new(struct perf_data *data,
- bool repipe, int repipe_fd,
+ bool repipe, int repipe_fd, bool data_mmap,
struct perf_tool *tool);
static inline struct perf_session *perf_session__new(struct perf_data *data,
struct perf_tool *tool)
{
- return __perf_session__new(data, false, -1, tool);
+ return __perf_session__new(data, false, -1, false, tool);
}
void perf_session__delete(struct perf_session *session);
--
2.41.0.185.g7c58973941-goog
next reply other threads:[~2023-06-20 20:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 20:18 Namhyung Kim [this message]
2023-06-20 20:18 ` [PATCH 2/3] perf tools: Add kallsyms__get_symbol_start() Namhyung Kim
2023-06-22 17:23 ` Ian Rogers
2023-06-20 20:18 ` [PATCH 3/3] perf machine: Include data symbols in the kernel map Namhyung Kim
2023-06-22 17:27 ` Ian Rogers
2023-07-11 15:19 ` Adrian Hunter
2023-07-11 17:30 ` Namhyung Kim
2023-07-12 5:44 ` Adrian Hunter
2023-06-22 17:17 ` [PATCH 1/3] perf machine: Add machine->has_data_mmap field Ian Rogers
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=20230620201818.1670753-1-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@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