trace-cmd library: Use tracefs_cpu for recorder helpers
PATCH 1/1 trace-cmd library: Use tracefs_cpu for recorder helpers
From: "Steven Rostedt (Google)" <[email protected]>
Use the API from libtracefs on tracefs_cpu that is used for reading from the trace_pipe_raw files for the recorder.
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- Makefile | 2 +- .../include/private/trace-cmd-private.h | 6 +- lib/trace-cmd/trace-recorder.c | 325 ++++-------------- tracecmd/trace-record.c | 34 +- 4 files changed, 68 insertions(+), 299 deletions(-)
Makefile +1 -1
@@ -23,7 +23,7 @@ export LIBTRACECMD_VERSION VERSION_FILE = ltc_version.h LIBTRACEEVENT_MIN_VERSION = 1.5 -LIBTRACEFS_MIN_VERSION = 1.4 +LIBTRACEFS_MIN_VERSION = 1.6 MAKEFLAGS += --no-print-directory
lib/trace-cmd/include/private/trace-cmd-private.h +3 -3
@@ -371,9 +371,9 @@ struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu, unstruct tracecmd_recorder *tracecmd_create_recorder_fd (int fd,int cpu,unsigned flags);struct tracecmd_recorder *tracecmd_create_recorder_virt (const char *file,int cpu,unsigned flags,int trace_fd);struct tracecmd_recorder *tracecmd_create_recorder_maxkb (const char *file,int cpu,unsigned flags,int maxkb); -struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd (int fd,int cpu,unsigned flags,const char *buffer); -struct tracecmd_recorder *tracecmd_create_buffer_recorder (const char *file,int cpu,unsigned flags,const char *buffer); -struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb (const char *file,int cpu,unsigned flags,const char *buffer,int maxkb); +struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd (int fd,int cpu,unsigned flags,struct tracefs_instance *instance); +struct tracecmd_recorder *tracecmd_create_buffer_recorder (const char *file,int cpu,unsigned flags,struct tracefs_instance *instance); +struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb (const char *file,int cpu,unsigned flags,struct tracefs_instance *instance,int maxkb);int tracecmd_start_recording (struct tracecmd_recorder *recorder,unsigned long sleep);void tracecmd_stop_recording (struct tracecmd_recorder *recorder);
lib/trace-cmd/trace-recorder.c +58 -267
489 lines not on this page · raw message
tracecmd/trace-record.c +6 -28
@@ -3326,19 +3326,11 @@ create_recorder_instance_pipe(struct buffer_instance *instance, {struct tracecmd_recorder *recorder;unsigned flags = recorder_flags |TRACECMD_RECORD_BLOCK_SPLICE ; -char *path; - - path =tracefs_instance_get_dir (instance->tracefs); - -if (!path) -die ("malloc" );/* This is already the child */ close (brass[0 ]); - recorder =tracecmd_create_buffer_recorder_fd (brass[1 ], cpu, flags, path); - -tracefs_put_tracing_file (path); + recorder =tracecmd_create_buffer_recorder_fd (brass[1 ], cpu, flags, instance->tracefs);return recorder; }
@@ -3349,7 +3341,6 @@ create_recorder_instance(struct buffer_instance *instance, const char *file, int {struct tracecmd_recorder *record;struct addrinfo *result; -char *path;if (is_guest (instance)) {int fd;
@@ -3386,12 +3377,8 @@ create_recorder_instance(struct buffer_instance *instance, const char *file, intif (!tracefs_instance_get_name (instance->tracefs))return tracecmd_create_recorder_maxkb (file, cpu, recorder_flags, max_kb); - path =tracefs_instance_get_dir (instance->tracefs); - record =tracecmd_create_buffer_recorder_maxkb (file, cpu, recorder_flags, - path, max_kb); -tracefs_put_tracing_file (path); - + instance->tracefs, max_kb);return record; }
@@ -3402,6 +3389,7 @@ create_recorder_instance(struct buffer_instance *instance, const char *file, intstatic int create_recorder (struct buffer_instance *instance,int cpu,enum trace_type type,int *brass) { +struct tracefs_instance *recorder_instance =NULL ;long ret;char *file;pid_t pid;
@@ -3427,7 +3415,6 @@ static int create_recorder(struct buffer_instance *instance, int cpu,if ((instance->client_ports && !is_guest (instance)) ||is_agent (instance)) {unsigned int flags = recorder_flags; -char *path =NULL ;int fd;if (is_agent (instance)) {
@@ -3449,19 +3436,10 @@ static int create_recorder(struct buffer_instance *instance, int cpu, }if (fd <0 )die ("Failed connecting to client" ); -if (tracefs_instance_get_name (instance->tracefs) && !is_agent (instance)) { - path =tracefs_instance_get_dir (instance->tracefs); - }else { -const char *dir =tracefs_tracing_dir (); +if (tracefs_instance_get_name (instance->tracefs) && !is_agent (instance)) + recorder_instance = instance->tracefs; -if (dir) - path =strdup (dir); - } -if (!path) -die ("can't get the tracing directory" ); - - recorder =tracecmd_create_buffer_recorder_fd (fd, cpu, flags, path); -tracefs_put_tracing_file (path); + recorder =tracecmd_create_buffer_recorder_fd (fd, cpu, flags, recorder_instance); }else { file =get_temp_file (instance, cpu); recorder =create_recorder_instance (instance, file, cpu, brass);
Signature · 1 line
2.35.1