From patchwork Thu Aug 4 16:53:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 73291 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1495201qga; Thu, 4 Aug 2016 09:55:35 -0700 (PDT) X-Received: by 10.66.123.105 with SMTP id lz9mr88313791pab.56.1470329735758; Thu, 04 Aug 2016 09:55:35 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gw1si15414969pac.108.2016.08.04.09.55.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 09:55:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVLuO-000065-Pl; Thu, 04 Aug 2016 16:54:12 +0000 Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVLu0-0008R3-P2 for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 16:53:51 +0000 Received: by mail-io0-x234.google.com with SMTP id 38so276370903iol.0 for ; Thu, 04 Aug 2016 09:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xpDvJQZ/qMWq1bHEjHuKeGOWAlaIJuQUqG6KsbM0SIE=; b=OJuCpYb5MGhXJFIBuVFLEONyi3wtUXN+JoqLvPnSopyxgQzCgo03ME2smGR8VyQJda Qeu9gAqKg3R27s7a4H1lS21bpw0ZJ12z8Z2T0EaxUC3UPmTAf6rkhrSsYjOUPr1gkLXR SFHqXQZovuhwtGc6JonXHujq5BkdIk+xzcHFw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xpDvJQZ/qMWq1bHEjHuKeGOWAlaIJuQUqG6KsbM0SIE=; b=S3tO1xNxDWuf3ep6XQW9H9ob6A/hY9OKRjYpJMDe5k6X7tsXEuBEWhW//G4b0kmR2v BAC/Ehe/Ej4pkBxks9BO7buYbeo7ut4+ljoskGr0Gzbz7421wW6tChYgvKo5atzm+Roi bcw7W5tl+74jZsR+h4wyu6l2Kme0J1URD5LLGtyBN1GiHgcDonDMgBLK6OhU2J6mpL7j 4cNUw410fMhLmedrhVTCkyIisxIR2eLcTo8+UmWzr9RkwGFP6XQ+ZCA+wVUHt+sKJKii NSe9p4Ro5jf559egYQhIRzWTzEBPMybqQsOiEBhnl3ap8oPdHOlpBGOmBT7KhrN5b7XI UdRg== X-Gm-Message-State: AEkoouuVzY6A0lb8Q4PHuY3/uvA0AYsqiRp00C40d8k9wwW+lUpJXvJfHhA6taNDwIIecQNj X-Received: by 10.107.56.87 with SMTP id f84mr74692392ioa.188.1470329607595; Thu, 04 Aug 2016 09:53:27 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id l19sm6117846iod.10.2016.08.04.09.53.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 09:53:27 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, jolsa@kernel.org Subject: [PATCH V4 1/6] perf/core: Adding PMU driver specific configuration Date: Thu, 4 Aug 2016 10:53:19 -0600 Message-Id: <1470329604-14356-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470329604-14356-1-git-send-email-mathieu.poirier@linaro.org> References: <1470329604-14356-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_095349_086519_1C2A2E27 X-CRM114-Status: GOOD ( 14.72 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c06:0:0:0:234 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This patch somewhat mimics the work done on address filters to add the infrastructure needed to pass PMU specific HW configuration to the driver before a session starts. Signed-off-by: Mathieu Poirier --- include/linux/perf_event.h | 9 +++++++++ include/uapi/linux/perf_event.h | 1 + kernel/events/core.c | 16 ++++++++++++++++ tools/include/uapi/linux/perf_event.h | 1 + 4 files changed, 27 insertions(+) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 7921f4f20a58..59d61a12cf9d 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -168,6 +168,9 @@ struct hw_perf_event { /* Last sync'ed generation of filters */ unsigned long addr_filters_gen; + /* HW specific configuration */ + void *drv_configs; + /* * hw_perf_event::state flags; used to track the PERF_EF_* state. */ @@ -442,6 +445,12 @@ struct pmu { * Filter events for PMU-specific reasons. */ int (*filter_match) (struct perf_event *event); /* optional */ + + /* + * PMU driver specific configuration. + */ + int (*set_drv_configs) (struct perf_event *event, + void __user *arg); /* optional */ }; /** diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index c66a485a24ac..90fbc5fd3925 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -407,6 +407,7 @@ struct perf_event_attr { #define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) #define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) #define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) +#define PERF_EVENT_IOC_SET_DRV_CONFIGS _IOW('$', 10, char *) enum perf_event_ioc_flags { PERF_IOC_FLAG_GROUP = 1U << 0, diff --git a/kernel/events/core.c b/kernel/events/core.c index 79dae188a987..9208e6ec036f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4457,6 +4457,8 @@ static int perf_event_set_output(struct perf_event *event, struct perf_event *output_event); static int perf_event_set_filter(struct perf_event *event, void __user *arg); static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd); +static int perf_event_set_drv_configs(struct perf_event *event, + void __user *arg); static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned long arg) { @@ -4526,6 +4528,10 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon rcu_read_unlock(); return 0; } + + case PERF_EVENT_IOC_SET_DRV_CONFIGS: + return perf_event_set_drv_configs(event, (void __user *)arg); + default: return -ENOTTY; } @@ -4558,6 +4564,7 @@ static long perf_compat_ioctl(struct file *file, unsigned int cmd, switch (_IOC_NR(cmd)) { case _IOC_NR(PERF_EVENT_IOC_SET_FILTER): case _IOC_NR(PERF_EVENT_IOC_ID): + case _IOC_NR(PERF_EVENT_IOC_SET_DRV_CONFIGS): /* Fix up pointer size (usually 4 -> 8 in 32-on-64-bit case */ if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) { cmd &= ~IOCSIZE_MASK; @@ -7633,6 +7640,15 @@ void perf_bp_event(struct perf_event *bp, void *data) } #endif +static int perf_event_set_drv_configs(struct perf_event *event, + void __user *arg) +{ + if (!event->pmu->set_drv_configs) + return -EINVAL; + + return event->pmu->set_drv_configs(event, arg); +} + /* * Allocate a new address filter */ diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index c66a485a24ac..90fbc5fd3925 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -407,6 +407,7 @@ struct perf_event_attr { #define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) #define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) #define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) +#define PERF_EVENT_IOC_SET_DRV_CONFIGS _IOW('$', 10, char *) enum perf_event_ioc_flags { PERF_IOC_FLAG_GROUP = 1U << 0,