2009-12-10 04:16:19

by Xiao Guangrong

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Xiao Guangrong <[email protected]>
---
kernel/perf_event.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 0bd0f67..41c2dde 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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();
/*
--
1.6.1.2


2009-12-10 05:14:05

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] perf_event: fix perf_swevent_hrtimer()

On Thu, 2009-12-10 at 12:14 +0800, Xiao Guangrong wrote:
> 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.

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

> Signed-off-by: Xiao Guangrong <[email protected]>
> ---
> kernel/perf_event.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 0bd0f67..41c2dde 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -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();
> /*

2009-12-10 05:26:06

by Xiao Guangrong

[permalink] [raw]
Subject: Re: [PATCH] perf_event: fix perf_swevent_hrtimer()



Peter Zijlstra wrote:
> On Thu, 2009-12-10 at 12:14 +0800, Xiao Guangrong wrote:
>> 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.
>
> Nope, please just initialize the missing variable.

Ah, my mistake, I'll resend it.

Thanks,
Xiao

2009-12-10 06:02:28

by Xiao Guangrong

[permalink] [raw]
Subject: [PATCH v2] 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.raw' variable not initialize.

Signed-off-by: Xiao Guangrong <[email protected]>
---
kernel/perf_event.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 0bd0f67..e63ba9a 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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();
/*
--
1.6.1.2

2009-12-10 06:19:17

by Xiao Guangrong

[permalink] [raw]
Subject: [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.

Signed-off-by: Xiao Guangrong <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/perf_event.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 94e1b28..3a5d6c4 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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();
/*

2009-12-10 09:10:39

by Xiao Guangrong

[permalink] [raw]
Subject: [PATCH] perf_event: fix variable initialization in other path

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

Signed-off-by: Xiao Guangrong <[email protected]>
---
arch/x86/kernel/cpu/perf_event.c | 4 ++++
kernel/perf_event.c | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index d35f260..1342f23 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -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);

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 41c2dde..6e2888d 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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))
--
1.6.1.2

2009-12-10 16:25:12

by Xiao Guangrong

[permalink] [raw]
Subject: [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

Signed-off-by: Xiao Guangrong <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/cpu/perf_event.c | 4 ++++
kernel/perf_event.c | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index d35f260..1342f23 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -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);

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 3a5d6c4..d891ec4 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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))