Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc1d628a authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

perf: Provide generic perf_sample_data initialization



This makes it easier to extend perf_sample_data and fixes a bug on arm
and sparc, which failed to set ->raw to NULL, which can cause crashes
when combined with PERF_SAMPLE_RAW.

It also optimizes PowerPC and tracepoint, because the struct
initialization is forced to zero out the whole structure.

Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: default avatarJean Pihet <jpihet@mvista.com>
Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: Jamie Iles <jamie.iles@picochip.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: stable@kernel.org
LKML-Reference: <20100304140100.315416040@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 548b8416
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -965,7 +965,7 @@ armv6pmu_handle_irq(int irq_num,
	 */
	armv6_pmcr_write(pmcr);

	data.addr = 0;
	perf_sample_data_init(&data, 0);

	cpuc = &__get_cpu_var(cpu_hw_events);
	for (idx = 0; idx <= armpmu->num_events; ++idx) {
@@ -1945,7 +1945,7 @@ static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
	 */
	regs = get_irq_regs();

	data.addr = 0;
	perf_sample_data_init(&data, 0);

	cpuc = &__get_cpu_var(cpu_hw_events);
	for (idx = 0; idx <= armpmu->num_events; ++idx) {
+4 −4
Original line number Diff line number Diff line
@@ -1164,10 +1164,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
	 * Finally record data if requested.
	 */
	if (record) {
		struct perf_sample_data data = {
			.addr	= ~0ULL,
			.period	= event->hw.last_period,
		};
		struct perf_sample_data data;

		perf_sample_data_init(&data, ~0ULL);
		data.period = event->hw.last_period;

		if (event->attr.sample_type & PERF_SAMPLE_ADDR)
			perf_get_data_addr(regs, &data.addr);
+1 −1
Original line number Diff line number Diff line
@@ -1189,7 +1189,7 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,

	regs = args->regs;

	data.addr = 0;
	perf_sample_data_init(&data, 0);

	cpuc = &__get_cpu_var(cpu_hw_events);

+1 −2
Original line number Diff line number Diff line
@@ -1097,8 +1097,7 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
	int idx, handled = 0;
	u64 val;

	data.addr = 0;
	data.raw = NULL;
	perf_sample_data_init(&data, 0);

	cpuc = &__get_cpu_var(cpu_hw_events);

+2 −4
Original line number Diff line number Diff line
@@ -590,10 +590,9 @@ static void intel_pmu_drain_bts_buffer(void)

	ds->bts_index = ds->bts_buffer_base;

	perf_sample_data_init(&data, 0);

	data.period	= event->hw.last_period;
	data.addr	= 0;
	data.raw	= NULL;
	regs.ip		= 0;

	/*
@@ -742,8 +741,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
	int bit, loops;
	u64 ack, status;

	data.addr = 0;
	data.raw = NULL;
	perf_sample_data_init(&data, 0);

	cpuc = &__get_cpu_var(cpu_hw_events);

Loading