Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754668Ab3EaIuO (ORCPT ); Fri, 31 May 2013 04:50:14 -0400 Received: from mail-we0-f175.google.com ([74.125.82.175]:39217 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754225Ab3EaIs3 (ORCPT ); Fri, 31 May 2013 04:48:29 -0400 From: Robert Richter To: Borislav Petkov Cc: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Robert Richter Subject: [PATCH 12/16] perf, persistent: Avoid adding identical events Date: Fri, 31 May 2013 10:47:32 +0200 Message-Id: <1369990056-10310-13-git-send-email-rric@kernel.org> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1369990056-10310-1-git-send-email-rric@kernel.org> References: <1369990056-10310-1-git-send-email-rric@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1001 Lines: 34 From: Robert Richter Check if an event already exists before adding it. Signed-off-by: Robert Richter --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/