mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf/core: Avoid removing shared pmu_context on unregister
@ 2017-05-12 10:40 Chris Wilson
  2017-05-12 11:42 ` Chris Wilson
  2017-05-12 11:45 ` [PATCH v2] " Chris Wilson
  0 siblings, 2 replies; 8+ messages in thread
From: Chris Wilson @ 2017-05-12 10:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Wilson, David Carrillo-Cisneros, Peter Zijlstra,
	Ingo Molnar, # v4 . 11+

In commit 1fd7e4169954 ("perf/core: Remove perf_cpu_context::unique_pmu"),
the search for another user of the pmu_cpu_context was removed, and so
we unconditionally free it during perf_pmu_unregister. This leads to
random corruption later and a BUG at mm/percpu.c:689.

Fixes: 1fd7e4169954 ("perf/core: Remove perf_cpu_context::unique_pmu")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: David Carrillo-Cisneros <davidcc@google.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: <stable@vger.kernel.org> # v4.11+
---
 kernel/events/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index aaefaa27e1a6..e62b6207925c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9005,7 +9005,8 @@ void perf_pmu_unregister(struct pmu *pmu)
 		device_del(pmu->dev);
 		put_device(pmu->dev);
 	}
-	free_pmu_context(pmu);
+	if (!find_pmu_context(pmu->task_ctx_nr))
+		free_pmu_context(pmu);
 }
 EXPORT_SYMBOL_GPL(perf_pmu_unregister);
 
-- 
2.11.0

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

end of thread, other threads:[~2018-09-21 13:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12 10:40 [PATCH] perf/core: Avoid removing shared pmu_context on unregister Chris Wilson
2017-05-12 11:42 ` Chris Wilson
2017-05-12 11:45 ` [PATCH v2] " Chris Wilson
2017-05-12 20:40   ` David Carrillo-Cisneros
2017-05-12 20:41     ` David Carrillo-Cisneros
2017-05-12 20:52     ` Chris Wilson
2017-05-12 21:26       ` David Carrillo-Cisneros
2018-09-21 13:26   ` Peter Zijlstra

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

all inboxes | Powered by JetHome®