lkml.org 
[lkml]   [2013]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 12/16] perf, persistent: Avoid adding identical events
Date
From: Robert Richter <robert.richter@calxeda.com>

Check if an event already exists before adding it.

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

diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c
index ebef089..1e93b51 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);
--
1.8.1.1


\
 
 \ /
  Last update: 2013-06-01 02:21    [W:0.266 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site