From patchwork Thu Jul 28 21:42:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 73009 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1062506qga; Thu, 28 Jul 2016 14:42:46 -0700 (PDT) X-Received: by 10.66.90.34 with SMTP id bt2mr62128378pab.139.1469742166106; Thu, 28 Jul 2016 14:42:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si14353855pfb.109.2016.07.28.14.42.45; Thu, 28 Jul 2016 14:42:46 -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 S1751767AbcG1Vmi (ORCPT + 29 others); Thu, 28 Jul 2016 17:42:38 -0400 Received: from mail-it0-f49.google.com ([209.85.214.49]:38418 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbcG1Vm1 (ORCPT ); Thu, 28 Jul 2016 17:42:27 -0400 Received: by mail-it0-f49.google.com with SMTP id j124so92744815ith.1 for ; Thu, 28 Jul 2016 14:42:27 -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=Jlz9LL0gNiFJgSEo8ei1qtcObiPTejewFam+GdH/Ob148xCJEATgQPP4ZDeYp8WktG cBJ4cdBAqfNfnZYsl1l+HKAJaEFZ2BKGIrnudjfVrWtj/GJELhawPDvloWdUQPod5y+R et2FoSywicJ2DFSCdhLrA0Zj8Py7FDgKlXUBI= 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=Gw6/zBhCME0MZxNxrAIX3pt0d/UylK3Cdjj98KV5fIIuO3FqnRmPl7cY+KM5nZjDMa E5xNPZf/3S/2x8gIMTZkQm+5oPBEXSj50ZHvW/Gzp/N0anfkI+b4UBshTH/0s851bX// d0fhPAepynt7BGoEMUIrQY3iqJYBCRuGApT+HTNzSl6RvzDh1dsMJtfZo36KL7EA6Jei s07Q/7YSpf7YjrHOsf/5c17z7qZGw3cOk8ZRGg5vwBBJZr2XVAUec00XQKZZ+zJKORea a2cJcZHOqD1DOPV6qdlSMcJdMO4tem6fCRcuvuggAt7C6VWTVTed/JcTGfVJ/YKXIr3s U/lA== X-Gm-Message-State: AEkoousbsXwVzpeEkY7HzV0VMSl9xgf6SjgL5b6VKOiN+reRsuPVpbTMi4I1rOq84ZAIVE6C X-Received: by 10.36.158.213 with SMTP id p204mr27253709itd.99.1469742146732; Thu, 28 Jul 2016 14:42:26 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h99sm5808499iod.9.2016.07.28.14.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jul 2016 14:42:26 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, jolsa@kernel.org Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mathieu Poirier Subject: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration Date: Thu, 28 Jul 2016 15:42:18 -0600 Message-Id: <1469742143-22245-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469742143-22245-1-git-send-email-mathieu.poirier@linaro.org> References: <1469742143-22245-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 ++++++++++++++++ tools/include/uapi/linux/perf_event.h | 1 + 4 files changed, 27 insertions(+) -- 2.7.4 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,