From: Steven Rostedt <rostedt@goodmis.org>
To: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>,
Sameeruddin shaik <sameeruddin.shaik8@gmail.com>
Subject: Re: [PATCH 2/3] libtracefs: Add tracefs_function_notrace() API
Date: Thu, 8 Apr 2021 08:53:40 -0400 [thread overview]
Message-ID: <20210408085340.5e84064f@gandalf.local.home> (raw)
In-Reply-To: <CAPpZLN5Lmc6QegJrLLzXsbu-bDtAVovnSF+=NZpr8E53K-JLYQ@mail.gmail.com>
On Thu, 8 Apr 2021 07:25:20 +0300
Tzvetomir Stoyanov <tz.stoyanov@gmail.com> wrote:
> > diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
> > index bf2fabf..9f45624 100644
> > --- a/src/tracefs-instance.c
> > +++ b/src/tracefs-instance.c
> > @@ -44,6 +44,7 @@ static struct tracefs_instance *instance_alloc(const char *trace_dir, const char
> > }
> >
> > instance->ftrace_filter_fd = -1;
> > + instance->ftrace_notrace_fd = -1;
>
> These descriptors should be closed in tracefs_instance_free(), as part
> of the instance cleanup.
Good point. I'll add a patch on top of this one to close both of them.
>
> >
> > return instance;
> >
> > diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c
> > index 21a9bd3..b41806b 100644
> > --- a/src/tracefs-tools.c
> > +++ b/src/tracefs-tools.c
> > @@ -21,10 +21,12 @@
> >
> > #define TRACE_CTRL "tracing_on"
> > #define TRACE_FILTER "set_ftrace_filter"
> > +#define TRACE_NOTRACE "set_ftrace_notrace"
> > #define TRACE_FILTER_LIST "available_filter_functions"
> >
> > /* File descriptor for Top level set_ftrace_filter */
> > static int ftrace_filter_fd = -1;
> > +static int ftrace_notrace_fd = -1;
> > static pthread_mutex_t filter_lock = PTHREAD_MUTEX_INITIALIZER;
>
> I'm wondering if we should free these global resources somehow. A
> cleanup API for the whole library can be implemented using
> __attribute__((destructor)), or some other way ?
No need. The OS will close them for you when the application exits. All
file descriptors that are opened will be closed by the OS.
That said, we should probably add O_CLOEXEC in the open for them such that
they don't stay open if the application does an exec() system call.
-- Steve
next prev parent reply other threads:[~2021-04-08 12:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 20:21 [PATCH 0/3] libtracefs: Update filtering functions Steven Rostedt
2021-04-07 20:21 ` [PATCH 1/3] libtracefs: Move most functionality into helper function for tracefs_function_filter() Steven Rostedt
2021-04-07 20:21 ` [PATCH 2/3] libtracefs: Add tracefs_function_notrace() API Steven Rostedt
2021-04-08 4:25 ` Tzvetomir Stoyanov
2021-04-08 12:53 ` Steven Rostedt [this message]
2021-04-07 20:21 ` [PATCH 3/3] libtracefs: Add a pthread_mutex per instance Steven Rostedt
2021-04-07 20:30 ` [PATCH 0/3] libtracefs: Update filtering functions 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=20210408085340.5e84064f@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=sameeruddin.shaik8@gmail.com \
--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).