mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
perf tools: Don't clone maps from parent when synthesizing forks
When synthesizing FORK events, we are trying to create thread objects for the already running tasks on the machine. Normally, for a kernel FORK event, we want to clone the parent's maps because that is what the kernel just did. But when synthesizing, this should not be done. If we do, we end up with overlapping maps as we process the sythesized MMAP2 events that get delivered shortly thereafter. Use the FORK event misc flags in an internal way to signal this situation, so we can elide the map clone when appropriate. Signed-off-by: David S. Miller <davem@davemloft.net> Cc: Don Zickus <dzickus@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joe Mario <jmario@redhat.com> Link: http://lkml.kernel.org/r/20181030.222404.2085088822877051075.davem@davemloft.net [ Added comment about flag use in machine__process_fork_event(), use ternary op in thread__clone_map_groups() as suggested by Jiri ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
ff27a06af6
commit
4f8f382e63
6 changed files with 29 additions and 10 deletions
|
@ -1708,6 +1708,7 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
|
|||
struct thread *parent = machine__findnew_thread(machine,
|
||||
event->fork.ppid,
|
||||
event->fork.ptid);
|
||||
bool do_maps_clone = true;
|
||||
int err = 0;
|
||||
|
||||
if (dump_trace)
|
||||
|
@ -1736,9 +1737,25 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
|
|||
|
||||
thread = machine__findnew_thread(machine, event->fork.pid,
|
||||
event->fork.tid);
|
||||
/*
|
||||
* When synthesizing FORK events, we are trying to create thread
|
||||
* objects for the already running tasks on the machine.
|
||||
*
|
||||
* Normally, for a kernel FORK event, we want to clone the parent's
|
||||
* maps because that is what the kernel just did.
|
||||
*
|
||||
* But when synthesizing, this should not be done. If we do, we end up
|
||||
* with overlapping maps as we process the sythesized MMAP2 events that
|
||||
* get delivered shortly thereafter.
|
||||
*
|
||||
* Use the FORK event misc flags in an internal way to signal this
|
||||
* situation, so we can elide the map clone when appropriate.
|
||||
*/
|
||||
if (event->fork.header.misc & PERF_RECORD_MISC_FORK_EXEC)
|
||||
do_maps_clone = false;
|
||||
|
||||
if (thread == NULL || parent == NULL ||
|
||||
thread__fork(thread, parent, sample->time) < 0) {
|
||||
thread__fork(thread, parent, sample->time, do_maps_clone) < 0) {
|
||||
dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
|
||||
err = -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue