From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756485AbcCaJYd (ORCPT ); Thu, 31 Mar 2016 05:24:33 -0400 Received: from terminus.zytor.com ([198.137.202.10]:37944 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750971AbcCaJYa (ORCPT ); Thu, 31 Mar 2016 05:24:30 -0400 Date: Thu, 31 Mar 2016 02:23:43 -0700 From: tip-bot for Alexander Shishkin Message-ID: Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, vincent.weaver@maine.edu, eranian@google.com, hpa@zytor.com, jolsa@redhat.com, alexander.shishkin@linux.intel.com, tglx@linutronix.de, acme@infradead.org, acme@redhat.com, torvalds@linux-foundation.org Reply-To: vincent.weaver@maine.edu, eranian@google.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, acme@redhat.com, torvalds@linux-foundation.org, acme@infradead.org, tglx@linutronix.de, alexander.shishkin@linux.intel.com, jolsa@redhat.com, hpa@zytor.com In-Reply-To: <1457098969-21595-2-git-send-email-alexander.shishkin@linux.intel.com> References: <1457098969-21595-2-git-send-email-alexander.shishkin@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/ring_buffer: Refuse to begin AUX transaction after rb->aux_mmap_count drops Git-Commit-ID: dcb10a967ce82d5ad20570693091139ae716ff76 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: dcb10a967ce82d5ad20570693091139ae716ff76 Gitweb: http://git.kernel.org/tip/dcb10a967ce82d5ad20570693091139ae716ff76 Author: Alexander Shishkin AuthorDate: Fri, 4 Mar 2016 15:42:45 +0200 Committer: Ingo Molnar CommitDate: Thu, 31 Mar 2016 10:30:41 +0200 perf/ring_buffer: Refuse to begin AUX transaction after rb->aux_mmap_count drops When ring buffer's AUX area is unmapped and rb->aux_mmap_count drops to zero, new AUX transactions into this buffer can still be started, even though the buffer in en route to deallocation. This patch adds a check to perf_aux_output_begin() for rb->aux_mmap_count being zero, in which case there is no point starting new transactions, in other words, the ring buffers that pass a certain point in perf_mmap_close will not have their events sending new data, which clears path for freeing those buffers' pages right there and then, provided that no active transactions are holding the AUX reference. 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: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: vince@deater.net Link: http://lkml.kernel.org/r/1457098969-21595-2-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar --- kernel/events/ring_buffer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index c61f0cb..89abf62 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -288,6 +288,13 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, goto err; /* + * If rb::aux_mmap_count is zero (and rb_has_aux() above went through), + * the aux buffer is in perf_mmap_close(), about to get freed. + */ + if (!atomic_read(&rb->aux_mmap_count)) + goto err; + + /* * Nesting is not supported for AUX area, make sure nested * writers are caught early */