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: <20180917112615.GB18395@sejong>
Date:   Mon, 17 Sep 2018 20:26:15 +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 37/48] perf record: Introduce struct record_thread

Hi Jiri,

On Thu, Sep 13, 2018 at 02:54:39PM +0200, Jiri Olsa wrote:
> Adding struct record_thread to carry the single thread's maps.
> 
> Link: http://lkml.kernel.org/n/tip-dsyi97xdc7ullvsisqmha0ca@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/perf/builtin-record.c | 179 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 179 insertions(+)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 1b01cb4d06b8..5c6b56f164a9 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -65,6 +65,15 @@ struct switch_output {
>  	bool		 set;
>  };
>  
> +struct record_thread {
> +	struct perf_mmap	**mmap;
> +	int			  mmap_nr;
> +	struct perf_mmap	**ovw_mmap;
> +	int			  ovw_mmap_nr;
> +	struct fdarray		  pollfd;
> +	struct record		 *rec;
> +};
> +
>  struct record {
>  	struct perf_tool	tool;
>  	struct record_opts	opts;
> @@ -83,6 +92,8 @@ struct record {
>  	bool			timestamp_boundary;
>  	struct switch_output	switch_output;
>  	unsigned long long	samples;
> +	struct record_thread	*threads;
> +	int			threads_cnt;
>  };
>  
>  static volatile int auxtrace_record__snapshot_started;
> @@ -967,6 +978,166 @@ static int record__synthesize(struct record *rec, bool tail)
>  	return err;
>  }
>  
> +static void
> +record_thread__clean(struct record_thread *th)
> +{
> +	free(th->mmap);
> +	free(th->ovw_mmap);
> +}
> +
> +static void
> +record__threads_clean(struct record *rec)
> +{
> +	struct record_thread *threads = rec->threads;
> +	int i;
> +
> +	if (threads) {
> +		for (i = 0; i < rec->threads_cnt; i++)
> +			record_thread__clean(threads + i);
> +	}
> +}
> +
> +static void record_thread__init(struct record_thread *th, struct record *rec)
> +{
> +	memset(th, 0, sizeof(*th));
> +	fdarray__init(&th->pollfd, 64);
> +	th->rec = rec;
> +}
> +
> +static int
> +record_thread__mmap(struct record_thread *th, int nr, int nr_ovw)
> +{
> +	struct perf_mmap **mmap;
> +
> +	mmap = zalloc(sizeof(*mmap) * nr);
> +	if (!mmap)
> +		return -ENOMEM;
> +
> +	th->mmap    = mmap;
> +	th->mmap_nr = nr;
> +
> +	if (nr_ovw) {
> +		mmap = zalloc(sizeof(*mmap) * nr_ovw);
> +		if (!mmap)
> +			return -ENOMEM;
> +
> +		th->ovw_mmap    = mmap;
> +		th->ovw_mmap_nr = nr;

s/nr;/nr_ovw;/ ?


> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +record__threads_assign(struct record *rec)
> +{
> +	struct record_thread *threads = rec->threads;
> +	struct record_thread *thread0 = threads;
> +	struct perf_evlist *evlist = rec->evlist;
> +	int i, j, nr, nr0, nr_ovw, nr_trk;
> +	int ret = -ENOMEM;
> +
> +	nr     = evlist->mmap           ? evlist->nr_mmaps : 0;
> +	nr_trk = evlist->track_mmap     ? evlist->nr_mmaps : 0;
> +	nr_ovw = evlist->overwrite_mmap ? evlist->nr_mmaps : 0;
> +
> +	nr0  = nr_trk;
> +	nr0 += nr;
> +
> +	if (record_thread__mmap(thread0, nr0, nr_ovw))
> +		goto out_error;
> +
> +	for (i = 0; i < nr_ovw; i++)
> +		thread0->ovw_mmap[i] = &evlist->overwrite_mmap[i];
> +
> +	for (i = 0; i < nr_trk; i++)
> +		thread0->mmap[i] = &evlist->track_mmap[i];
> +
> +	for (j = 0; i < nr0 && j < nr; i++, j++)
> +		thread0->mmap[i] = &evlist->mmap[j];

I'm not sure it'll work with the overwrite mmap well..

Thanks,
Namhyung


> +
> +	ret = 0;
> +
> +out_error:
> +	return ret;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ