public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* __hw_perf_counter_init() on x86
@ 2009-09-09  6:49 David Miller
  2009-09-09  8:04 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2009-09-09  6:49 UTC (permalink / raw)
  To: mingo; +Cc: a.p.zijlstra, linux-kernel


It seems that for most of the error returns this function
can give, we'll leak the active_counters count grabbed
at the beginning of the function and therefore we'll never
re-enable the LAPIC NMI watchdog even once all the perf
counter users go away.

Just FYI...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: __hw_perf_counter_init() on x86
  2009-09-09  6:49 __hw_perf_counter_init() on x86 David Miller
@ 2009-09-09  8:04 ` Peter Zijlstra
  2009-09-09  8:30   ` David Miller
  2009-09-20 18:06   ` [tip:perfcounters/urgent] perf_counter: x86: Fix PMU resource leak tip-bot for Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Zijlstra @ 2009-09-09  8:04 UTC (permalink / raw)
  To: David Miller; +Cc: mingo, linux-kernel

On Tue, 2009-09-08 at 23:49 -0700, David Miller wrote:
> It seems that for most of the error returns this function
> can give, we'll leak the active_counters count grabbed
> at the beginning of the function and therefore we'll never
> re-enable the LAPIC NMI watchdog even once all the perf
> counter users go away.
> 
> Just FYI...

Thanks!

---
Subject: perf_counter: x86: Fix PMU resource leak

Dave noticed that we leak the PMU resource reservations when we fail the
hardware counter init.

Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 arch/x86/kernel/cpu/perf_counter.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index f9cd084..5224371 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
 	if (err)
 		return err;
 
+	counter->destroy = hw_perf_counter_destroy;
+
 	/*
 	 * Generate PMC IRQs:
 	 * (keep 'enabled' bit clear for now)
@@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
 			return -EOPNOTSUPP;
 	}
 
-	counter->destroy = hw_perf_counter_destroy;
-
 	/*
 	 * Raw event type provide the config in the event structure
 	 */
@@ -2093,8 +2093,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
 	int err;
 
 	err = __hw_perf_counter_init(counter);
-	if (err)
+	if (err) {
+		if (counter->destroy)
+			counter->destroy(counter);
 		return ERR_PTR(err);
+	}
 
 	return &pmu;
 }



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: __hw_perf_counter_init() on x86
  2009-09-09  8:04 ` Peter Zijlstra
@ 2009-09-09  8:30   ` David Miller
  2009-09-20 18:06   ` [tip:perfcounters/urgent] perf_counter: x86: Fix PMU resource leak tip-bot for Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2009-09-09  8:30 UTC (permalink / raw)
  To: a.p.zijlstra; +Cc: mingo, linux-kernel

From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Wed, 09 Sep 2009 10:04:47 +0200

> Subject: perf_counter: x86: Fix PMU resource leak
> 
> Dave noticed that we leak the PMU resource reservations when we fail the
> hardware counter init.
> 
> Reported-by: David Miller <davem@davemloft.net>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

Looks great.

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perfcounters/urgent] perf_counter: x86: Fix PMU resource leak
  2009-09-09  8:04 ` Peter Zijlstra
  2009-09-09  8:30   ` David Miller
@ 2009-09-20 18:06   ` tip-bot for Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-09-20 18:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo, davem

Commit-ID:  a1792cdacaf5180e04e07811e220c4a3b4a9c33e
Gitweb:     http://git.kernel.org/tip/a1792cdacaf5180e04e07811e220c4a3b4a9c33e
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Wed, 9 Sep 2009 10:04:47 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 20 Sep 2009 19:53:57 +0200

perf_counter: x86: Fix PMU resource leak

Dave noticed that we leak the PMU resource reservations when we
fail the hardware counter init.

Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: David Miller <davem@davemloft.net>
LKML-Reference: <1252483487.7746.164.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/cpu/perf_counter.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index dbdf712..a6c8b27 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
 	if (err)
 		return err;
 
+	counter->destroy = hw_perf_counter_destroy;
+
 	/*
 	 * Generate PMC IRQs:
 	 * (keep 'enabled' bit clear for now)
@@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
 			return -EOPNOTSUPP;
 	}
 
-	counter->destroy = hw_perf_counter_destroy;
-
 	/*
 	 * Raw event type provide the config in the event structure
 	 */
@@ -2107,8 +2107,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
 	int err;
 
 	err = __hw_perf_counter_init(counter);
-	if (err)
+	if (err) {
+		if (counter->destroy)
+			counter->destroy(counter);
 		return ERR_PTR(err);
+	}
 
 	return &pmu;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-20 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09  6:49 __hw_perf_counter_init() on x86 David Miller
2009-09-09  8:04 ` Peter Zijlstra
2009-09-09  8:30   ` David Miller
2009-09-20 18:06   ` [tip:perfcounters/urgent] perf_counter: x86: Fix PMU resource leak tip-bot for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox