Patch "tracing: Make trace_marker{,_raw} stream-like" 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: Make trace_marker{,_raw} stream-like

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-make-trace_marker-_raw-stream-like.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.



commit 742e4e870af5dfe2b163eb5e6b7ba745d4e4f139
Author: John Keeping <john@xxxxxxxxxxxxx>
Date:   Tue Dec 7 14:25:58 2021 +0000

    tracing: Make trace_marker{,_raw} stream-like
    
    [ Upstream commit 2972e3050e3517a85ca1813b227d4c302e804343 ]
    
    The tracing marker files are write-only streams with no meaningful
    concept of file position.  Using stream_open() to mark them as
    stream-link indicates this and has the added advantage that a single
    file descriptor can now be used from multiple threads without contention
    thanks to clearing FMODE_ATOMIC_POS.
    
    Note that this has the potential to break existing userspace by since
    both lseek(2) and pwrite(2) will now return ESPIPE when previously lseek
    would have updated the stored offset and pwrite would have appended to
    the trace.  A survey of libtracefs and several other projects found to
    use trace_marker(_raw) [1][2][3] suggests that everyone limits
    themselves to calling write(2) and close(2) on these file descriptors so
    there is a good chance this will go unnoticed and the benefits of
    reduced overhead and lock contention seem worth the risk.
    
    [1] https://github.com/google/perfetto
    [2] https://github.com/intel/media-driver/
    [3] https://w1.fi/cgit/hostap/
    
    Link: https://lkml.kernel.org/r/20211207142558.347029-1-john@xxxxxxxxxxxx
    
    Signed-off-by: John Keeping <john@xxxxxxxxxxxx>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
    Stable-dep-of: f5ca233e2e66 ("tracing: Increase trace array ref count on enable and filter files")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6adacfc880d6c..5aa23a4382c5e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4887,6 +4887,12 @@ int tracing_open_generic_tr(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+static int tracing_mark_open(struct inode *inode, struct file *filp)
+{
+	stream_open(inode, filp);
+	return tracing_open_generic_tr(inode, filp);
+}
+
 static int tracing_release(struct inode *inode, struct file *file)
 {
 	struct trace_array *tr = inode->i_private;
@@ -7225,9 +7231,6 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 	if (tt)
 		event_triggers_post_call(tr->trace_marker_file, tt);
 
-	if (written > 0)
-		*fpos += written;
-
 	return written;
 }
 
@@ -7286,9 +7289,6 @@ tracing_mark_raw_write(struct file *filp, const char __user *ubuf,
 
 	__buffer_unlock_commit(buffer, event);
 
-	if (written > 0)
-		*fpos += written;
-
 	return written;
 }
 
@@ -7699,16 +7699,14 @@ static const struct file_operations tracing_free_buffer_fops = {
 };
 
 static const struct file_operations tracing_mark_fops = {
-	.open		= tracing_open_generic_tr,
+	.open		= tracing_mark_open,
 	.write		= tracing_mark_write,
-	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
 
 static const struct file_operations tracing_mark_raw_fops = {
-	.open		= tracing_open_generic_tr,
+	.open		= tracing_mark_open,
 	.write		= tracing_mark_raw_write,
-	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
 



[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