From patchwork Mon Apr 7 15:04:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 27911 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8DBBC20490 for ; Mon, 7 Apr 2014 15:10:19 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf27873880obc.2 for ; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=vIMcpTTbXKXOxt/DX+S6A1ffTMoIGsiui/76zQTUHto=; b=lbUr3pGOyNFFIh4KQ5x7t9Q4pY7+Ay89P3hQKnIBwkUvyYuVYEfbF2kAA7Sz0gJOqv Ek1dSYV/zzs5T5gdlyWabaL8nfRmQqxAMv/wpvRTy+n7qWADLhKy/Mra9iywMO4Cd4cN nmxUxG7JmjLDvAuZ2KoC24CER/vcEuVGKmarVs5O4PZmCZwtvB8A0GrlSfY7NdnAE/I3 h8GUvlzzdbLF/hsdDEVz0yMfo9uQ5BczpVUFiaMDQugkS+vQ6/a48HhGw+hrKgkSnVhC 11hYxg+DFx2rw/piHgftFHj7WYqIfuSHcEY/N3l95m4M9LAgLvSQ/1bTxcgGJsGiKevn +e+w== X-Gm-Message-State: ALoCoQnhCgyJxL7NKNRDeziAbAvmr+oymQaHJ7MUXVZsVzcnC+BWBXe6I6BbLtlEXD67VIfula5B X-Received: by 10.43.141.196 with SMTP id jf4mr15634145icc.9.1396883418822; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.100 with SMTP id u91ls1692895qgu.74.gmail; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) X-Received: by 10.220.4.132 with SMTP id 4mr19583534vcr.9.1396883418727; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id sk2si3167639vcb.198.2014.04.07.08.10.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 08:10:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so3772488veb.27 for ; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) X-Received: by 10.52.119.178 with SMTP id kv18mr524173vdb.39.1396883418622; Mon, 07 Apr 2014 08:10:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp170029vcv; Mon, 7 Apr 2014 08:10:18 -0700 (PDT) X-Received: by 10.68.113.194 with SMTP id ja2mr31698956pbb.30.1396883417662; Mon, 07 Apr 2014 08:10:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id eg2si8478801pac.469.2014.04.07.08.10.16; Mon, 07 Apr 2014 08:10:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755725AbaDGPKI (ORCPT + 27 others); Mon, 7 Apr 2014 11:10:08 -0400 Received: from mail-ee0-f50.google.com ([74.125.83.50]:63215 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755137AbaDGPFE (ORCPT ); Mon, 7 Apr 2014 11:05:04 -0400 Received: by mail-ee0-f50.google.com with SMTP id c13so742947eek.37 for ; Mon, 07 Apr 2014 08:05:03 -0700 (PDT) X-Received: by 10.14.215.9 with SMTP id d9mr3320267eep.64.1396883103090; Mon, 07 Apr 2014 08:05:03 -0700 (PDT) Received: from localhost.localdomain (201-179-62-37.mobileinternet.proximus.be. [37.62.179.201]) by mx.google.com with ESMTPSA id o4sm42287649eef.20.2014.04.07.08.05.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Apr 2014 08:05:02 -0700 (PDT) From: Jean Pihet To: Borislav Petkov , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter Cc: Robert Richter , Jean Pihet Subject: [PATCH 04/16] perf, mmap: Factor out perf_get_fd() Date: Mon, 7 Apr 2014 17:04:26 +0200 Message-Id: <1396883078-25320-5-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1396883078-25320-1-git-send-email-jean.pihet@linaro.org> References: <1396883078-25320-1-git-send-email-jean.pihet@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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 Signed-off-by: Jean Pihet --- kernel/events/core.c | 14 ++++++++------ kernel/events/internal.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 22ec8f0..9857475 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4206,6 +4206,11 @@ static const struct file_operations perf_fops = { .fasync = perf_fasync, }; +int perf_get_fd(struct perf_event *event, int f_flags) +{ + return anon_inode_getfd("[perf_event]", &perf_fops, event, f_flags); +} + /* * Perf event wakeup * @@ -7028,7 +7033,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; @@ -7189,10 +7193,9 @@ SYSCALL_DEFINE5(perf_event_open, goto err_context; } - event_file = anon_inode_getfile("[perf_event]", &perf_fops, event, - f_flags); - if (IS_ERR(event_file)) { - err = PTR_ERR(event_file); + event_fd = perf_get_fd(event, f_flags); + if (event_fd < 0) { + err = event_fd; goto err_context; } @@ -7257,7 +7260,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 e9007ff..5f1f92d 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h @@ -209,5 +209,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, int f_flags); #endif /* _KERNEL_EVENTS_INTERNAL_H */