Skip to contentSkip to conversation

perf, pt: Fix massive data losses

PATCH In review Alexander Shishkin 5 participants 17 messages May 10, 2016 – May 21, 2016

Subsystems (3)
lore
Share & tools
lore

Alexander Shishkin

author reviewer
#0 lore raw

cover perf, pt: Fix massive data losses

Hi Peter,

Markus reported that PT is losing a lot of its data in cpu-wide mode. There are two problems in play here, both are amplified by the fact that cpu-wide events don't normally get re-scheduled, so if we don't disable them when their buffers are full, they get forever stuck. Hence two patches. I propose to put these through perf/urgent and also stable trees so that people with older kernels still get to collect humongous amounts of PT traces in cpu-wide mode.

Alexander Shishkin (2):
perf/x86/intel/pt: Generate PMI in the STOP region as well
perf: Disable the event on a truncated AUX record

 arch/x86/events/intel/pt.c  |  2 ++
 kernel/events/ring_buffer.c | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.8.1
author reviewer
#1 lore raw

PATCH 1/2 perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

This patch makes PT also generate a PMI when the last output region is full.

---
 arch/x86/events/intel/pt.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/events/intel/pt.c +2 -0
index 5b648d4a94..a157cf67a9 100644
@@ -861,6 +861,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 
 	/* clear STOP and INT from current entry */
 	buf->topa_index[buf->stop_pos]->stop = 0;
+	buf->topa_index[buf->stop_pos]->intr = 0;
 	buf->topa_index[buf->intr_pos]->intr = 0;
 
 	/* how many pages till the STOP marker */
@@ -885,6 +886,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 	buf->intr_pos = idx;
 
 	buf->topa_index[buf->stop_pos]->stop = 1;
+	buf->topa_index[buf->stop_pos]->intr = 1;
 	buf->topa_index[buf->intr_pos]->intr = 1;
 
 	return 0;
Signature · 1 line
2.8.1
#2 lore raw

[tip:perf/core] perf/x86/intel/pt: Generate PMI in the STOP region as well

perf/x86/intel/pt: Generate PMI in the STOP region as well
Commit-ID:  5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Gitweb:     http://git.kernel.org/tip/5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 10:14:55 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

This patch makes PT also generate a PMI when the last output region is full.

---
 arch/x86/events/intel/pt.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/events/intel/pt.c +2 -0
index 54fa238..04bb5fb 100644
@@ -835,6 +835,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 
 	/* clear STOP and INT from current entry */
 	buf->topa_index[buf->stop_pos]->stop = 0;
+	buf->topa_index[buf->stop_pos]->intr = 0;
 	buf->topa_index[buf->intr_pos]->intr = 0;
 
 	/* how many pages till the STOP marker */
@@ -859,6 +860,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 	buf->intr_pos = idx;
 
 	buf->topa_index[buf->stop_pos]->stop = 1;
+	buf->topa_index[buf->stop_pos]->intr = 1;
 	buf->topa_index[buf->intr_pos]->intr = 1;
 
 	return 0;
author reviewer
#3 lore raw

Re: [tip:perf/core] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 8 lines · tip-bot for Alexander Shishkin
Commit-ID:  5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Gitweb:     http://git.kernel.org/tip/5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 10:14:55 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

I was hoping to get this (and the other "truncated" thing patch) in via perf/urgent, them being bugs that cause people to lose trace data.

Regards,
--
Alex

#4 lore raw

Re: [tip:perf/core] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 9 lines · Alexander Shishkin
Quoted 7 lines · tip-bot for Alexander Shishkin
Commit-ID:  5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Gitweb:     http://git.kernel.org/tip/5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 10:14:55 +0200
Quoted 4 lines
Quoted 1 line

perf/x86/intel/pt: Generate PMI in the STOP region as well

I was hoping to get this (and the other "truncated" thing patch) in via perf/urgent, them being bugs that cause people to lose trace data.

Ok, agreed - I cherry-picked them over into perf/urgent as well.

Thanks,

Ingo

author reviewer
#5 lore raw

Re: [tip:perf/core] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Alexander Shishkin
Quoted 7 lines · tip-bot for Alexander Shishkin
Commit-ID:  5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Gitweb:     http://git.kernel.org/tip/5fbe4788b55540a6c4fe2c47e05482ac356eaf74
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 10:14:55 +0200
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

perf/x86/intel/pt: Generate PMI in the STOP region as well

I was hoping to get this (and the other "truncated" thing patch) in via perf/urgent, them being bugs that cause people to lose trace data.

Ok, agreed - I cherry-picked them over into perf/urgent as well.

Thanks!

Regards,
--
Alex

#6 lore raw

[tip:perf/urgent] perf/x86/intel/pt: Generate PMI in the STOP region as well

In reply to Alexander Shishkin
perf/x86/intel/pt: Generate PMI in the STOP region as well
Commit-ID:  ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Gitweb:     http://git.kernel.org/tip/ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 14:45:59 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

This patch makes PT also generate a PMI when the last output region is full.

---
 arch/x86/events/intel/pt.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/events/intel/pt.c +2 -0
index 09a77db..7377814 100644
@@ -709,6 +709,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 
 	/* clear STOP and INT from current entry */
 	buf->topa_index[buf->stop_pos]->stop = 0;
+	buf->topa_index[buf->stop_pos]->intr = 0;
 	buf->topa_index[buf->intr_pos]->intr = 0;
 
 	/* how many pages till the STOP marker */
@@ -733,6 +734,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 	buf->intr_pos = idx;
 
 	buf->topa_index[buf->stop_pos]->stop = 1;
+	buf->topa_index[buf->stop_pos]->intr = 1;
 	buf->topa_index[buf->intr_pos]->intr = 1;
 
 	return 0;
author reviewer
#7 lore raw

Re: [tip:perf/urgent] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 24 lines · tip-bot for Alexander Shishkin
Commit-ID:  ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Gitweb:     http://git.kernel.org/tip/ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 14:45:59 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

Quoted 7 lines

This patch makes PT also generate a PMI when the last output region is full.

Can we also have this one queued up for stable 4.4 and 4.5?

Thanks,
--
Alex

Acked-by
#8 lore raw

Re: [tip:perf/urgent] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 29 lines · Alexander Shishkin
Quoted 27 lines · tip-bot for Alexander Shishkin
Commit-ID:  ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Gitweb:     http://git.kernel.org/tip/ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 14:45:59 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

This patch makes PT also generate a PMI when the last output region is full.

Quoted 6 lines
Quoted 4 lines

Can we also have this one queued up for stable 4.4 and 4.5?

Agreed.

Thanks,

Ingo

maintainer
#9 lore raw

Re: [tip:perf/urgent] perf/x86/intel/pt: Generate PMI in the STOP region as well

Quoted 37 lines · Ingo Molnar
Quoted 34 lines · Alexander Shishkin
Quoted 31 lines · tip-bot for Alexander Shishkin
Commit-ID:  ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Gitweb:     http://git.kernel.org/tip/ab92b232ae05c382c3df0e3d6a5c6d16b639ac8c
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:32 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 14:45:59 +0200

perf/x86/intel/pt: Generate PMI in the STOP region as well

Currently, the PT driver always sets the PMI bit one region (page) before the STOP region so that we can wake up the consumer before we run out of room in the buffer and have to disable the event. However, we also need an interrupt in the last output region, so that we actually get to disable the event (if no more room from new data is available at that point), otherwise hardware just quietly refuses to start, but the event is scheduled in and we end up losing trace data till the event gets removed.

For a cpu-wide event it is even worse since there may not be any re-scheduling at all and no chance for the ring buffer code to notice that its buffer is filled up and the event needs to be disabled (so that the consumer can re-enable it when it finishes reading the data out). In other words, all the trace data will be lost after the buffer gets filled up.

This patch makes PT also generate a PMI when the last output region is full.

Quoted 5 lines
Quoted 1 line

Can we also have this one queued up for stable 4.4 and 4.5?

Agreed.

The filename moved around, now fixed and queued up, thanks.

greg k-h

author reviewer
#10 lore raw

PATCH 2/2 perf: Disable the event on a truncated AUX record

In reply to Alexander Shishkin

When the PMU driver reports a truncated AUX record, it effectively means that there is no more usable room in the event's AUX buffer (even though there may still be some room, so that perf_aux_output_begin() doesn't take action). At this point the consumer still has to be woken up and the event has to be disabled, otherwise the event will just keep spinning between perf_aux_output_begin() and perf_aux_output_end() until its context gets unscheduled.

Again, for cpu-wide events this means never, so once in this condition, they will be forever losing data.

Fix this by disabling the event and waking up the consumer in case of a truncated AUX record.

---
 kernel/events/ring_buffer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/events/ring_buffer.c +9 -1
index 0f7f011710..5dd23b2d03 100644
@@ -405,6 +405,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 			 bool truncated)
 {
 	struct ring_buffer *rb = handle->rb;
+	bool wakeup = truncated;
 	unsigned long aux_head;
 	u64 flags = 0;
 
@@ -433,9 +434,16 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 	aux_head = rb->user_page->aux_head = local_read(&rb->aux_head);
 
 	if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) {
-		perf_output_wakeup(handle);
+		wakeup = true;
 		local_add(rb->aux_watermark, &rb->aux_wakeup);
 	}
+
+	if (wakeup) {
+		if (truncated)
+			handle->event->pending_disable = 1;
+		perf_output_wakeup(handle);
+	}
+
 	handle->event = NULL;
 
 	local_set(&rb->aux_nest, 0);
Signature · 1 line
2.8.1
maintainer
#11 lore raw

Re: [PATCH 2/2] perf: Disable the event on a truncated AUX record

Quoted 14 lines · Alexander Shishkin

When the PMU driver reports a truncated AUX record, it effectively means that there is no more usable room in the event's AUX buffer (even though there may still be some room, so that perf_aux_output_begin() doesn't take action). At this point the consumer still has to be woken up and the event has to be disabled, otherwise the event will just keep spinning between perf_aux_output_begin() and perf_aux_output_end() until its context gets unscheduled.

Again, for cpu-wide events this means never, so once in this condition, they will be forever losing data.

Fix this by disabling the event and waking up the consumer in case of a truncated AUX record.

kernel/events/ring_buffer.c void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, · line 445

Quoted 5 lines
kernel/events/ring_buffer.c +5 -0
+	if (wakeup) {
+		if (truncated)
+			handle->event->pending_disable = 1;
+		perf_output_wakeup(handle);
+	}

Does the userspace tool know how to deal with this and re-enable it?

author reviewer
#12 lore raw

Re: [PATCH 2/2] perf: Disable the event on a truncated AUX record

Quoted 15 lines · Peter Zijlstra
Quoted 13 lines · Alexander Shishkin

When the PMU driver reports a truncated AUX record, it effectively means that there is no more usable room in the event's AUX buffer (even though there may still be some room, so that perf_aux_output_begin() doesn't take action). At this point the consumer still has to be woken up and the event has to be disabled, otherwise the event will just keep spinning between perf_aux_output_begin() and perf_aux_output_end() until its context gets unscheduled.

Again, for cpu-wide events this means never, so once in this condition, they will be forever losing data.

Fix this by disabling the event and waking up the consumer in case of a truncated AUX record.

Quoted 7 lines

kernel/events/ring_buffer.c void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size, · line 445

Quoted 5 lines
kernel/events/ring_buffer.c +5 -0
+	if (wakeup) {
+		if (truncated)
+			handle->event->pending_disable = 1;
+		perf_output_wakeup(handle);
+	}

Does the userspace tool know how to deal with this and re-enable it?

Yes, it knows to ioctl(EVENT_ENABLE). Also, we're already doing the disabling for the no-room-in-buffer condition in perf_aux_output_begin().

Regards,
--
Alex

maintainer
#13 lore raw

Re: [PATCH 2/2] perf: Disable the event on a truncated AUX record

Quoted 7 lines · Alexander Shishkin
Quoted 2 lines · Peter Zijlstra

Does the userspace tool know how to deal with this and re-enable it?

Yes, it knows to ioctl(EVENT_ENABLE). Also, we're already doing the disabling for the no-room-in-buffer condition in perf_aux_output_begin().

Awesome; gots them queued.

author reviewer
#14 lore raw

Re: [PATCH 2/2] perf: Disable the event on a truncated AUX record

Quoted 10 lines · Peter Zijlstra
Quoted 7 lines · Alexander Shishkin
Quoted 2 lines · Peter Zijlstra

Does the userspace tool know how to deal with this and re-enable it?

Yes, it knows to ioctl(EVENT_ENABLE). Also, we're already doing the disabling for the no-room-in-buffer condition in perf_aux_output_begin().

Awesome; gots them queued.

Much thanks!

Regards,
--
Alex

#15 lore raw

[tip:perf/core] perf/core: Disable the event on a truncated AUX record

In reply to Alexander Shishkin
perf/core: Disable the event on a truncated AUX record
Commit-ID:  3f56e687a138481894a1088d5aa7d41951bdb020
Gitweb:     http://git.kernel.org/tip/3f56e687a138481894a1088d5aa7d41951bdb020
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:33 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 10:14:55 +0200

perf/core: Disable the event on a truncated AUX record

When the PMU driver reports a truncated AUX record, it effectively means that there is no more usable room in the event's AUX buffer (even though there may still be some room, so that perf_aux_output_begin() doesn't take action). At this point the consumer still has to be woken up and the event has to be disabled, otherwise the event will just keep spinning between perf_aux_output_begin() and perf_aux_output_end() until its context gets unscheduled.

Again, for cpu-wide events this means never, so once in this condition, they will be forever losing data.

Fix this by disabling the event and waking up the consumer in case of a truncated AUX record.

---
 kernel/events/ring_buffer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/events/ring_buffer.c +9 -1
index c49bab4..ae9b90d 100644
@@ -405,6 +405,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 			 bool truncated)
 {
 	struct ring_buffer *rb = handle->rb;
+	bool wakeup = truncated;
 	unsigned long aux_head;
 	u64 flags = 0;
 
@@ -433,9 +434,16 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 	aux_head = rb->user_page->aux_head = local_read(&rb->aux_head);
 
 	if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) {
-		perf_output_wakeup(handle);
+		wakeup = true;
 		local_add(rb->aux_watermark, &rb->aux_wakeup);
 	}
+
+	if (wakeup) {
+		if (truncated)
+			handle->event->pending_disable = 1;
+		perf_output_wakeup(handle);
+	}
+
 	handle->event = NULL;
 
 	local_set(&rb->aux_nest, 0);
#16 lore raw

[tip:perf/urgent] perf/core: Disable the event on a truncated AUX record

In reply to Alexander Shishkin
perf/core: Disable the event on a truncated AUX record
Commit-ID:  9f448cd3cbcec8995935e60b27802ae56aac8cc0
Gitweb:     http://git.kernel.org/tip/9f448cd3cbcec8995935e60b27802ae56aac8cc0
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 10 May 2016 16:18:33 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 May 2016 14:46:11 +0200

perf/core: Disable the event on a truncated AUX record

When the PMU driver reports a truncated AUX record, it effectively means that there is no more usable room in the event's AUX buffer (even though there may still be some room, so that perf_aux_output_begin() doesn't take action). At this point the consumer still has to be woken up and the event has to be disabled, otherwise the event will just keep spinning between perf_aux_output_begin() and perf_aux_output_end() until its context gets unscheduled.

Again, for cpu-wide events this means never, so once in this condition, they will be forever losing data.

Fix this by disabling the event and waking up the consumer in case of a truncated AUX record.

---
 kernel/events/ring_buffer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/events/ring_buffer.c +9 -1
index c61f0cb..7611d0f 100644
@@ -347,6 +347,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 			 bool truncated)
 {
 	struct ring_buffer *rb = handle->rb;
+	bool wakeup = truncated;
 	unsigned long aux_head;
 	u64 flags = 0;
 
@@ -375,9 +376,16 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
 	aux_head = rb->user_page->aux_head = local_read(&rb->aux_head);
 
 	if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) {
-		perf_output_wakeup(handle);
+		wakeup = true;
 		local_add(rb->aux_watermark, &rb->aux_wakeup);
 	}
+
+	if (wakeup) {
+		if (truncated)
+			handle->event->pending_disable = 1;
+		perf_output_wakeup(handle);
+	}
+
 	handle->event = NULL;
 
 	local_set(&rb->aux_nest, 0);