diff mbox

[v2,10/14] perf, persistent: Avoid adding identical events

Message ID 1370968960-22527-11-git-send-email-rric@kernel.org
State New
Headers show

Commit Message

Robert Richter June 11, 2013, 4:42 p.m. UTC
From: Robert Richter <robert.richter@linaro.org>

Check if an event already exists before adding it.

Signed-off-by: Robert Richter <robert.richter@linaro.org>
Signed-off-by: Robert Richter <rric@kernel.org>
---
 kernel/events/persistent.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c
index 586cea5..4fcd071 100644
--- a/kernel/events/persistent.c
+++ b/kernel/events/persistent.c
@@ -40,6 +40,12 @@  add_persistent_event_on_cpu(unsigned int cpu, struct perf_event_attr *attr,
 
 	mutex_lock(&per_cpu(pers_events_lock, cpu));
 
+	desc = get_persistent_event(cpu, attr);
+	if (desc) {
+		event = ERR_PTR(-EEXIST);
+		goto out;
+	}
+
 	desc = kzalloc(sizeof(*desc), GFP_KERNEL);
 	if (!desc) {
 		event = ERR_PTR(-ENOMEM);