From: Joel Fernandes <joel@joelfernandes.org>
To: linux-trace-devel@vger.kernel.org
Cc: vineethrp@google.com, rostedt@goodmis.org, tz.stoyanov@gmail.com,
Joel Fernandes <joel@joelfernandes.org>
Subject: [PATCH v2] trace-cmd: Move trace_msg cache file to memfd
Date: Sun, 3 Apr 2022 23:18:25 +0000 [thread overview]
Message-ID: <20220403231825.1258376-1-joel@joelfernandes.org> (raw)
This is cleaner and also fixes issues in Android where /tmp does not
exist.
With this, host-guest tracing works on Android VM running on ChromeOS
Linux.
Signed-off-by: Joel Fernandes <joel@joelfernandes.org>
---
lib/trace-cmd/include/private/trace-cmd-private.h | 2 --
lib/trace-cmd/trace-msg.c | 4 +---
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 6934376..3aee139 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -377,7 +377,6 @@ enum tracecmd_msg_flags {
};
/* for both client and server */
-#define MSG_CACHE_FILE "/tmp/trace_msg_cacheXXXXXX"
struct tracecmd_msg_handle {
int fd;
short cpu_count;
@@ -386,7 +385,6 @@ struct tracecmd_msg_handle {
bool done;
bool cache;
int cfd;
- char cfile[sizeof(MSG_CACHE_FILE)];
};
struct tracecmd_tsync_protos {
diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c
index 03b853e..1472f20 100644
--- a/lib/trace-cmd/trace-msg.c
+++ b/lib/trace-cmd/trace-msg.c
@@ -593,11 +593,9 @@ tracecmd_msg_handle_alloc(int fd, unsigned long flags)
int tracecmd_msg_handle_cache(struct tracecmd_msg_handle *msg_handle)
{
if (msg_handle->cfd < 0) {
- strcpy(msg_handle->cfile, MSG_CACHE_FILE);
- msg_handle->cfd = mkstemp(msg_handle->cfile);
+ msg_handle->cfd = memfd_create("trace_msg_cache", 0);
if (msg_handle->cfd < 0)
return -1;
- unlink(msg_handle->cfile);
}
msg_handle->cache = true;
return 0;
--
2.35.1.1094.g7c7d902a7c-goog
next reply other threads:[~2022-04-03 23:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 23:18 Joel Fernandes [this message]
2022-04-04 18:34 ` [PATCH v2] trace-cmd: Move trace_msg cache file to memfd 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=20220403231825.1258376-1-joel@joelfernandes.org \
--to=joel@joelfernandes.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tz.stoyanov@gmail.com \
--cc=vineethrp@google.com \
/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).