Patch "tracing: Wake up ring buffer waiters on closing of the file" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing: Wake up ring buffer waiters on closing of the file

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-wake-up-ring-buffer-waiters-on-closing-of-the-file.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From f3ddb74ad0790030c9592229fb14d8c451f4e9a8 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>
Date: Tue, 27 Sep 2022 19:15:27 -0400
Subject: tracing: Wake up ring buffer waiters on closing of the file

From: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>

commit f3ddb74ad0790030c9592229fb14d8c451f4e9a8 upstream.

When the file that represents the ring buffer is closed, there may be
waiters waiting on more input from the ring buffer. Call
ring_buffer_wake_waiters() to wake up any waiters when the file is
closed.

Link: https://lkml.kernel.org/r/20220927231825.182416969@xxxxxxxxxxx

Cc: stable@xxxxxxxxxxxxxxx
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice")
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 include/linux/trace_events.h |    1 +
 kernel/trace/trace.c         |   15 +++++++++++++++
 2 files changed, 16 insertions(+)

--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -91,6 +91,7 @@ struct trace_iterator {
 	unsigned int		temp_size;
 	char			*fmt;	/* modified format holder */
 	unsigned int		fmt_size;
+	long			wait_index;
 
 	/* trace_seq for __print_flags() and __print_symbolic() etc. */
 	struct trace_seq	tmp_seq;
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8117,6 +8117,12 @@ static int tracing_buffers_release(struc
 
 	__trace_array_put(iter->tr);
 
+	iter->wait_index++;
+	/* Make sure the waiters see the new wait_index */
+	smp_wmb();
+
+	ring_buffer_wake_waiters(iter->array_buffer->buffer, iter->cpu_file);
+
 	if (info->spare)
 		ring_buffer_free_read_page(iter->array_buffer->buffer,
 					   info->spare_cpu, info->spare);
@@ -8270,6 +8276,8 @@ tracing_buffers_splice_read(struct file
 
 	/* did we read anything? */
 	if (!spd.nr_pages) {
+		long wait_index;
+
 		if (ret)
 			goto out;
 
@@ -8277,10 +8285,17 @@ tracing_buffers_splice_read(struct file
 		if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
 			goto out;
 
+		wait_index = READ_ONCE(iter->wait_index);
+
 		ret = wait_on_pipe(iter, iter->tr->buffer_percent);
 		if (ret)
 			goto out;
 
+		/* Make sure we see the new wait_index */
+		smp_rmb();
+		if (wait_index != iter->wait_index)
+			goto out;
+
 		goto again;
 	}
 


Patches currently in stable-queue which might be from rostedt@xxxxxxxxxxx are

queue-5.15/tracing-fix-reading-strings-from-synthetic-events.patch
queue-5.15/tracing-add-ioctl-to-force-ring-buffer-waiters-to-wake-up.patch
queue-5.15/ring-buffer-have-the-shortest_full-queue-be-the-shortest-not-longest.patch
queue-5.15/ring-buffer-add-ring_buffer_wake_waiters.patch
queue-5.15/tracing-move-duplicate-code-of-trace_kprobe-eprobe.c-into-header.patch
queue-5.15/tracing-add-fault-name-injection-to-kernel-probes.patch
queue-5.15/ring-buffer-fix-race-between-reset-page-and-reading-page.patch
queue-5.15/tracing-wake-up-ring-buffer-waiters-on-closing-of-the-file.patch
queue-5.15/tracing-disable-interrupt-or-preemption-before-acquiring-arch_spinlock_t.patch
queue-5.15/tracing-wake-up-waiters-when-tracing-is-disabled.patch
queue-5.15/ring-buffer-allow-splice-to-read-previous-partially-read-pages.patch
queue-5.15/ring-buffer-check-pending-waiters-when-doing-wake-ups-as-well.patch
queue-5.15/ftrace-properly-unset-ftrace_hash_fl_mod.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux