perf: revert PERF_RECORD_MMAP2 support
PATCH 1/1 perf: revert PERF_RECORD_MMAP2 support
This unified patch removes the following commits
for both kernel and perf tool:
6adb0b0 perf tools: Add default handler for mmap2 events 384c671 perf trace: Add mmap2 handler
5c5e854 perf tools: Add attr->mmap2 support d008d52 perf: Fix up MMAP2 buffer space reservation 13d7a24 perf: Add attr->mmap2 attribute to an event
The MMAP2 record extension is not quite ready for prime time. We have identified address space cases where mappings would not be reported properly when apps fiddled directly with clone() and VM_CLONE. We will revisit the patch series soon.
--- include/uapi/linux/perf_event.h | 24 +---------------- kernel/events/core.c | 47 +++----------------------------- tools/perf/builtin-annotate.c | 1 - tools/perf/builtin-inject.c | 15 ----------- tools/perf/builtin-mem.c | 1 - tools/perf/builtin-report.c | 1 - tools/perf/builtin-script.c | 1 - tools/perf/builtin-trace.c | 1 - tools/perf/tests/perf-record.c | 15 +++-------- tools/perf/util/build-id.c | 1 - tools/perf/util/event.c | 56 +++++++++------------------------------ tools/perf/util/event.h | 19 ------------- tools/perf/util/evsel.c | 16 +++-------- tools/perf/util/header.c | 3 --- tools/perf/util/machine.c | 53 +----------------------------------- tools/perf/util/machine.h | 1 - tools/perf/util/map.c | 8 +----- tools/perf/util/map.h | 8 ++---- tools/perf/util/session.c | 27 +------------------ tools/perf/util/tool.h | 1 - 20 files changed, 30 insertions(+), 269 deletions(-)
include/uapi/linux/perf_event.h +1 -23
@@ -300,9 +300,8 @@ struct perf_event_attr { exclude_callchain_kernel : 1, /* exclude kernel callchains */ exclude_callchain_user : 1, /* exclude user callchains */ - mmap2 : 1, /* include mmap with inode data */ - __reserved_1 : 40; + __reserved_1 : 41;union {__u32 wakeup_events;/* wakeup every n events */
@@ -681,27 +680,6 @@ enum perf_event_type {*/ PERF_RECORD_SAMPLE =9 , -/* -* The MMAP2 records are an augmented version of MMAP, they add -* maj, min, ino numbers to be used to uniquely identify each mapping -* -* struct { -* struct perf_event_header header; -* -* u32 pid, tid; -* u64 addr; -* u64 len; -* u64 pgoff; -* u32 maj; -* u32 min; -* u64 ino; -* u64 ino_generation; -* char filename[]; -* struct sample_id sample_id; -* }; -*/ -PERF_RECORD_MMAP2 =10 , - PERF_RECORD_MAX, /* non-ABI */ };
kernel/events/core.c +4 -43
113 lines not on this page · raw message
tools/perf/builtin-annotate.c +0 -1
@@ -297,7 +297,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) .tool = { .sample = process_sample_event, .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, .comm = perf_event__process_comm, .exit = perf_event__process_exit, .fork = perf_event__process_fork,
tools/perf/builtin-inject.c +0 -15
@@ -123,19 +123,6 @@ static int perf_event__repipe_mmap(struct perf_tool *tool,return err; } -static int perf_event__repipe_mmap2 (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample, -struct machine *machine) -{ -int err; - - err =perf_event__process_mmap2 (tool, event, sample, machine); -perf_event__repipe (tool, event, sample, machine); - -return err; -} - static int perf_event__repipe_fork(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample,
@@ -350,7 +337,6 @@ static int __cmd_inject(struct perf_inject *inject)if (inject->build_ids || inject->sched_stat) { inject->tool.mmap = perf_event__repipe_mmap; - inject->tool.mmap2 = perf_event__repipe_mmap2; inject->tool.fork = perf_event__repipe_fork; inject->tool.tracing_data = perf_event__repipe_tracing_data; }
@@ -402,7 +388,6 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) .tool = { .sample = perf_event__repipe_sample, .mmap = perf_event__repipe, - .mmap2 = perf_event__repipe, .comm = perf_event__repipe, .fork = perf_event__repipe, .exit = perf_event__repipe,
tools/perf/builtin-mem.c +0 -1
@@ -190,7 +190,6 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) .tool = { .sample = process_sample_event, .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, .comm = perf_event__process_comm, .lost = perf_event__process_lost, .fork = perf_event__process_fork,
tools/perf/builtin-report.c +0 -1
@@ -757,7 +757,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) .tool = { .sample = process_sample_event, .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, .comm = perf_event__process_comm, .exit = perf_event__process_exit, .fork = perf_event__process_fork,
tools/perf/builtin-script.c +0 -1
@@ -542,7 +542,6 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,static struct perf_tool perf_script = { .sample = process_sample_event, .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, .comm = perf_event__process_comm, .exit = perf_event__process_exit, .fork = perf_event__process_fork,
tools/perf/builtin-trace.c +0 -1
@@ -1790,7 +1790,6 @@ static int trace__replay(struct trace *trace) trace->tool.sample = trace__process_sample; trace->tool.mmap = perf_event__process_mmap; - trace->tool.mmap2 = perf_event__process_mmap2; trace->tool.comm = perf_event__process_comm; trace->tool.exit = perf_event__process_exit; trace->tool.fork = perf_event__process_fork;
tools/perf/tests/perf-record.c +4 -11
@@ -50,7 +50,7 @@ int test__PERF_RECORD(void)struct perf_sample sample;const char *cmd ="sleep" ;const char *argv[] = { cmd,"1" ,NULL , }; -char *bname, *mmap_filename; +char *bname;u64 prev_time =0 ;bool found_cmd_mmap = false, found_libc_mmap = false,
@@ -202,7 +202,6 @@ int test__PERF_RECORD(void)if ((type ==PERF_RECORD_COMM || type ==PERF_RECORD_MMAP || - type ==PERF_RECORD_MMAP2 || type ==PERF_RECORD_FORK || type ==PERF_RECORD_EXIT ) && (pid_t )event->comm.pid != evlist->workload.pid) {
@@ -211,8 +210,7 @@ int test__PERF_RECORD(void) }if ((type ==PERF_RECORD_COMM || - type ==PERF_RECORD_MMAP || - type ==PERF_RECORD_MMAP2 ) && + type ==PERF_RECORD_MMAP ) && event->comm.pid != event->comm.tid) {pr_debug ("%s with different pid/tid!\n" , name); ++errs;
@@ -228,12 +226,7 @@ int test__PERF_RECORD(void)case PERF_RECORD_EXIT : goto found_exit;case PERF_RECORD_MMAP : - mmap_filename = event->mmap.filename; - goto check_bname; -case PERF_RECORD_MMAP2 : - mmap_filename = event->mmap2.filename; - check_bname: - bname =strrchr (mmap_filename,'/' ); + bname =strrchr (event->mmap.filename,'/' );if (bname !=NULL ) {if (!found_cmd_mmap) found_cmd_mmap = !strcmp (bname +1 , cmd);
@@ -242,7 +235,7 @@ int test__PERF_RECORD(void)if (!found_ld_mmap) found_ld_mmap = !strncmp (bname +1 ,"ld" ,2 ); }else if (!found_vdso_mmap) - found_vdso_mmap = !strcmp (mmap_filename,"[vdso]" ); + found_vdso_mmap = !strcmp (event->mmap.filename,"[vdso]" );break ;case PERF_RECORD_SAMPLE :
tools/perf/util/build-id.c +0 -1
@@ -67,7 +67,6 @@ static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused,struct perf_tool build_id__mark_dso_hit_ops = { .sample = build_id__mark_dso_hit, .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, .fork = perf_event__process_fork, .exit = perf_event__exit_del_thread, .attr = perf_event__process_attr,
tools/perf/util/event.c +12 -44
106 lines not on this page · raw message
tools/perf/util/event.h +0 -19
@@ -17,19 +17,6 @@ struct mmap_event {char filename[PATH_MAX ]; }; -struct mmap2_event { -struct perf_event_header header; -u32 pid, tid; -u64 start; -u64 len; -u64 pgoff; -u32 maj; -u32 min; -u64 ino; -u64 ino_generation; -char filename[PATH_MAX ]; -}; -struct comm_event {struct perf_event_header header;u32 pid, tid;
@@ -182,7 +169,6 @@ struct tracing_data_event {union perf_event {struct perf_event_header header;struct mmap_event mmap; -struct mmap2_event mmap2;struct comm_event comm;struct fork_event fork;struct lost_event lost;
@@ -233,10 +219,6 @@ int perf_event__process_mmap(struct perf_tool *tool,union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap2 (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample, -struct machine *machine); int perf_event__process_fork(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample,
@@ -267,7 +249,6 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,size_t perf_event__fprintf_comm (union perf_event *event,FILE *fp);size_t perf_event__fprintf_mmap (union perf_event *event,FILE *fp); -size_t perf_event__fprintf_mmap2 (union perf_event *event,FILE *fp);size_t perf_event__fprintf_task (union perf_event *event,FILE *fp);size_t perf_event__fprintf (union perf_event *event,FILE *fp);
tools/perf/util/evsel.c +4 -12
@@ -27,7 +27,6 @@static struct {bool sample_id_all;bool exclude_guest; -bool mmap2; } perf_missing_features;#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
@@ -677,9 +676,8 @@ void perf_evsel__config(struct perf_evsel *evsel,if (opts->sample_weight) attr->sample_type |=PERF_SAMPLE_WEIGHT ; - attr->mmap = track; - attr->mmap2 = track && !perf_missing_features.mmap2; - attr->comm = track; + attr->mmap = track; + attr->comm = track;if (opts->sample_transaction) attr->sample_type |=PERF_SAMPLE_TRANSACTION ;
@@ -1021,8 +1019,6 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, } fallback_missing_features: -if (perf_missing_features.mmap2) - evsel->attr.mmap2 =0 ;if (perf_missing_features.exclude_guest) evsel->attr.exclude_guest = evsel->attr.exclude_host =0 ; retry_sample_id:
@@ -1087,11 +1083,8 @@ try_fallback:if (err != -EINVAL || cpu >0 || thread >0 ) goto out_close; -if (!perf_missing_features.mmap2 && evsel->attr.mmap2) { - perf_missing_features.mmap2 = true; - goto fallback_missing_features; - }else if (!perf_missing_features.exclude_guest && - (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { +if (!perf_missing_features.exclude_guest && + (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { perf_missing_features.exclude_guest = true; goto fallback_missing_features; }else if (!perf_missing_features.sample_id_all) {
@@ -1944,7 +1937,6 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,if_print (exclude_hv);if_print (exclude_idle);if_print (mmap); -if_print (mmap2);if_print (comm);if_print (freq);if_print (inherit_stat);
tools/perf/util/header.c +0 -3
@@ -1366,9 +1366,6 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)fprintf (fp,", precise_ip = %d" , evsel->attr.precise_ip); -fprintf (fp,", attr_mmap2 = %d" , evsel->attr.mmap2); -fprintf (fp,", attr_mmap = %d" , evsel->attr.mmap); -fprintf (fp,", attr_mmap_data = %d" , evsel->attr.mmap_data);if (evsel->ids) {fprintf (fp,", id = {" );for (j =0 , id = evsel->id; j < evsel->ids; j++, id++) {
tools/perf/util/machine.c +1 -52
71 lines not on this page · raw message
tools/perf/util/machine.h +0 -1
@@ -45,7 +45,6 @@ int machine__process_exit_event(struct machine *machine, union perf_event *eventint machine__process_fork_event (struct machine *machine,union perf_event *event);int machine__process_lost_event (struct machine *machine,union perf_event *event);int machine__process_mmap_event (struct machine *machine,union perf_event *event); -int machine__process_mmap2_event (struct machine *machine,union perf_event *event);int machine__process_event (struct machine *machine,union perf_event *event);typedef void (*machine__process_t )(struct machine *machine,void *data);
tools/perf/util/map.c +1 -7
@@ -48,8 +48,7 @@ void map__init(struct map *map, enum map_type type, }struct map *map__new (struct list_head *dsos__list,u64 start,u64 len, -u64 pgoff,u32 pid,u32 d_maj,u32 d_min,u64 ino, -u64 ino_gen,char *filename, +u64 pgoff,u32 pid,char *filename,enum map_type type) {struct map *map =malloc (sizeof (*map));
@@ -63,11 +62,6 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, vdso =is_vdso_map (filename); no_dso =is_no_dso_memory (filename); - map->maj = d_maj; - map->min = d_min; - map->ino = ino; - map->ino_generation = ino_gen; -if (anon) {snprintf (newfilename,sizeof (newfilename),"/tmp/perf-%d.map" , pid); filename = newfilename;
tools/perf/util/map.h +2 -6
@@ -36,9 +36,6 @@ struct map {bool erange_warned;u32 priv;u64 pgoff; -u32 maj, min;/* only valid for MMAP2 record */ -u64 ino;/* only valid for MMAP2 record */ -u64 ino_generation;/* only valid for MMAP2 record */ /* ip -> dso rip */ u64 (*map_ip)(struct map *,u64 );
@@ -94,9 +91,8 @@ typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);void map__init (struct map *map,enum map_type type,u64 start,u64 end,u64 pgoff,struct dso *dso);struct map *map__new (struct list_head *dsos__list,u64 start,u64 len, -u64 pgoff,u32 pid,u32 d_maj,u32 d_min,u64 ino, -u64 ino_gen, -char *filename,enum map_type type); +u64 pgoff,u32 pid,char *filename, +enum map_type type);struct map *map__new2 (u64 start,struct dso *dso,enum map_type type);void map__delete (struct map *map);struct map *map__clone (struct map *map);
tools/perf/util/session.c +1 -26
@@ -256,8 +256,6 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->sample = process_event_sample_stub;if (tool->mmap ==NULL ) tool->mmap = process_event_stub; -if (tool->mmap2 ==NULL ) - tool->mmap2 = process_event_stub;if (tool->comm ==NULL ) tool->comm = process_event_stub;if (tool->fork ==NULL )
@@ -353,25 +351,6 @@ static void perf_event__mmap_swap(union perf_event *event, } } -static void perf_event__mmap2_swap (union perf_event *event, -bool sample_id_all) -{ - event->mmap2.pid =bswap_32 (event->mmap2.pid); - event->mmap2.tid =bswap_32 (event->mmap2.tid); - event->mmap2.start =bswap_64 (event->mmap2.start); - event->mmap2.len =bswap_64 (event->mmap2.len); - event->mmap2.pgoff =bswap_64 (event->mmap2.pgoff); - event->mmap2.maj =bswap_32 (event->mmap2.maj); - event->mmap2.min =bswap_32 (event->mmap2.min); - event->mmap2.ino =bswap_64 (event->mmap2.ino); - -if (sample_id_all) { -void *data = &event->mmap2.filename; - - data +=PERF_ALIGN (strlen (data) +1 ,sizeof (u64)); -swap_sample_id_all (event, data); - } -}static void perf_event__task_swap (union perf_event *event,bool sample_id_all) { event->fork.pid =bswap_32 (event->fork.pid);
@@ -487,7 +466,6 @@ typedef void (*perf_event__swap_op)(union perf_event *event,static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_MMAP ] = perf_event__mmap_swap, - [PERF_RECORD_MMAP2 ] = perf_event__mmap2_swap, [PERF_RECORD_COMM ] = perf_event__comm_swap, [PERF_RECORD_FORK ] = perf_event__task_swap, [PERF_RECORD_EXIT ] = perf_event__task_swap,
@@ -892,8 +870,7 @@ static struct machine * (cpumode == PERF_RECORD_MISC_GUEST_USER))) {u32 pid; -if (event->header.type ==PERF_RECORD_MMAP - || event->header.type ==PERF_RECORD_MMAP2 ) +if (event->header.type ==PERF_RECORD_MMAP ) pid = event->mmap.pid;else pid = sample->pid;
@@ -1020,8 +997,6 @@ static int perf_session_deliver_event(struct perf_session *session, sample, evsel, machine);case PERF_RECORD_MMAP :return tool->mmap (tool, event, sample, machine); -case PERF_RECORD_MMAP2 : -return tool->mmap2 (tool, event, sample, machine);case PERF_RECORD_COMM :return tool->comm (tool, event, sample, machine);case PERF_RECORD_FORK :
tools/perf/util/tool.h +0 -1
@@ -29,7 +29,6 @@ struct perf_tool {event_sample sample, read;event_op mmap, - mmap2, comm, fork, exit,
Signature · 1 line
1.7.10.4
Quoted 30 lines · Stephane Eranian
This unified patch removes the following commits
for both kernel and perf tool:6adb0b0 perf tools: Add default handler for mmap2 events 384c671 perf trace: Add mmap2 handler
5c5e854 perf tools: Addattr->mmap2support d008d52 perf: Fix up MMAP2 buffer space reservation 13d7a24 perf: Addattr->mmap2attribute to an eventThe MMAP2 record extension is not quite ready for prime time. We have identified address space cases where mappings would not be reported properly when apps fiddled directly with
clone()andVM_CLONE. We will revisit the patch series soon.Signed-off-by Stephane Eranian <[email protected]>--- include/uapi/linux/perf_event.h | 24 +---------------- kernel/events/core.c | 47 +++----------------------------- tools/perf/builtin-annotate.c | 1 - tools/perf/builtin-inject.c | 15 ----------- tools/perf/builtin-mem.c | 1 - tools/perf/builtin-report.c | 1 - tools/perf/builtin-script.c | 1 - tools/perf/builtin-trace.c | 1 - tools/perf/tests/perf-record.c | 15 +++-------- tools/perf/util/build-id.c | 1 - tools/perf/util/event.c | 56 +++++++++------------------------------ tools/perf/util/event.h | 19 ------------- tools/perf/util/evsel.c | 16 +++--------
Quoted 8 lines
tools/perf/util/header.c | 3 --- tools/perf/util/machine.c | 53 +----------------------------------- tools/perf/util/machine.h | 1 - tools/perf/util/map.c | 8 +----- tools/perf/util/map.h | 8 ++---- tools/perf/util/session.c | 27 +------------------ tools/perf/util/tool.h | 1 - 20 files changed, 30 insertions(+), 269 deletions(-)
Ugh, that's way too large.
I thought the plan was to do a minimal revert. Is there really no way to do this in a (much) shorter fashion?
For example by a simple patch that returns -EINVAL (or -ENOSYS) if the new flag is used - i.e. behaves like the old kernel in that regard - but leaves the rest in place. (the 'rest' will hopefully be fixed for v3.13)
Tooling will then fall back as if it was an old kernel - i.e. no changes needed there at all. Right?
Hm?
Ingo
Quoted 42 lines · Ingo Molnar
Quoted 30 lines · Stephane Eranian
This unified patch removes the following commits
for both kernel and perf tool:6adb0b0 perf tools: Add default handler for mmap2 events 384c671 perf trace: Add mmap2 handler
5c5e854 perf tools: Addattr->mmap2support d008d52 perf: Fix up MMAP2 buffer space reservation 13d7a24 perf: Addattr->mmap2attribute to an eventThe MMAP2 record extension is not quite ready for prime time. We have identified address space cases where mappings would not be reported properly when apps fiddled directly with
clone()andVM_CLONE. We will revisit the patch series soon.Signed-off-by Stephane Eranian <[email protected]>--- include/uapi/linux/perf_event.h | 24 +---------------- kernel/events/core.c | 47 +++----------------------------- tools/perf/builtin-annotate.c | 1 - tools/perf/builtin-inject.c | 15 ----------- tools/perf/builtin-mem.c | 1 - tools/perf/builtin-report.c | 1 - tools/perf/builtin-script.c | 1 - tools/perf/builtin-trace.c | 1 - tools/perf/tests/perf-record.c | 15 +++-------- tools/perf/util/build-id.c | 1 - tools/perf/util/event.c | 56 +++++++++------------------------------ tools/perf/util/event.h | 19 ------------- tools/perf/util/evsel.c | 16 +++--------Quoted 8 lines
tools/perf/util/header.c | 3 --- tools/perf/util/machine.c | 53 +----------------------------------- tools/perf/util/machine.h | 1 - tools/perf/util/map.c | 8 +----- tools/perf/util/map.h | 8 ++---- tools/perf/util/session.c | 27 +------------------ tools/perf/util/tool.h | 1 - 20 files changed, 30 insertions(+), 269 deletions(-)
Quoted 9 lines
Ugh, that's way too large.
I thought the plan was to do a minimal revert. Is there really no way to do this in a (much) shorter fashion?
For example by a simple patch that returns
-EINVAL(or-ENOSYS) if the new flag is used - i.e. behaves like the old kernel in that regard - but leaves the rest in place. (the 'rest' will hopefully be fixed for v3.13)
That's what I did in my initial revert patch. But it did not include the perf tool revert.
I believe in the end, we will still go with the extended MMAP record and not with the physical address (which adds a PERF_SAMPLE_*). So we can leave the attr->mmap2 bit defined and return -EINVAL for now.
As for the perf tool, we can remove everything and add that later on because the layout of the MMAP2 record may change.
Quoted 3 lines
Tooling will then fall back as if it was an old kernel - i.e. no changes needed there at all. Right?
Yes.
Quoted 7 lines · Stephane Eranian
Quoted 4 lines
For example by a simple patch that returns
-EINVAL(or-ENOSYS) if the new flag is used - i.e. behaves like the old kernel in that regard - but leaves the rest in place. (the 'rest' will hopefully be fixed for v3.13)That's what I did in my initial revert patch. But it did not include the perf tool revert.
Could the perf tool part have a minimal revert as well?
Quoted 3 lines
I believe in the end, we will still go with the extended MMAP record and not with the physical address (which adds a PERF_SAMPLE_*). So we can leave the
attr->mmap2bit defined and return-EINVALfor now.
Yeah.
Quoted 2 lines
As for the perf tool, we can remove everything and add that later on because the layout of the MMAP2 record may change.
Yes - but can we keep the actual revert patch minimal? I.e. just prevent mmap2 records from being generated, or so.
Thanks,
Ingo