* [PATCH v2] trace-cmd: Move trace_msg cache file to memfd
@ 2022-04-03 23:18 Joel Fernandes
2022-04-04 18:34 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Joel Fernandes @ 2022-04-03 23:18 UTC (permalink / raw)
To: linux-trace-devel; +Cc: vineethrp, rostedt, tz.stoyanov, Joel Fernandes
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] trace-cmd: Move trace_msg cache file to memfd
2022-04-03 23:18 [PATCH v2] trace-cmd: Move trace_msg cache file to memfd Joel Fernandes
@ 2022-04-04 18:34 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2022-04-04 18:34 UTC (permalink / raw)
To: Joel Fernandes; +Cc: linux-trace-devel, vineethrp, tz.stoyanov
On Sun, 3 Apr 2022 23:18:25 +0000
Joel Fernandes <joel@joelfernandes.org> wrote:
> +++ 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);
> }
This causes:
trace-profile.c:23:3: warning: #warning "lib audit not found, using raw syscalls " "(install audit-libs-devel(for fedora) or libaudit-dev(for debian/ubuntu) and try again)" [-Wcpp]
23 | # warning "lib audit not found, using raw syscalls " \
| ^~~~~~~
Care to send a v3 update?
Man page shows:
SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <sys/mman.h>
int memfd_create(const char *name, unsigned int flags);
Note, all of trace-cmd is compiled with _GNU_SOURCE set.
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-04 21:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03 23:18 [PATCH v2] trace-cmd: Move trace_msg cache file to memfd Joel Fernandes
2022-04-04 18:34 ` Steven Rostedt
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.