From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v3 5/6] libtracefs: Add new tracefs API tracefs_instances_walk()
Date: Thu, 12 Nov 2020 14:17:28 -0500 [thread overview]
Message-ID: <20201112141728.20e3607e@gandalf.local.home> (raw)
In-Reply-To: <20201112091109.1239169-6-tz.stoyanov@gmail.com>
On Thu, 12 Nov 2020 11:11:08 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
> The logic for finding all configured ftrace instances is encapuslated in
> a new tracefs_instances_walk() API. A user specified callback is
> called for each ftrace instance in the system, excpet for the top level
> one.
> The implementation of "trace-cmd stat" is modified to use the new API.
>
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
> include/tracefs/tracefs.h | 1 +
> lib/tracefs/include/tracefs-local.h | 1 +
> lib/tracefs/tracefs-events.c | 14 ++++----
> lib/tracefs/tracefs-instance.c | 55 +++++++++++++++++++++++++++++
> tracecmd/trace-stat.c | 52 +++++++--------------------
> utest/tracefs-utest.c | 52 +++++++++++++++++++++++++++
> 6 files changed, 129 insertions(+), 46 deletions(-)
>
> diff --git a/include/tracefs/tracefs.h b/include/tracefs/tracefs.h
> index 388d8f94..bcf3dd64 100644
> --- a/include/tracefs/tracefs.h
> +++ b/include/tracefs/tracefs.h
> @@ -32,6 +32,7 @@ int tracefs_instance_file_write(struct tracefs_instance *instance,
> const char *file, const char *str);
> char *tracefs_instance_file_read(struct tracefs_instance *instance,
> char *file, int *psize);
> +int tracefs_instances_walk(int (*callback)(const char *, void *), void *context);
>
> bool tracefs_instance_exists(const char *name);
> bool tracefs_file_exists(struct tracefs_instance *instance, char *name);
> diff --git a/lib/tracefs/include/tracefs-local.h b/lib/tracefs/include/tracefs-local.h
> index fe327a0f..08b67fa9 100644
> --- a/lib/tracefs/include/tracefs-local.h
> +++ b/lib/tracefs/include/tracefs-local.h
> @@ -9,5 +9,6 @@
> /* Can be overridden */
> void warning(const char *fmt, ...);
> int str_read_file(const char *file, char **buffer);
> +char *trace_append_file(const char *dir, const char *name);
>
> #endif /* _TRACE_FS_LOCAL_H */
> diff --git a/lib/tracefs/tracefs-events.c b/lib/tracefs/tracefs-events.c
> index 6b796382..f2c6046c 100644
> --- a/lib/tracefs/tracefs-events.c
> +++ b/lib/tracefs/tracefs-events.c
> @@ -210,7 +210,7 @@ static char **add_list_string(char **list, const char *name, int len)
> return list;
> }
>
> -static char *append_file(const char *dir, const char *name)
> +char *trace_append_file(const char *dir, const char *name)
We should get into the habit of adding "__hidden" to anything that is not
static but also not visible outside the library.
-- Steve
> {
> char *file;
> int ret;
> @@ -265,7 +265,7 @@ char **tracefs_event_systems(const char *tracing_dir)
> if (!tracing_dir)
> return NULL;
>
> - events_dir = append_file(tracing_dir, "events");
> + events_dir = trace_append_file(tracing_dir, "events");
> if (!events_dir)
> return NULL;
>
> @@ -290,14 +290,14 @@ char **tracefs_event_systems(const char *tracing_dir)
> strcmp(name, "..") == 0)
> continue;
>
> - sys = append_file(events_dir, name);
> + sys = trace_append_file(events_dir, name);
> ret = stat(sys, &st);
> if (ret < 0 || !S_ISDIR(st.st_mode)) {
> free(sys);
> continue;
> }
>
> - enable = append_file(sys, "enable");
> + enable = trace_append_file(sys, "enable");
>
> ret = stat(enable, &st);
> if (ret >= 0)
> @@ -359,7 +359,7 @@ char **tracefs_system_events(const char *tracing_dir, const char *system)
> strcmp(name, "..") == 0)
> continue;
>
> - event = append_file(system_dir, name);
> + event = trace_append_file(system_dir, name);
> ret = stat(event, &st);
> if (ret < 0 || !S_ISDIR(st.st_mode)) {
> free(event);
> @@ -401,7 +401,7 @@ char **tracefs_tracers(const char *tracing_dir)
> if (!tracing_dir)
> return NULL;
>
> - available_tracers = append_file(tracing_dir, "available_tracers");
> + available_tracers = trace_append_file(tracing_dir, "available_tracers");
> if (!available_tracers)
> return NULL;
>
> @@ -493,7 +493,7 @@ static int read_header(struct tep_handle *tep, const char *tracing_dir)
> int len;
> int ret = -1;
>
> - header = append_file(tracing_dir, "events/header_page");
> + header = trace_append_file(tracing_dir, "events/header_page");
>
> ret = stat(header, &st);
> if (ret < 0)
>
next prev parent reply other threads:[~2020-11-12 19:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 9:11 [PATCH v3 0/6] libtracefs fixes and improvements Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 1/6] trace-cmd: Change tracefs.h include path Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 2/6] libtracefs: Change get name API to return constant string Tzvetomir Stoyanov (VMware)
2020-11-12 19:10 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 3/6] libtracefs: Add new API to check if instance exists Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 4/6] libtracefs: Combine allocate and create APIs into one Tzvetomir Stoyanov (VMware)
2020-11-12 19:14 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 5/6] libtracefs: Add new tracefs API tracefs_instances_walk() Tzvetomir Stoyanov (VMware)
2020-11-12 19:17 ` Steven Rostedt [this message]
2020-11-12 9:11 ` [PATCH v3 6/6] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)
2020-11-12 19:23 ` 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=20201112141728.20e3607e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@gmail.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).