From patchwork Thu Aug 11 16:21:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9275579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95C32600CB for ; Thu, 11 Aug 2016 16:24:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88DBF2871B for ; Thu, 11 Aug 2016 16:24:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DB0D2871D; Thu, 11 Aug 2016 16:24:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F282B2871B for ; Thu, 11 Aug 2016 16:24:24 +0000 (UTC) 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 1bXsks-0003Ws-R8; Thu, 11 Aug 2016 16:22:50 +0000 Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bXsjn-0002zn-Eo for linux-arm-kernel@lists.infradead.org; Thu, 11 Aug 2016 16:21:45 +0000 Received: by mail-it0-x235.google.com with SMTP id x130so612755ite.1 for ; Thu, 11 Aug 2016 09:21:23 -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=EGRmgDU/jd2xrslPTQK0rxhB18zuDzXjItCaZ32f7oQ=; b=DXNBxd3NPofTYV+QosM+dlvE77LoKcALF/W2DBPJgEre9JYHJi1LFVpl90VxG7A24e W131DZFw86EpM+BUlRZfNEEU908UNHe8QIJhLsznLklq5oTOxMJTUnN2omxSxdDnLNzM wuSNWMEVa8QN5xB5wMbqpvMaOgEeR+mzLa9wE= 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=EGRmgDU/jd2xrslPTQK0rxhB18zuDzXjItCaZ32f7oQ=; b=BMo6gI5ckH2iwBRZaEXwTMltkTZrwvHpMkX3WyuY1erx15b5BKveJASnehzCdfLZ+a 2eLoCHlWrsqeytAU1XELXnG1oLRv42K1OK4rEbmXejeMM7lbK/Q/2bTLzJPil5YQMlcb /cB8k2jk+RteGqBfMpPhuhE8WjljTaJB1NGpMWlG9exiznFokQMcC/MbiyfWJ5DX31eg OVHIPV7851QfAS8vlE7RtcDcP16EaIIiL1Wp0Tucmrth+DyiLtuYh256+qcao5EiS+w4 3riJdFH18hNPGBRc4cQ6Shzdw3uZhAIqRGyQlmh5/teFAiCmdZUa55i7tJffxQqS9Lme 7XZg== X-Gm-Message-State: AEkoouv54kn3NKIw0DDcU+rpIdFkSdi9jiuqZSQ8RvK22cmoL9a96ZLJAJUtCnwckVlJYqQ2 X-Received: by 10.36.204.68 with SMTP id x65mr11071683itf.54.1470932482507; Thu, 11 Aug 2016 09:21:22 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id d71sm1605485ioj.33.2016.08.11.09.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 09:21:20 -0700 (PDT) From: Mathieu Poirier To: peterz@infradead.org Subject: [PATCH V5 5/9] perf: Passing struct perf_event to function setup_aux() Date: Thu, 11 Aug 2016 10:21:00 -0600 Message-Id: <1470932464-726-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470932464-726-1-git-send-email-mathieu.poirier@linaro.org> References: <1470932464-726-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160811_092143_667311_267CA9B2 X-CRM114-Status: GOOD ( 15.72 ) 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: Mathieu Poirier , Alexander Shishkin , linux-kernel@vger.kernel.org, acme@kernel.org, vince@deater.net, mingo@redhat.com, mtk.manpages@gmail.com, jolsa@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some information, like driver specific configuration, is found in the hw_perf_event structure. As such pass a 'struct perf_event' to function setup_aux() rather than just the CPU number so that individual drivers can make the right configuration when setting up a session. For example the sink definition for a given CoreSight session can be embedded in the perf cmd line: perf record -e cs_etm/@sink=20070000.etr/ ... The string "sink=20070000.etr" is conveyed to the kernel by way of of an ioctl() call. From there is is handed over to the PMU driver for parsing and processing. If the format is valid the substring "20070000.etr" is kept in the hw_perf_event::drv_configs for future reference. When pmu::setup_aux() is called information about both the perf_event::cpu and the hw_perf_event::drv_configs is needed to setup a path from source to sink. Signed-off-by: Mathieu Poirier Cc: Alexander Shishkin --- arch/x86/events/intel/bts.c | 4 +++- arch/x86/events/intel/pt.c | 5 +++-- drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++-- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 0a6e393a2e62..98155c2dfcce 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -68,8 +68,10 @@ static size_t buf_size(struct page *page) } static void * -bts_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool overwrite) +bts_buffer_setup_aux(struct perf_event *event, void **pages, + int nr_pages, bool overwrite) { + int cpu = event->cpu; struct bts_buffer *buf; struct page *page; int node = (cpu == -1) ? cpu : cpu_to_node(cpu); diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 04bb5fb5a8d7..5178c5de0b19 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -1003,10 +1003,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages, * Return: Our private PT buffer structure. */ static void * -pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot) +pt_buffer_setup_aux(struct perf_event *event, void **pages, + int nr_pages, bool snapshot) { struct pt_buffer *buf; - int node, ret; + int node, ret, cpu = event->cpu; if (!nr_pages) return NULL; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 755125f7917f..f4174f36c5a0 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -155,7 +155,7 @@ static void etm_free_aux(void *data) schedule_work(&event_data->work); } -static void *etm_setup_aux(int event_cpu, void **pages, +static void *etm_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { int cpu; @@ -163,7 +163,7 @@ static void *etm_setup_aux(int event_cpu, void **pages, struct coresight_device *sink; struct etm_event_data *event_data = NULL; - event_data = alloc_event_data(event_cpu); + event_data = alloc_event_data(event->cpu); if (!event_data) return NULL; diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 1ea2028d9848..16f797561907 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -421,7 +421,7 @@ struct pmu { /* * Set up pmu-private data structures for an AUX area */ - void *(*setup_aux) (int cpu, void **pages, + void *(*setup_aux) (struct perf_event *event, void **pages, int nr_pages, bool overwrite); /* optional */ diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index ae9b90dc9a5a..56aba90af437 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -616,7 +616,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, goto out; } - rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages, + rb->aux_priv = event->pmu->setup_aux(event, rb->aux_pages, nr_pages, overwrite); if (!rb->aux_priv) goto out;