From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
John Keeping <john@metanate.com>
Subject: [for-next][PATCH 01/11] tracing: Make trace_marker{,_raw} stream-like
Date: Sat, 11 Dec 2021 20:26:18 -0500 [thread overview]
Message-ID: <20211212012644.746059161@goodmis.org> (raw)
In-Reply-To: 20211212012617.690710310@goodmis.org
From: John Keeping <john@metanate.com>
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@metanate.com
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e3b8c906b7b4..588de6df473f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4841,6 +4841,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;
@@ -7117,9 +7123,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;
}
@@ -7178,9 +7181,6 @@ tracing_mark_raw_write(struct file *filp, const char __user *ubuf,
__buffer_unlock_commit(buffer, event);
- if (written > 0)
- *fpos += written;
-
return written;
}
@@ -7580,16 +7580,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,
};
--
2.33.0
next prev parent reply other threads:[~2021-12-12 1:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 1:26 [for-next][PATCH 00/11] tracing: More updates for 5.17 Steven Rostedt
2021-12-12 1:26 ` Steven Rostedt [this message]
2021-12-12 1:26 ` [for-next][PATCH 02/11] script/sorttable: Code style improvements Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 03/11] tracefs: Use d_inode() helper function to get the dentry inode Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 04/11] tracing: Iterate trace_[ku]probe objects directly Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 05/11] tracing: Do not let synth_events block other dyn_event systems during create Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 06/11] tracing: Use memset_startat helper in trace_iterator_reset() Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 07/11] tracing: Use trace_iterator_reset() in tracing_read_pipe() Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 08/11] tracing: Change event_command func() to parse() Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 09/11] tracing: Change event_trigger_ops func() to trigger() Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 10/11] tracing: Add helper functions to simplify event_command.parse() callback handling Steven Rostedt
2021-12-12 1:26 ` [for-next][PATCH 11/11] tracing: Have existing event_command.parse() implementations use helpers Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211212012644.746059161@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=john@metanate.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.