From patchwork Tue Jul 19 22:53:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 72372 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp322070qga; Tue, 19 Jul 2016 15:54:19 -0700 (PDT) X-Received: by 10.66.90.34 with SMTP id bt2mr68781323pab.139.1468968858828; Tue, 19 Jul 2016 15:54:18 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xp2si3084478pac.150.2016.07.19.15.54.18; Tue, 19 Jul 2016 15:54:18 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbcGSWyE (ORCPT + 29 others); Tue, 19 Jul 2016 18:54:04 -0400 Received: from mail-io0-f173.google.com ([209.85.223.173]:32855 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbcGSWyA (ORCPT ); Tue, 19 Jul 2016 18:54:00 -0400 Received: by mail-io0-f173.google.com with SMTP id 38so32622382iol.0 for ; Tue, 19 Jul 2016 15:54:00 -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=WuWMS2dz5Q7pD1cFtFF5ssl4Je41SQpA/kMKO3S9iqM=; b=NvKOeoX9w6nrjbgrrdyNyScepMPwgM35izQnuWSPYPsR/oJ6y8ob8zOkz8S4OoBhH4 BjZpPEMDtBfXMMu29/VOlRZPHFnh9zuUu/87IHIPgKmcwgwx96oGFxwXyYaBmjKFnXnt ryow2btuF5bpBHtIyfpdDGWPqwnBHgnN3DB40= 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=WuWMS2dz5Q7pD1cFtFF5ssl4Je41SQpA/kMKO3S9iqM=; b=UnKGVfH9nFAqqJ7lzh8v9PD6F2gq0+zZ7VCTvmIgThSQcyuhvqSLE5182olnI3qGBC WHPdhdMwYx2O53JouZJyzed6r0aSjTiOdM1PSotbh9hU2Pwp966iEJy6zV2PUEeBerhT uIETFpQ3oSxKYVRepCIK4/b7H2rAaUa8SYGgVUgT8mGWpTLwxWTXuE3b7n9uivykiPG8 1vZvGzuSuBg0yjeG9U+omqxBn9X7STloUMYQr72X0SIVAL2Nzb0sv0q1sZFK6ox6mQo4 2HxVIcnCeM7+0ixgVfBFviw5gGIXX35mEMAtp2Z7DJ5WrduFznzxDY89KMZTofRr/RKy kiXQ== X-Gm-Message-State: ALyK8tKK47hBVQzzvEYnLBuoYZrPtV7UqP1nf9U8DoIddw+NJdMGZDDwcHLFjnqMNU5HJlOp X-Received: by 10.107.134.93 with SMTP id i90mr42440949iod.153.1468968839773; Tue, 19 Jul 2016 15:53:59 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x96sm71499ita.20.2016.07.19.15.53.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 15:53:59 -0700 (PDT) From: Mathieu Poirier To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/6] perf/core: Adding PMU driver specific configuration Date: Tue, 19 Jul 2016 16:53:51 -0600 Message-Id: <1468968836-12695-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468968836-12695-1-git-send-email-mathieu.poirier@linaro.org> References: <1468968836-12695-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 ++++++++++++++++ 3 files changed, 26 insertions(+) -- 2.7.4 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 1a827cecd62f..70bfd59afa98 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 36ce552cf6a9..1bba3580882f 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -403,6 +403,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 eb37c41b8452..28bbd5f18f17 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4414,6 +4414,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) { @@ -4483,6 +4485,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; } @@ -4515,6 +4521,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; @@ -7585,6 +7592,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 */