Skip to content

Commit e36f19a

Browse files
committed
ring-buffer: Reuse rb_watermark_hit() for the poll logic
The check for knowing if the poll should wait or not is basically the exact same logic as rb_watermark_hit(). The only difference is that rb_watermark_hit() also handles the !full case. But for the full case, the logic is the same. Just call that instead of duplicating the code in ring_buffer_poll_wait(). Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 8145f1c commit e36f19a

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

kernel/trace/ring_buffer.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -960,25 +960,18 @@ __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu,
960960
}
961961

962962
if (full) {
963-
unsigned long flags;
964-
965963
poll_wait(filp, &rbwork->full_waiters, poll_table);
966964

967-
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
968-
if (!cpu_buffer->shortest_full ||
969-
cpu_buffer->shortest_full > full)
970-
cpu_buffer->shortest_full = full;
971-
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
972-
if (full_hit(buffer, cpu, full))
965+
if (rb_watermark_hit(buffer, cpu, full))
973966
return EPOLLIN | EPOLLRDNORM;
974967
/*
975968
* Only allow full_waiters_pending update to be seen after
976-
* the shortest_full is set. If the writer sees the
977-
* full_waiters_pending flag set, it will compare the
978-
* amount in the ring buffer to shortest_full. If the amount
979-
* in the ring buffer is greater than the shortest_full
980-
* percent, it will call the irq_work handler to wake up
981-
* this list. The irq_handler will reset shortest_full
969+
* the shortest_full is set (in rb_watermark_hit). If the
970+
* writer sees the full_waiters_pending flag set, it will
971+
* compare the amount in the ring buffer to shortest_full.
972+
* If the amount in the ring buffer is greater than the
973+
* shortest_full percent, it will call the irq_work handler
974+
* to wake up this list. The irq_handler will reset shortest_full
982975
* back to zero. That's done under the reader_lock, but
983976
* the below smp_mb() makes sure that the update to
984977
* full_waiters_pending doesn't leak up into the above.

0 commit comments

Comments
 (0)