linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Christian Brauner <brauner@kernel.org>,
	Ajay Kaher <ajay.kaher@broadcom.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH] eventfs: Give files a default of PAGE_SIZE size
Date: Fri, 26 Jan 2024 13:18:37 -0500	[thread overview]
Message-ID: <20240126131837.36dbecc8@gandalf.local.home> (raw)

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The sqlhist utility[1] (or the new trace-cmd sqlhist command[2]) creates
the commands of a synthetic event based on the files in the tracefs/events
directory. When creating these commands for an embedded system, it is
asked to copy the files to the temp directory, tar them up and send them
to the main machine. Ideally, tar could be used directly without copying
them to the /tmp directory. But because the sizes presented by the inodes
are of size '0' the tar just copies zero bytes of the file making it
useless.

By following what sysfs does, and give files a default size of PAGE_SIZE,
it allows the tar to work. No event file is greater than PAGE_SIZE.

Although tar will give an error of:

 tar: events/raw_syscalls/filter: File shrank by 3904 bytes; padding with zeros

Which is consistent to the error it gives to sysfs as well:

~# (cd /sys/ && tar cf - firmware) | tar xf -
 [..]
 tar: firmware/acpi/interrupts/ff_slp_btn: File shrank by 4057 bytes; padding with zeros

But only add size if the file can be open for read. It doesn't make sense
for files that are write-only.

[1] https://trace-cmd.org/Documentation/libtracefs/libtracefs-sqlhist.html
[2] https://trace-cmd.org/Documentation/trace-cmd/trace-cmd-sqlhist.1.html

Link: https://lore.kernel.org/all/CAMuHMdU-+RmngWJwpHYPjVcaOe3NO37Cu8msLvqePdbyk8qmZA@mail.gmail.com/

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 fs/tracefs/event_inode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 7be7a694b106..013b8af40a4f 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -363,6 +363,8 @@ static struct dentry *create_file(const char *name, umode_t mode,
 	inode->i_fop = fop;
 	inode->i_private = data;
 	inode->i_ino = ino;
+	if (mode & (S_IRUSR | S_IRGRP | S_IROTH))
+		inode->i_size = PAGE_SIZE;
 
 	ti = get_tracefs(inode);
 	ti->flags |= TRACEFS_EVENT_INODE;
-- 
2.43.0


             reply	other threads:[~2024-01-26 18:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 18:18 Steven Rostedt [this message]
2024-01-26 18:31 ` [PATCH] eventfs: Give files a default of PAGE_SIZE size Linus Torvalds
2024-01-26 18:41   ` Steven Rostedt
2024-01-26 19:06     ` Linus Torvalds
2024-01-26 19:37       ` 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=20240126131837.36dbecc8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=ajay.kaher@broadcom.com \
    --cc=brauner@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).