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: <20130515212052.GA5814@krava.redhat.com>
Date:	Wed, 15 May 2013 23:20:52 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Namhyung Kim <namhyung@...nel.org>
Cc:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...nel.org>,
	Namhyung Kim <namhyung.kim@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	David Ahern <dsahern@...il.com>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 09/15] perf ftrace: Add 'record' sub-command

On Tue, May 14, 2013 at 07:13:53PM +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@....com>
> 
> The ftrace record command is for saving raw ftrace buffer contents
> which can be get from per_cpu/cpuX/trace_pipe_raw.
> 
> Since ftrace events are generated very frequently so single thread for
> recording mostly resulted in buffer overruns.  Thus it uses per-cpu
> recorder thread to prevent such cases and they save the contents to
> their own files.
> 

SNIP

> +
> +	/* synthesize sample data */
> +	list_for_each_entry(fra, &recorders, node) {
> +		struct perf_evsel *evsel = perf_evlist__first(ftrace->evlist);
> +		union perf_event event = {
> +			.sample = {
> +				.header = {
> +					.type = PERF_RECORD_SAMPLE,
> +					.misc = PERF_RECORD_MISC_KERNEL,
> +					.size = sizeof(event.sample.header) +
> +						evsel->sample_size,
> +				},
> +			},
> +		};
> +		struct perf_sample sample = {
> +			.cpu = fra->cpu,
> +			.period = 1,
> +		};
> +		void *raw_data;
> +		u32 raw_size;
> +		int orig_size;
> +
> +		if (fra->state != RECORD_STATE__DONE) {
> +			pr_warning("recorder failed for some reason on cpu%d\n",
> +				   fra->cpu);
> +			continue;
> +		}
> +
> +		perf_event__synthesize_sample(&event, evsel->attr.sample_type,
> +					      &sample, false);
> +
> +		raw_data = synthesize_raw_data(evsel);
> +		if (raw_data == NULL) {
> +			pr_err("synthesizing raw sample failed\n");
> +			goto out_fra;
> +		}
> +
> +		/*
> +		 * start of raw data is the size of raw data excluding itself.
> +		 */
> +		raw_size = sizeof(u32) + (*(u32 *) raw_data);
> +
> +		orig_size = event.sample.header.size;
> +		event.sample.header.size += raw_size;
> +
> +		err = write(perf_fd, &event.sample, orig_size);
> +		if (err != orig_size) {
> +			pr_err("write error occurred\n");
> +			goto out_fra;
> +		}
> +
> +		err = write(perf_fd, raw_data, raw_size);
> +		if (err != (int)raw_size) {
> +			pr_err("write error occurred\n");
> +			goto out_fra;
> +		}

missing free(raw_data) ?

jirka

> +
> +		session->header.data_size += event.sample.header.size;
> +	}
> +
> +	perf_session__write_header(session, ftrace->evlist, perf_fd, true);
> +
> +out_fra:
> +	list_for_each_entry_safe(fra, tmp, &recorders, node) {
> +		list_del(&fra->node);
> +		free(fra);
> +	}
> +out_session:
> +	free(session);
> +out_close:
> +	close(perf_fd);
> +out_reset:
> +	reset_tracing_files(ftrace);
>  	return done ? 0 : -1;
>  }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ