lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181031130138.GA13216@krava>
Date:   Wed, 31 Oct 2018 14:01:38 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     David Miller <davem@...emloft.net>
Cc:     acme@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: Don't clone maps from parent when synthesizing
 forks

On Tue, Oct 30, 2018 at 10:24:04PM -0700, David Miller wrote:

SNIP

> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 111ae858cbcb..214b7979c4e7 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -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)
> @@ -1737,8 +1738,11 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
>  	thread = machine__findnew_thread(machine, event->fork.pid,
>  					 event->fork.tid);
>  
> +	if (event->fork.header.misc & PERF_RECORD_MISC_FORK_EXEC)
> +		do_maps_clone = false;

could you please put some comment in here shortly
explaining the reason behind this flag

> +
>  	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;
>  	}
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index 2048d393ece6..54b2c9ceba9f 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -330,7 +330,8 @@ static int thread__prepare_access(struct thread *thread)
>  }
>  
>  static int thread__clone_map_groups(struct thread *thread,
> -				    struct thread *parent)
> +				    struct thread *parent,
> +				    bool do_maps_clone)
>  {
>  	/* This is new thread, we share map groups for process. */
>  	if (thread->pid_ == parent->pid_)
> @@ -341,15 +342,14 @@ static int thread__clone_map_groups(struct thread *thread,
>  			 thread->pid_, thread->tid, parent->pid_, parent->tid);
>  		return 0;
>  	}
> -
>  	/* But this one is new process, copy maps. */
> -	if (map_groups__clone(thread, parent->mg) < 0)
> +	if (do_maps_clone &&
> +	    map_groups__clone(thread, parent->mg) < 0)
>  		return -ENOMEM;
> -
>  	return 0;

we could move all this into one line:

	return do_maps_clone ? map_groups__clone(thread, parent->mg) : 0;

thanks,
jirka

>  }
>  
> -int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
> +int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone)
>  {
>  	if (parent->comm_set) {
>  		const char *comm = thread__comm_str(parent);
> @@ -362,7 +362,7 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
>  	}
>  
>  	thread->ppid = parent->tid;
> -	return thread__clone_map_groups(thread, parent);
> +	return thread__clone_map_groups(thread, parent, do_maps_clone);
>  }
>  
>  void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
> diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
> index 07606aa6998d..7e30fe99b74b 100644
> --- a/tools/perf/util/thread.h
> +++ b/tools/perf/util/thread.h
> @@ -87,7 +87,7 @@ struct comm *thread__comm(const struct thread *thread);
>  struct comm *thread__exec_comm(const struct thread *thread);
>  const char *thread__comm_str(const struct thread *thread);
>  int thread__insert_map(struct thread *thread, struct map *map);
> -int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
> +int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone);
>  size_t thread__fprintf(struct thread *thread, FILE *fp);
>  
>  struct thread *thread__main_thread(struct machine *machine, struct thread *thread);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ