From patchwork Fri Jan 13 16:03:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 9515965 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 9A3E36077E for ; Fri, 13 Jan 2017 16:06:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D23F285E8 for ; Fri, 13 Jan 2017 16:06:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81E452873B; Fri, 13 Jan 2017 16:06:41 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC9C1285E8 for ; Fri, 13 Jan 2017 16:06:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cS4NB-0001p8-Sy; Fri, 13 Jan 2017 16:06:37 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cS4LW-0005xj-NC for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2017 16:05:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 45B8C15BF; Fri, 13 Jan 2017 08:04:12 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 190043F5AC; Fri, 13 Jan 2017 08:04:12 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id F03B11AE3619; Fri, 13 Jan 2017 16:04:10 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2 07/10] perf: Directly pass PERF_AUX_* flags to perf_aux_output_end Date: Fri, 13 Jan 2017 16:03:46 +0000 Message-Id: <1484323429-15231-8-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484323429-15231-1-git-send-email-will.deacon@arm.com> References: <1484323429-15231-1-git-send-email-will.deacon@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170113_080455_172424_D0ED5200 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, robh@kernel.org, kim.phillips@arm.com, mathieu.poirier@linaro.org, pawel.moll@arm.com, suzuki.poulose@arm.com, marc.zyngier@arm.com, Will Deacon , linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, tglx@linutronix.de, alex.bennee@linaro.org, christoffer.dall@linaro.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 In preparation for adding additional flags to perf AUX records, allow the flags for a session to be passed directly to perf_aux_output_end, rather than extend the function to take a bool for each one. Signed-off-by: Will Deacon --- arch/x86/events/intel/bts.c | 11 ++++++----- arch/x86/events/intel/pt.c | 11 +++++++---- drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +++-- include/linux/perf_event.h | 4 ++-- kernel/events/ring_buffer.c | 12 +++++------- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 982c9e31daca..2aa63190f01e 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -276,7 +276,7 @@ static void bts_event_start(struct perf_event *event, int flags) return; fail_end_stop: - perf_aux_output_end(&bts->handle, 0, false); + perf_aux_output_end(&bts->handle, 0, 0); fail_stop: event->hw.state = PERF_HES_STOPPED; @@ -319,9 +319,9 @@ static void bts_event_stop(struct perf_event *event, int flags) bts->handle.head = local_xchg(&buf->data_size, buf->nr_pages << PAGE_SHIFT); - perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), - !!local_xchg(&buf->lost, 0)); + local_xchg(&buf->lost, 0) ? + PERF_AUX_FLAG_TRUNCATED : 0); } cpuc->ds->bts_index = bts->ds_back.bts_buffer_base; @@ -485,7 +485,8 @@ int intel_bts_interrupt(void) return handled; perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), - !!local_xchg(&buf->lost, 0)); + local_xchg(&buf->lost, 0) ? + PERF_AUX_FLAG_OVERWRITE : 0); buf = perf_aux_output_begin(&bts->handle, event); if (buf) @@ -500,7 +501,7 @@ int intel_bts_interrupt(void) * cleared handle::event */ barrier(); - perf_aux_output_end(&bts->handle, 0, false); + perf_aux_output_end(&bts->handle, 0, 0); } } diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 1c1b9fe705c8..e229f675114d 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -1187,7 +1187,8 @@ void intel_pt_interrupt(void) pt_update_head(pt); perf_aux_output_end(&pt->handle, local_xchg(&buf->data_size, 0), - local_xchg(&buf->lost, 0)); + local_xchg(&buf->lost, 0) ? + PERF_AUX_FLAG_TRUNCATED : 0); if (!event->hw.state) { int ret; @@ -1202,7 +1203,8 @@ void intel_pt_interrupt(void) /* snapshot counters don't use PMI, so it's safe */ ret = pt_buffer_reset_markers(buf, &pt->handle); if (ret) { - perf_aux_output_end(&pt->handle, 0, true); + perf_aux_output_end(&pt->handle, 0, + PERF_AUX_FLAG_TRUNCATED); return; } @@ -1274,7 +1276,7 @@ static void pt_event_start(struct perf_event *event, int mode) return; fail_end_stop: - perf_aux_output_end(&pt->handle, 0, true); + perf_aux_output_end(&pt->handle, 0, PERF_AUX_FLAG_TRUNCATED); fail_stop: hwc->state = PERF_HES_STOPPED; } @@ -1316,7 +1318,8 @@ static void pt_event_stop(struct perf_event *event, int mode) local_xchg(&buf->data_size, buf->nr_pages << PAGE_SHIFT); perf_aux_output_end(&pt->handle, local_xchg(&buf->data_size, 0), - local_xchg(&buf->lost, 0)); + local_xchg(&buf->lost, 0) ? + PERF_AUX_FLAG_TRUNCATED : 0); } } diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 17741969026e..4a425b2f62ee 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -301,7 +301,7 @@ static void etm_event_start(struct perf_event *event, int flags) return; fail_end_stop: - perf_aux_output_end(handle, 0, true); + perf_aux_output_end(handle, 0, PERF_AUX_FLAG_TRUNCATED); fail: event->hw.state = PERF_HES_STOPPED; goto out; @@ -350,7 +350,8 @@ static void etm_event_stop(struct perf_event *event, int mode) event_data->snk_config, &lost); - perf_aux_output_end(handle, size, lost); + perf_aux_output_end(handle, size, + lost ? PERF_AUX_FLAG_TRUNCATED : 0); } /* Disabling the path make its elements available to other sessions */ diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 4741ecdb9817..473e052e6208 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -847,7 +847,7 @@ perf_cgroup_from_task(struct task_struct *task, struct perf_event_context *ctx) extern void *perf_aux_output_begin(struct perf_output_handle *handle, struct perf_event *event); extern void perf_aux_output_end(struct perf_output_handle *handle, - unsigned long size, bool truncated); + unsigned long size, u64 flags); extern int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size); extern void *perf_get_aux(struct perf_output_handle *handle); @@ -1265,7 +1265,7 @@ perf_aux_output_begin(struct perf_output_handle *handle, struct perf_event *event) { return NULL; } static inline void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, - bool truncated) { } + u64 flags) { } static inline int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size) { return -EINVAL; } diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 64158071690c..2c8af2e75953 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -410,15 +410,11 @@ EXPORT_SYMBOL_GPL(perf_aux_output_begin); * transaction must be stopped and therefore drop the AUX reference count. */ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, - bool truncated) + u64 flags) { struct ring_buffer *rb = handle->rb; - bool wakeup = truncated; + bool wakeup = !!flags; unsigned long aux_head; - u64 flags = 0; - - if (truncated) - flags |= PERF_AUX_FLAG_TRUNCATED; /* in overwrite mode, driver provides aux_head via handle */ if (rb->aux_overwrite) { @@ -427,6 +423,8 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, aux_head = handle->head; local_set(&rb->aux_head, aux_head); } else { + flags &= ~PERF_AUX_FLAG_OVERWRITE; + aux_head = local_read(&rb->aux_head); local_add(size, &rb->aux_head); } @@ -447,7 +445,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, } if (wakeup) { - if (truncated) + if (flags & PERF_AUX_FLAG_TRUNCATED) handle->event->pending_disable = 1; perf_output_wakeup(handle); }