Skip to contentSkip to conversation

perf_event: fix perf_swevent_hrtimer()

PATCH Superseded Xiao Guangrong 2 participants 7 messages Dec 10, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf_event: fix perf_swevent_hrtimer()

fix:
[<c0477471>] ? printk+0x1d/0x24
[<c01c98f9>] ? perf_prepare_sample+0x269/0x280

 [<c0149231>] warn_slowpath_common+0x71/0xd0
 [<c01c98f9>] ? perf_prepare_sample+0x269/0x280
 [<c01492aa>] warn_slowpath_null+0x1a/0x20
 [<c01c98f9>] perf_prepare_sample+0x269/0x280
 [<c016e9f3>] ? cpu_clock+0x53/0x90
 [<c01cc368>] __perf_event_overflow+0x2a8/0x300
 [<c01ccc3b>] perf_event_overflow+0x1b/0x30
 [<c01ccccf>] perf_swevent_hrtimer+0x7f/0x120

This is because 'data' variable not initialize.

---
 kernel/perf_event.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/perf_event.c +1 -1
index 0bd0f67..41c2dde 100644
@@ -4009,7 +4009,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 	event	= container_of(hrtimer, struct perf_event, hw.hrtimer);
 	event->pmu->read(event);
 
-	data.addr = 0;
+	memset(&data, 0, sizeof(data));
 	data.period = event->hw.last_period;
 	regs = get_irq_regs();
 	/*
Signature · 1 line
1.6.1.2
maintainer
#1 lore raw
Quoted 12 lines · Xiao Guangrong

fix:
[<c0477471>] ? printk+0x1d/0x24
[<c01c98f9>] ? perf_prepare_sample+0x269/0x280

 [<c0149231>] warn_slowpath_common+0x71/0xd0
 [<c01c98f9>] ? perf_prepare_sample+0x269/0x280
 [<c01492aa>] warn_slowpath_null+0x1a/0x20
 [<c01c98f9>] perf_prepare_sample+0x269/0x280
 [<c016e9f3>] ? cpu_clock+0x53/0x90
 [<c01cc368>] __perf_event_overflow+0x2a8/0x300
 [<c01ccc3b>] perf_event_overflow+0x1b/0x30
 [<c01ccccf>] perf_swevent_hrtimer+0x7f/0x120
Quoted 1 line

This is because 'data' variable not initialize.

Nope, please just initialize the missing variable. Which from a quick glance is data.raw.

Quoted 18 lines
---
 kernel/perf_event.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/perf_event.c +1 -1
index 0bd0f67..41c2dde 100644
@@ -4009,7 +4009,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 	event	= container_of(hrtimer, struct perf_event, hw.hrtimer);
 	event->pmu->read(event);
 
-	data.addr = 0;
+	memset(&data, 0, sizeof(data));
 	data.period = event->hw.last_period;
 	regs = get_irq_regs();
 	/*
#2 lore raw
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Xiao Guangrong

fix:
[<c0477471>] ? printk+0x1d/0x24
[<c01c98f9>] ? perf_prepare_sample+0x269/0x280

 [<c0149231>] warn_slowpath_common+0x71/0xd0
 [<c01c98f9>] ? perf_prepare_sample+0x269/0x280
 [<c01492aa>] warn_slowpath_null+0x1a/0x20
 [<c01c98f9>] perf_prepare_sample+0x269/0x280
 [<c016e9f3>] ? cpu_clock+0x53/0x90
 [<c01cc368>] __perf_event_overflow+0x2a8/0x300
 [<c01ccc3b>] perf_event_overflow+0x1b/0x30
 [<c01ccccf>] perf_swevent_hrtimer+0x7f/0x120
Quoted 3 lines
Quoted 1 line

This is because 'data' variable not initialize.

Nope, please just initialize the missing variable.

Ah, my mistake, I'll resend it.

Thanks,
Xiao

#3 lore raw

PATCH v2 1/1 perf_event: fix perf_swevent_hrtimer()

In reply to Peter Zijlstra

fix:
[<c0477471>] ? printk+0x1d/0x24
[<c01c98f9>] ? perf_prepare_sample+0x269/0x280

 [<c0149231>] warn_slowpath_common+0x71/0xd0
 [<c01c98f9>] ? perf_prepare_sample+0x269/0x280
 [<c01492aa>] warn_slowpath_null+0x1a/0x20
 [<c01c98f9>] perf_prepare_sample+0x269/0x280
 [<c016e9f3>] ? cpu_clock+0x53/0x90
 [<c01cc368>] __perf_event_overflow+0x2a8/0x300
 [<c01ccc3b>] perf_event_overflow+0x1b/0x30
 [<c01ccccf>] perf_swevent_hrtimer+0x7f/0x120

This is because 'data.raw' variable not initialize.

---
 kernel/perf_event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/perf_event.c +1 -0
index 0bd0f67..e63ba9a 100644
@@ -4010,6 +4010,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 	event->pmu->read(event);
 
 	data.addr = 0;
+	data.raw = NULL;
 	data.period = event->hw.last_period;
 	regs = get_irq_regs();
 	/*
Signature · 1 line
1.6.1.2
#4 lore raw

[tip:perf/urgent] perf_event: Fix perf_swevent_hrtimer() variable initialization

Commit-ID:  21140f4d3387aa2213f1deea0128df1dbf924379
Gitweb:     http://git.kernel.org/tip/21140f4d3387aa2213f1deea0128df1dbf924379
Author:     Xiao Guangrong <[email protected]>
AuthorDate: Thu, 10 Dec 2009 14:00:51 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 10 Dec 2009 07:11:05 +0100

perf_event: Fix perf_swevent_hrtimer() variable initialization

fix:

[<c0477471>] ? printk+0x1d/0x24
[<c01c98f9>] ? perf_prepare_sample+0x269/0x280

 [<c0149231>] warn_slowpath_common+0x71/0xd0
 [<c01c98f9>] ? perf_prepare_sample+0x269/0x280
 [<c01492aa>] warn_slowpath_null+0x1a/0x20
 [<c01c98f9>] perf_prepare_sample+0x269/0x280
 [<c016e9f3>] ? cpu_clock+0x53/0x90
 [<c01cc368>] __perf_event_overflow+0x2a8/0x300
 [<c01ccc3b>] perf_event_overflow+0x1b/0x30
 [<c01ccccf>] perf_swevent_hrtimer+0x7f/0x120

This is because 'data.raw' variable not initialize.

LKML-Reference: <[email protected]>

---
 kernel/perf_event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/perf_event.c +1 -0
index 94e1b28..3a5d6c4 100644
@@ -4010,6 +4010,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 	event->pmu->read(event);
 
 	data.addr = 0;
+	data.raw = NULL;
 	data.period = event->hw.last_period;
 	regs = get_irq_regs();
 	/*
#5 lore raw

PATCH 1/1 perf_event: fix variable initialization in other path

In reply to Peter Zijlstra

fix variable initialization in other path
[Commit-ID: 21140f4d3387aa2213f1deea0128df1dbf924379 is not clean]

---
 arch/x86/kernel/cpu/perf_event.c |    4 ++++
 kernel/perf_event.c              |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_event.c +4 -0
index d35f260..1342f23 100644
@@ -1632,6 +1632,7 @@ static void intel_pmu_drain_bts_buffer(struct cpu_hw_events *cpuc)
 
 	data.period	= event->hw.last_period;
 	data.addr	= 0;
+	data.raw	= NULL;
 	regs.ip		= 0;
 
 	/*
@@ -1749,6 +1750,7 @@ static int p6_pmu_handle_irq(struct pt_regs *regs)
 	u64 val;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
@@ -1794,6 +1796,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
 	u64 ack, status;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
@@ -1857,6 +1860,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
 	u64 val;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
kernel/perf_event.c +1 -0
index 41c2dde..6e2888d 100644
@@ -4299,6 +4299,7 @@ void perf_bp_event(struct perf_event *bp, void *data)
 	struct perf_sample_data sample;
 	struct pt_regs *regs = data;
 
+	sample.raw = NULL;
 	sample.addr = bp->attr.bp_addr;
 
 	if (!perf_exclude_event(bp, regs))
Signature · 1 line
1.6.1.2
#6 lore raw

[tip:perf/urgent] perf_event: Fix variable initialization in other codepaths

Commit-ID:  5e855db5d8fec44e6604eb245aa9077bbd3f0d05
Gitweb:     http://git.kernel.org/tip/5e855db5d8fec44e6604eb245aa9077bbd3f0d05
Author:     Xiao Guangrong <[email protected]>
AuthorDate: Thu, 10 Dec 2009 17:08:54 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 10 Dec 2009 17:23:02 +0100

perf_event: Fix variable initialization in other codepaths

Cc Peter Zijlstra <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Paul Mackerras <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/cpu/perf_event.c |    4 ++++
 kernel/perf_event.c              |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_event.c +4 -0
index d35f260..1342f23 100644
@@ -1632,6 +1632,7 @@ static void intel_pmu_drain_bts_buffer(struct cpu_hw_events *cpuc)
 
 	data.period	= event->hw.last_period;
 	data.addr	= 0;
+	data.raw	= NULL;
 	regs.ip		= 0;
 
 	/*
@@ -1749,6 +1750,7 @@ static int p6_pmu_handle_irq(struct pt_regs *regs)
 	u64 val;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
@@ -1794,6 +1796,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
 	u64 ack, status;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
@@ -1857,6 +1860,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
 	u64 val;
 
 	data.addr = 0;
+	data.raw = NULL;
 
 	cpuc = &__get_cpu_var(cpu_hw_events);
 
kernel/perf_event.c +1 -0
index 3a5d6c4..d891ec4 100644
@@ -4300,6 +4300,7 @@ void perf_bp_event(struct perf_event *bp, void *data)
 	struct perf_sample_data sample;
 	struct pt_regs *regs = data;
 
+	sample.raw = NULL;
 	sample.addr = bp->attr.bp_addr;
 
 	if (!perf_exclude_event(bp, regs))