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: <20180917112837.GC18395@sejong>
Date:   Mon, 17 Sep 2018 20:28:37 +0900
From:   Namhyung Kim <namhyung@...nel.org>
To:     Jiri Olsa <jolsa@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Andi Kleen <andi@...stfloor.org>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        kernel-team@....com
Subject: Re: [PATCH 38/48] perf record: Read record thread's mmaps

On Thu, Sep 13, 2018 at 02:54:40PM +0200, Jiri Olsa wrote:
> Switch the maps source from evlist into thread data.
> 
> Link: http://lkml.kernel.org/n/tip-2r6hn6shl185j66b4vl1k4pr@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/perf/builtin-record.c | 37 ++++++++++++++++++++-----------------
>  1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 5c6b56f164a9..d6fef646b67f 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -96,6 +96,8 @@ struct record {
>  	int			threads_cnt;
>  };
>  
> +static __thread struct record_thread *thread;
> +
>  static volatile int auxtrace_record__snapshot_started;
>  static DEFINE_TRIGGER(auxtrace_snapshot_trigger);
>  static DEFINE_TRIGGER(switch_output_trigger);
> @@ -561,24 +563,24 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
>  				    bool overwrite)
>  {
>  	u64 bytes_written = rec->bytes_written;
> -	int i;
> +	int i, nr;
>  	int rc = 0;
> -	struct perf_mmap *maps;
> +	struct perf_mmap **maps;
>  
>  	if (!evlist)
>  		return 0;
>  
> -	maps = overwrite ? evlist->overwrite_mmap : evlist->mmap;
> +	maps = overwrite ? thread->ovw_mmap : thread->mmap;
>  	if (!maps)
>  		return 0;
>  
>  	if (overwrite && evlist->bkw_mmap_state != BKW_MMAP_DATA_PENDING)
>  		return 0;
>  
> -	for (i = 0; i < evlist->nr_mmaps; i++) {
> -		struct perf_mmap *map = &maps[i];
> -		struct perf_mmap *track_map =  evlist->track_mmap ?
> -					      &evlist->track_mmap[i] : NULL;
> +	nr = overwrite ? thread->ovw_mmap_nr : thread->mmap_nr;
> +
> +	for (i = 0; i < nr; i++) {
> +		struct perf_mmap *map = maps[i];
>  
>  		if (map->base) {
>  			if (perf_mmap__push(map, rec, record__pushfn) != 0) {
> @@ -592,21 +594,20 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
>  			rc = -1;
>  			goto out;
>  		}
> -
> -		if (track_map && track_map->base) {
> -			if (perf_mmap__push(track_map, rec, record__pushfn) != 0) {
> -				rc = -1;
> -				goto out;
> -			}
> -		}
>  	}
>  
>  	/*
>  	 * Mark the round finished in case we wrote
>  	 * at least one event.
>  	 */
> -	if (bytes_written != rec->bytes_written)
> -		rc = record__write(rec, NULL, &finished_round_event, sizeof(finished_round_event));
> +	if (bytes_written != rec->bytes_written) {
> +		/*
> +		 * All maps of the threads point to a single file,
> +		 * so we can just pick first one.
> +		 */
> +		rc = record__write(rec, thread->mmap[0], &finished_round_event,

Shouldn't it be maps[0] ?

Thanks,
Namhyung


> +				   sizeof(finished_round_event));
> +	}
>  
>  	if (overwrite)
>  		perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY);
> @@ -1222,6 +1223,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>  			goto out_child;
>  	}
>  
> +	thread = &rec->threads[0];
> +
>  	err = bpf__apply_obj_config();
>  	if (err) {
>  		char errbuf[BUFSIZ];
> @@ -1415,7 +1418,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>  		if (hits == rec->samples) {
>  			if (done || draining)
>  				break;
> -			err = perf_evlist__poll(rec->evlist, -1);
> +			err = fdarray__poll(&thread->pollfd, -1);
>  			/*
>  			 * Propagate error, only if there's any. Ignore positive
>  			 * number of returned events and interrupt error.
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ