From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756736AbcCaJZW (ORCPT ); Thu, 31 Mar 2016 05:25:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38030 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756061AbcCaJZQ (ORCPT ); Thu, 31 Mar 2016 05:25:16 -0400 Date: Thu, 31 Mar 2016 02:24:32 -0700 From: tip-bot for Alexander Shishkin Message-ID: Cc: jolsa@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, eranian@google.com, alexander.shishkin@linux.intel.com, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, torvalds@linux-foundation.org, vincent.weaver@maine.edu, mathieu.poirier@linaro.org, acme@infradead.org Reply-To: jolsa@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, eranian@google.com, acme@redhat.com, alexander.shishkin@linux.intel.com, hpa@zytor.com, mingo@kernel.org, torvalds@linux-foundation.org, vincent.weaver@maine.edu, mathieu.poirier@linaro.org, acme@infradead.org In-Reply-To: <1457098969-21595-4-git-send-email-alexander.shishkin@linux.intel.com> References: <1457098969-21595-4-git-send-email-alexander.shishkin@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/ring_buffer: Document AUX API usage Git-Commit-ID: af5bb4ed1254a378b6028c09e58bdcc1cd9bf5b3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: af5bb4ed1254a378b6028c09e58bdcc1cd9bf5b3 Gitweb: http://git.kernel.org/tip/af5bb4ed1254a378b6028c09e58bdcc1cd9bf5b3 Author: Alexander Shishkin AuthorDate: Fri, 4 Mar 2016 15:42:47 +0200 Committer: Ingo Molnar CommitDate: Thu, 31 Mar 2016 10:30:43 +0200 perf/ring_buffer: Document AUX API usage In order to ensure safe AUX buffer management, we rely on the assumption that pmu::stop() stops its ongoing AUX transaction and not just the hw. This patch documents this requirement for the perf_aux_output_{begin,end}() APIs. Signed-off-by: Alexander Shishkin Signed-off-by: Peter Zijlstra (Intel) Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mathieu Poirier Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: vince@deater.net Link: http://lkml.kernel.org/r/1457098969-21595-4-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar --- kernel/events/ring_buffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 367e9c5..0ed4555 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -252,6 +252,10 @@ ring_buffer_init(struct ring_buffer *rb, long watermark, int flags) * The ordering is similar to that of perf_output_{begin,end}, with * the exception of (B), which should be taken care of by the pmu * driver, since ordering rules will differ depending on hardware. + * + * Call this from pmu::start(); see the comment in perf_aux_output_end() + * about its use in pmu callbacks. Both can also be called from the PMI + * handler if needed. */ void *perf_aux_output_begin(struct perf_output_handle *handle, struct perf_event *event) @@ -323,6 +327,7 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, return handle->rb->aux_priv; err_put: + /* can't be last */ rb_free_aux(rb); err: @@ -337,6 +342,10 @@ err: * aux_head and posting a PERF_RECORD_AUX into the perf buffer. It is the * pmu driver's responsibility to observe ordering rules of the hardware, * so that all the data is externally visible before this is called. + * + * Note: this has to be called from pmu::stop() callback, as the assumption + * of the AUX buffer management code is that after pmu::stop(), the AUX + * 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) @@ -376,6 +385,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, handle->event = NULL; local_set(&rb->aux_nest, 0); + /* can't be last */ rb_free_aux(rb); ring_buffer_put(rb); }