From: Steven Rostedt <rostedt@goodmis.org>
To: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Tao Zhou <tao.zhou@linux.dev>, Ingo Molnar <mingo@redhat.com>,
Tom Zanussi <zanussi@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>,
Clark Williams <williams@redhat.com>,
John Kacur <jkacur@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-rt-users@vger.kernel.org,
linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V7 02/14] rtla: Helper functions for rtla
Date: Wed, 24 Nov 2021 16:37:59 -0500 [thread overview]
Message-ID: <20211124163759.6d118d96@gandalf.local.home> (raw)
In-Reply-To: <1eb27af1d8356d17d1f8a69a362da46ae8594ab0.1635535309.git.bristot@kernel.org>
On Fri, 29 Oct 2021 21:26:05 +0200
Daniel Bristot de Oliveira <bristot@kernel.org> wrote:
> +/*
> + * enable_tracer_by_name - enable a tracer on the given instance
> + */
> +int enable_tracer_by_name(struct tracefs_instance *inst, const char *tracer)
> +{
> + enum tracefs_tracers t;
> + int retval;
> +
> + t = TRACEFS_TRACER_CUSTOM;
> +
> + debug_msg("enabling %s tracer\n", tracer);
> +
> + retval = tracefs_tracer_set(inst, t, tracer);
Interesting. We had discussions about having the custom option (which I
fought for, for this very reason).
> + if (retval < 0) {
> + if (errno == ENODEV)
> + err_msg("tracer %s not found!\n", tracer);
> +
> + err_msg("failed to enable the tracer %s\n", tracer);
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +/*
> + * disable_tracer - set nop tracer to the insta
> + */
> +void disable_tracer(struct tracefs_instance *inst)
> +{
> + enum tracefs_tracers t = TRACEFS_TRACER_NOP;
> + int retval;
> +
> + retval = tracefs_tracer_set(inst, t);
> + if (retval < 0)
> + err_msg("oops, error disabling tracer\n");
> +}
> +
> +/*
> + * create_instance - create a trace instance with *instance_name
> + */
> +struct tracefs_instance *create_instance(char *instance_name)
> +{
> + return tracefs_instance_create(instance_name);
> +}
> +
> +/*
> + * destroy_instance - remove a trace instance and free the data
> + */
> +void destroy_instance(struct tracefs_instance *inst)
> +{
> + tracefs_instance_destroy(inst);
> + tracefs_instance_free(inst);
> +}
> +
> +/*
> + * save_trace_to_file - save the trace output of the instance to the file
> + */
> +int save_trace_to_file(struct tracefs_instance *inst, const char *filename)
> +{
> + const char *file = "trace";
> + mode_t mode = 0644;
> + char *buffer[4096];
Did you really mean to have buffer be 4096 strings?
Or did you mean:
char buffer[4096];
(i.e. a single string of 4096 size)?
-- Steve
> + int out_fd, in_fd;
> + int retval = -1;
> +
> + in_fd = tracefs_instance_file_open(inst, file, O_RDONLY);
> + if (in_fd < 0) {
> + err_msg("Failed to open trace file\n");
> + return -1;
> + }
> +
> + out_fd = creat(filename, mode);
> + if (out_fd < 0) {
> + err_msg("Failed to create output file %s\n", filename);
> + goto out_close_in;
> + }
> +
> + do {
> + retval = read(in_fd, buffer, sizeof(buffer));
> + if (retval <= 0)
> + goto out_close;
> +
> + retval = write(out_fd, buffer, retval);
> + if (retval < 0)
> + goto out_close;
> + } while (retval > 0);
> +
> + retval = 0;
> +out_close:
> + close(out_fd);
> +out_close_in:
> + close(in_fd);
> + return retval;
> +}
> +
> +/*
next prev parent reply other threads:[~2021-11-24 21:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 19:26 [PATCH V7 00/14] RTLA: An interface for osnoise/timerlat tracers Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 01/14] rtla: Real-Time Linux Analysis tool Daniel Bristot de Oliveira
2021-11-24 21:28 ` Steven Rostedt
2021-11-25 13:37 ` Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 02/14] rtla: Helper functions for rtla Daniel Bristot de Oliveira
2021-11-24 21:37 ` Steven Rostedt [this message]
2021-11-25 13:42 ` Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 03/14] rtla: Add osnoise tool Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 04/14] rtla/osnoise: Add osnoise top mode Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 05/14] rtla/osnoise: Add the hist mode Daniel Bristot de Oliveira
2021-11-24 22:12 ` Steven Rostedt
2021-11-24 22:15 ` Steven Rostedt
2021-11-25 13:45 ` Daniel Bristot de Oliveira
2021-11-25 14:20 ` Steven Rostedt
2021-11-25 14:30 ` Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 06/14] rtla: Add timerlat tool and timelart top mode Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 07/14] rtla/timerlat: Add timerlat hist mode Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 08/14] rtla: Add Documentation Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 09/14] rtla: Add rtla osnoise man page Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 10/14] rtla: Add rtla osnoise top documentation Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 11/14] rtla: Add rtla osnoise hist documentation Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 12/14] rtla: Add rtla timerlat documentation Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 13/14] rtla: Add rtla timerlat top documentation Daniel Bristot de Oliveira
2021-10-29 19:26 ` [PATCH V7 14/14] rtla: Add rtla timerlat hist documentation Daniel Bristot de Oliveira
2021-11-24 22:11 ` [PATCH V7 00/14] RTLA: An interface for osnoise/timerlat tracers Steven Rostedt
2021-11-25 13:46 ` Daniel Bristot de Oliveira
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=20211124163759.6d118d96@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=bigeasy@linutronix.de \
--cc=bristot@kernel.org \
--cc=jkacur@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tao.zhou@linux.dev \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
--cc=zanussi@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 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).