From patchwork Tue Jun 11 16:42:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17899 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E9E025DF1 for ; Thu, 13 Jun 2013 10:57:27 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id a1sf7130290qcx.10 for ; Thu, 13 Jun 2013 03:57:27 -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=oOLrrwQHfUFYCOqEtnCEqpp0aqBeI6e945TqhploUF4=; b=YI1sSzh2Q2u6MvxgsgI85JxOCdCXi/NWKP2/5yLU5U3ACgRz1yF9rmtZS1T6EnfC/0 r9KEssz9m+1UPYFOJZ1tn9BJtnCpmMOC8GzH6Zy0N+l4SS8GGSt+38waEz7xMglStPtx hQpi7EvXxJPtLCGHGPVIBySp5mlmaUyX1Aj9LRIRUOdd2H5XPhZeZnyFUgkWkIlGaeYM jJMwf4z2c8F5c566wszVaY6vDeEByEHt+d7lL7vOuOz4tPcILV7Jl2IU9Tqf0+33MKER ItMmKzoVILol7EXjuHZ0w+LmqYkwIkzuUT1krb4QE6OSQ0pGzNXc5eLRPdiDhBTqbRUp jaqw== 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=oOLrrwQHfUFYCOqEtnCEqpp0aqBeI6e945TqhploUF4=; b=KbB+R2NamjD6KjoZKn4j7YXV8a4SsgoYPI4z2OAVZdsDDn40sRdlhRYW+xUnne1Rqo 9/yNToE08iMJ0o78IKbIS6B1u+KLxGO9UVSJNBGmHuElpy3Q6Q/Z5PRNW+eK505ntMX7 f82a1cGshT264eqG5hGPYK6FDV3Yg4xfGRMwWEUcyDwAP+/CYvBHEIWI33crmkXS36wq kCPh9wwPVMZyN9VwDZxM+mCXH91EPVugLw1LIVBHUOZFgFlvNHDak5OQksi2cFizcn1V ycuGtOfYF9s6hHawtLa5hBqdnElVfoZY6azmXZGrKn/W+6Saa1Lxx1wlMs80y9KNCy0u rczQ== X-Received: by 10.224.129.196 with SMTP id p4mr1299615qas.6.1371121047310; Thu, 13 Jun 2013 03:57:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.163 with SMTP id i3ls1696221qer.49.gmail; Thu, 13 Jun 2013 03:57:27 -0700 (PDT) X-Received: by 10.58.255.199 with SMTP id as7mr110325ved.23.1371121047119; Thu, 13 Jun 2013 03:57:27 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id zt2si10199253vdb.50.2013.06.13.03.57.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:27 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f 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::22f; Received: by mail-ve0-f175.google.com with SMTP id da11so7600229veb.34 for ; Thu, 13 Jun 2013 03:57:27 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr114002vdj.8.1371121046619; Thu, 13 Jun 2013 03:57:26 -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 gx3csp16621vec; Thu, 13 Jun 2013 03:57:25 -0700 (PDT) X-Received: by 10.204.224.15 with SMTP id im15mr53009bkb.120.1371121045362; Thu, 13 Jun 2013 03:57:25 -0700 (PDT) Received: from mail-bk0-x22b.google.com (mail-bk0-x22b.google.com [2a00:1450:4008:c01::22b]) by mx.google.com with ESMTPS id lz10si1043425bkb.64.2013.06.13.03.57.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of rric.net@gmail.com designates 2a00:1450:4008:c01::22b as permitted sender) client-ip=2a00:1450:4008:c01::22b; Received: by mail-bk0-f43.google.com with SMTP id jm2so3827034bkc.2 for ; Thu, 13 Jun 2013 03:57:24 -0700 (PDT) X-Received: by 10.204.61.71 with SMTP id s7mr63874bkh.74.1371121044791; Thu, 13 Jun 2013 03:57:24 -0700 (PDT) Received: from rric.localhost (g224198135.adsl.alicedsl.de. [92.224.198.135]) by mx.google.com with ESMTPSA id kz11sm4001785bkb.11.2013.06.13.03.57.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:24 -0700 (PDT) Resent-From: Robert Richter Resent-Date: Thu, 13 Jun 2013 12:57:21 +0200 Resent-Message-ID: <20130613105721.GM12218@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.07 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Jun 2013 09:43:08 -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 12/14] perf, persistent: Name each persistent event Date: Tue, 11 Jun 2013 18:42:38 +0200 Message-Id: <1370968960-22527-13-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: ALoCoQneWpbJrfJfvA2Y6dpC69BTsQQBXhAga+ogcIC2DoLaUSpAPLG+rVbJeRqVQt2FtPgqG4bi X-Original-Sender: rric.net@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f 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 For later adding persistent events to sysfs we need a name for each event. Adding a name to each persistent event. Signed-off-by: Robert Richter Signed-off-by: Robert Richter --- arch/x86/kernel/cpu/mcheck/mce.c | 3 ++- include/linux/perf_event.h | 4 ++-- kernel/events/persistent.c | 30 +++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index d421937..833eb7a 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1991,7 +1991,8 @@ int __init mcheck_init(void) int __init mcheck_init_tp(void) { - if (perf_add_persistent_event_by_id(event_mce_record.event.type)) { + if (perf_add_persistent_event_by_id(event_mce_record.name, + event_mce_record.event.type)) { pr_err("Error adding MCE persistent event.\n"); return -EINVAL; } diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index dc72c93..06b4357b 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -751,7 +751,7 @@ extern void perf_event_disable(struct perf_event *event); extern int __perf_event_disable(void *info); extern void perf_event_task_tick(void); extern int perf_add_persistent_event(struct perf_event_attr *, unsigned); -extern int perf_add_persistent_event_by_id(int id); +extern int perf_add_persistent_event_by_id(char *name, int id); #else /* !CONFIG_PERF_EVENTS */ static inline void perf_event_task_sched_in(struct task_struct *prev, @@ -794,7 +794,7 @@ static inline int __perf_event_disable(void *info) { return -1; } static inline void perf_event_task_tick(void) { } static inline int perf_add_persistent_event(struct perf_event_attr *attr, unsigned nr_pages) { return -EINVAL; } -static inline int perf_add_persistent_event_by_id(int id) { return -EINVAL; } +static inline int perf_add_persistent_event_by_id(char *name, int id) { return -EINVAL; } #endif /* !CONFIG_PERF_EVENTS */ #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_NO_HZ_FULL) diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c index 97c57c9..96201c1 100644 --- a/kernel/events/persistent.c +++ b/kernel/events/persistent.c @@ -14,6 +14,11 @@ struct pers_event_desc { int fd; }; +struct pers_event { + char *name; + struct perf_event_attr attr; +}; + static DEFINE_PER_CPU(struct list_head, pers_events); static DEFINE_PER_CPU(struct mutex, pers_events_lock); @@ -132,14 +137,20 @@ unwind: return PTR_ERR(event); } -int perf_add_persistent_event_by_id(int id) +int perf_add_persistent_event_by_id(char* name, int id) { - struct perf_event_attr *attr; + struct pers_event *event; + struct perf_event_attr *attr; + int ret = -ENOMEM; - attr = kzalloc(sizeof(*attr), GFP_KERNEL); - if (!attr) + event = kzalloc(sizeof(*event), GFP_KERNEL); + if (!event) return -ENOMEM; + event->name = kstrdup(name, GFP_KERNEL); + if (!event->name) + goto fail; + attr = &event->attr; attr->sample_period = 1; attr->wakeup_events = 1; attr->sample_type = PERF_SAMPLE_RAW; @@ -148,7 +159,16 @@ int perf_add_persistent_event_by_id(int id) attr->type = PERF_TYPE_TRACEPOINT; attr->size = sizeof(*attr); - return perf_add_persistent_event(attr, CPU_BUFFER_NR_PAGES); + ret = perf_add_persistent_event(attr, CPU_BUFFER_NR_PAGES); + if (ret) + goto fail; + + return 0; +fail: + kfree(event->name); + kfree(event); + + return ret; } int perf_get_persistent_event_fd(unsigned cpu, struct perf_event_attr *attr)