From patchwork Tue Jun 11 16:42:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17895 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D1CA25DF1 for ; Thu, 13 Jun 2013 10:57:13 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id 2sf11261111qea.5 for ; Thu, 13 Jun 2013 03:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:resent-from:resent-date:resent-message-id:resent-to :sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:list-unsubscribe; bh=CN0MULxjjDOUW+2TkQXLN2R2Ddi1/RQTkTpwoPzwKdA=; b=TK0IcQFl6MRMDbF3NNggEPnF7XQFwf+5/YGSPRTiGnPL8Jue9ZTuZPpn3tVEfNSikG eS0sCYcwvzYWtc+2RO8690ga/GPCeq2ikK3/gxDbK3BZyviYJzy38UHCUqjlUX1o53XH QsjdslXHQESOgB1mf30WSYzMkncgfY9uJL4citlGKGdAUbZylgrE0ql270Y4W2097S4m zDzGBy8/rtMzxJmcPyHUcjrCpgJxRtKnwFWWERW91NOE/5Vg7q85/DVxM5YKb8DPTjOh p3RQY2TrH1Jpvu7LCiSKCgFEQLU1wOFNk5+oSmCuOccDijz4Km8NKUw7QPqJjBu2TxSs px1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:resent-from:resent-date:resent-message-id:resent-to :sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=CN0MULxjjDOUW+2TkQXLN2R2Ddi1/RQTkTpwoPzwKdA=; b=i39XFbD4B52TJ7RvfrBWqXxCQ75NGYm0Hmrw0e2nhOtEC5+M5tHZceexOzxPs6a464 mEZHoAT5iwlSakdI8YJVqXBTl4dzOe3ews4KkFae17fIu0aUkeB0v3tTAgXCEyU/zeXi tNIAYvZoFL9SN1E6dFcL3Ukic9XRlPWTn5yNcpsJ6q+B0k5Ygfyr4Q6d2gtvTziV1uEM o+eO0pMIiOJSTAQlmhcS+sxD2Ttf+uxKozCzyzQzbexCQPHucJEv0+Aclp0xI0zRA7ay jSoRbCunJfJxHdJp34b/5HFgpZRsBDbpwtvAUQkYUk4hb+iwc3SwPZTPrq1DfvDh50Wu vnUA== X-Received: by 10.224.59.205 with SMTP id m13mr1298293qah.7.1371121033344; Thu, 13 Jun 2013 03:57:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.3 with SMTP id f3ls4110287qeh.83.gmail; Thu, 13 Jun 2013 03:57:13 -0700 (PDT) X-Received: by 10.220.6.135 with SMTP id 7mr66665vcz.72.1371121033177; Thu, 13 Jun 2013 03:57:13 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id xb6si10197435vdb.55.2013.06.13.03.57.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so3396880vcb.10 for ; Thu, 13 Jun 2013 03:57:13 -0700 (PDT) X-Received: by 10.220.215.73 with SMTP id hd9mr119365vcb.19.1371121032965; Thu, 13 Jun 2013 03:57:12 -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.58.191.99 with SMTP id gx3csp16610vec; Thu, 13 Jun 2013 03:57:12 -0700 (PDT) X-Received: by 10.204.187.209 with SMTP id cx17mr48897bkb.143.1371121031868; Thu, 13 Jun 2013 03:57:11 -0700 (PDT) Received: from mail-bk0-x233.google.com (mail-bk0-x233.google.com [2a00:1450:4008:c01::233]) by mx.google.com with ESMTPS id pf5si1903556bkb.120.2013.06.13.03.57.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of rric.net@gmail.com designates 2a00:1450:4008:c01::233 as permitted sender) client-ip=2a00:1450:4008:c01::233; Received: by mail-bk0-f51.google.com with SMTP id ji1so4316058bkc.24 for ; Thu, 13 Jun 2013 03:57:11 -0700 (PDT) X-Received: by 10.205.99.131 with SMTP id cs3mr42760bkc.169.1371121031300; Thu, 13 Jun 2013 03:57:11 -0700 (PDT) Received: from rric.localhost (g224198135.adsl.alicedsl.de. [92.224.198.135]) by mx.google.com with ESMTPSA id jm15sm9176373bkb.13.2013.06.13.03.57.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:10 -0700 (PDT) Resent-From: Robert Richter Resent-Date: Thu, 13 Jun 2013 12:57:08 +0200 Resent-Message-ID: <20130613105708.GI12218@rric.localhost> Resent-To: linaro-kernel@lists.linaro.org, patches@linaro.org Received: from rric.localhost (f053086247.adsl.alicedsl.de. [78.53.86.247]) by mx.google.com with ESMTPSA id b12sm6160884bkz.0.2013.06.11.09.43.01 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Jun 2013 09:43:02 -0700 (PDT) Sender: Robert Richter From: Robert Richter To: Borislav Petkov Cc: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter , Robert Richter Subject: [PATCH v2 08/14] perf, persistent: Reworking perf_get_persistent_event_fd() Date: Tue, 11 Jun 2013 18:42:34 +0200 Message-Id: <1370968960-22527-9-git-send-email-rric@kernel.org> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1370968960-22527-1-git-send-email-rric@kernel.org> References: <1370968960-22527-1-git-send-email-rric@kernel.org> X-Gm-Message-State: ALoCoQnyoltdkbcD17+78ToE8ZUYXGoVB4d94ppnwOOJhU1bcbJTooHY/wmrSPIhMce8QwDV9Gwv X-Original-Sender: rric.net@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 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 There is already a function anon_inode_getfd() that does already all the work. Reworking and simplifying code. Signed-off-by: Robert Richter Signed-off-by: Robert Richter --- kernel/events/persistent.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c index 7d91871..16ed47c 100644 --- a/kernel/events/persistent.c +++ b/kernel/events/persistent.c @@ -87,33 +87,6 @@ static void del_persistent_event(int cpu, struct perf_event_attr *attr) kfree(desc); } -static int __alloc_persistent_event_fd(struct pers_event_desc *desc) -{ - struct file *event_file = NULL; - int event_fd = -1; - - event_fd = get_unused_fd(); - if (event_fd < 0) - goto out; - - event_file = anon_inode_getfile("[pers_event]", &perf_fops, - desc->event, O_RDONLY); - if (IS_ERR(event_file)) - goto err_event_file; - - desc->fd = event_fd; - fd_install(event_fd, event_file); - - goto out; - - - err_event_file: - put_unused_fd(event_fd); - - out: - return event_fd; -} - /* * Create and enable the persistent version of the perf event described by * @attr. @@ -165,6 +138,7 @@ int perf_add_persistent_event_by_id(int id) int perf_get_persistent_event_fd(unsigned cpu, struct perf_event_attr *attr) { struct pers_event_desc *desc; + int event_fd; if (cpu >= (unsigned)nr_cpu_ids) return -EINVAL; @@ -173,7 +147,12 @@ int perf_get_persistent_event_fd(unsigned cpu, struct perf_event_attr *attr) if (!desc) return -ENODEV; - return __alloc_persistent_event_fd(desc); + event_fd = anon_inode_getfd("[pers_event]", &perf_fops, + desc->event, O_RDONLY); + if (event_fd >= 0) + desc->fd = event_fd; + + return event_fd; }