From patchwork Thu Aug 22 14:13:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 19419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f199.google.com (mail-gh0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C035248E6 for ; Thu, 22 Aug 2013 14:22:16 +0000 (UTC) Received: by mail-gh0-f199.google.com with SMTP id g14sf1539823ghb.2 for ; Thu, 22 Aug 2013 07:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:delivered-to:sender:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=4SSVlIWk+HHvgNG7rBhTNgRceu5eNRQq7nXdr0xmYvs=; b=DXRwe3rE2Q+bEwV4k6uTG5ELONM87KMzt1s4QA8cSnLd1HHGyEl4lyn4jzc0X6Hom/ Q4fZ8utUzFyhsnD9OG/1a59XJE8xuXbT6iEjWlGAyTS/MttiRnuD4CUp8bC/pabj+K55 TLyGStNi68i+AWSPiAJkbTNv9ahZeUowQ8McDUQot43DEckba23qEObaez4CLjusuI3/ 3xyvTb+3c2RQZD88tQ2h1RHKjfKV1nqK0VuEA/CtxlhayslEnTZmaNEIjBE/a298aVhs M4k/5aEtswjs4u1tQQ+3R3d4ony9MZh2oFYBBAGY+BOMzXh6BW45C1a+Shibp9eGw9Vg Empg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:sender:from:to:cc :subject:date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=4SSVlIWk+HHvgNG7rBhTNgRceu5eNRQq7nXdr0xmYvs=; b=B7cOZ4bRoXRzcRzQpJa2FolrZRECgKAas9aPozPM89JuqZFhYFtDNZqYsKODqBHuPK CGPioZJ64GK73jsVbjUONCmBH7cFZ/g9Pw6ClDSsRSD+BmfAs+ibCO5X2UKdrv5AadcP gdRu+oo50rhD2cdqYdEPxz5iKMKwSIyfxYv7u2lmT/h3BMIeC5b9vuDIOimel/Eu0Q4k UG6fjaKuBWpB8d6cJDBE1os5wbyXDw4TgrFo3xmTVV85MmH/edp01lJRuNSIM4JByjPE xA1s1qArlKBPWibCgTTahnbunjfpqQjH2pDv3D2BTp/8RF7qJbeOsxj0Yel7MZbPkqUO 6/Gw== X-Received: by 10.224.4.138 with SMTP id 10mr13058602qar.8.1377181335349; Thu, 22 Aug 2013 07:22:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.75.228 with SMTP id f4ls1115165qew.12.gmail; Thu, 22 Aug 2013 07:22:15 -0700 (PDT) X-Received: by 10.220.74.69 with SMTP id t5mr11927554vcj.18.1377181335220; Thu, 22 Aug 2013 07:22:15 -0700 (PDT) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id i15si4020679vep.92.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:22:15 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22d; Received: by mail-ve0-f173.google.com with SMTP id cy12so1529792veb.4 for ; Thu, 22 Aug 2013 07:22:15 -0700 (PDT) X-Gm-Message-State: ALoCoQkt3PxJrYY1JeIZClkWwTZYyHibnIccTGks/QM/FLSTFXK40gEBgPody5Cbxl1CVHy0hwx7 X-Received: by 10.58.237.105 with SMTP id vb9mr11705643vec.2.1377180883094; Thu, 22 Aug 2013 07:14:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp33206vcz; Thu, 22 Aug 2013 07:14:42 -0700 (PDT) X-Received: by 10.204.64.78 with SMTP id d14mr2108210bki.40.1377180882010; Thu, 22 Aug 2013 07:14:42 -0700 (PDT) Received: from mail-bk0-x236.google.com (mail-bk0-x236.google.com [2a00:1450:4008:c01::236]) by mx.google.com with ESMTPS id ki1si2303983bkb.187.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:14:41 -0700 (PDT) Received-SPF: pass (google.com: domain of rric.net@gmail.com designates 2a00:1450:4008:c01::236 as permitted sender) client-ip=2a00:1450:4008:c01::236; Received: by mail-bk0-f54.google.com with SMTP id mz12so720011bkb.27 for ; Thu, 22 Aug 2013 07:14:41 -0700 (PDT) X-Received: by 10.205.22.138 with SMTP id qw10mr2394022bkb.29.1377180881021; Thu, 22 Aug 2013 07:14:41 -0700 (PDT) Received: from rric.localhost (g224195237.adsl.alicedsl.de. [92.224.195.237]) by mx.google.com with ESMTPSA id jh13sm3079991bkb.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:14:40 -0700 (PDT) Sender: Robert Richter From: Robert Richter To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Borislav Petkov , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter , Robert Richter Subject: [PATCH v3 04/12] perf, mmap: Factor out perf_get_fd() Date: Thu, 22 Aug 2013 16:13:19 +0200 Message-Id: <1377180807-12758-5-git-send-email-rric@kernel.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1377180807-12758-1-git-send-email-rric@kernel.org> References: <1377180807-12758-1-git-send-email-rric@kernel.org> X-Original-Sender: rric.net@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gmail.com Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Robert Richter This new function creates a new fd for an event. We need this later to get a fd from a persistent event. Signed-off-by: Robert Richter Signed-off-by: Robert Richter --- kernel/events/core.c | 13 ++++++++----- kernel/events/internal.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 24810d5..932acc6 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4100,6 +4100,11 @@ static const struct file_operations perf_fops = { .fasync = perf_fasync, }; +int perf_get_fd(struct perf_event *event) +{ + return anon_inode_getfd("[perf_event]", &perf_fops, event, O_RDWR); +} + /* * Perf event wakeup * @@ -6868,7 +6873,6 @@ SYSCALL_DEFINE5(perf_event_open, struct perf_event *event, *sibling; struct perf_event_attr attr; struct perf_event_context *ctx; - struct file *event_file = NULL; struct fd group = {NULL, 0}; struct task_struct *task = NULL; struct pmu *pmu; @@ -7025,9 +7029,9 @@ SYSCALL_DEFINE5(perf_event_open, goto err_context; } - event_file = anon_inode_getfile("[perf_event]", &perf_fops, event, O_RDWR); - if (IS_ERR(event_file)) { - err = PTR_ERR(event_file); + event_fd = perf_get_fd(event); + if (event_fd < 0) { + err = event_fd; goto err_context; } @@ -7093,7 +7097,6 @@ SYSCALL_DEFINE5(perf_event_open, * perf_group_detach(). */ fdput(group); - fd_install(event_fd, event_file); return event_fd; err_context: diff --git a/kernel/events/internal.h b/kernel/events/internal.h index 8ddaf57..d8708aa 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h @@ -192,5 +192,6 @@ static inline void put_event(struct perf_event *event) extern int perf_alloc_rb(struct perf_event *event, int nr_pages, int flags); extern void perf_free_rb(struct perf_event *event); +extern int perf_get_fd(struct perf_event *event); #endif /* _KERNEL_EVENTS_INTERNAL_H */