[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171012005358.GB9177@sejong>
Date: Thu, 12 Oct 2017 09:53:58 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Tom Zanussi <tom.zanussi@...ux.intel.com>
Cc: Steven Rostedt <rostedt@...dmis.org>, tglx@...utronix.de,
mhiramat@...nel.org, vedang.patel@...el.com, bigeasy@...utronix.de,
joel.opensrc@...il.com, joelaf@...gle.com,
mathieu.desnoyers@...icios.com, baohong.liu@...el.com,
rajvi.jingar@...el.com, linux-kernel@...r.kernel.org,
linux-rt-users@...r.kernel.org, kernel-team@....com
Subject: Re: [PATCH v3 21/33] tracing: Add support for 'synthetic' events
On Wed, Oct 04, 2017 at 02:50:18PM -0500, Tom Zanussi wrote:
> On Wed, 2017-10-04 at 14:08 -0400, Steven Rostedt wrote:
> > On Fri, 22 Sep 2017 15:00:01 -0500
> > Tom Zanussi <tom.zanussi@...ux.intel.com> wrote:
> >
> >
> >
> > > +/* This function releases synth_event_mutex */
> > > +static int unregister_synth_event(struct synth_event *event)
> > > +{
> > > + struct trace_event_call *call = &event->call;
> > > + int ret;
> > > +
> > > + mutex_unlock(&synth_event_mutex);
> > > + ret = trace_remove_event_call(call);
> > > + mutex_lock(&synth_event_mutex);
> > > +
> > > + return ret;
> > > +}
> > > +
> > > +static int remove_synth_event(struct synth_event *event)
> > > +{
> > > + int ret = unregister_synth_event(event);
> > > +
> > > + if (!ret)
> > > + list_del(&event->list);
> > > +
> > > + return ret;
> > > +}
> > > +
> >
> >
> > > +/* This function releases synth_event_mutex */
> > > +static int release_all_synth_events(void)
> > > +{
> > > + struct synth_event *event, *e;
> > > + int ret = 0;
> > > +
> > > + mutex_lock(&synth_event_mutex);
> > > +
> > > + list_for_each_entry(event, &synth_event_list, list) {
> > > + if (event->ref) {
> > > + ret = -EBUSY;
> > > + goto out;
> > > + }
> > > + }
> > > +
> > > + list_for_each_entry_safe(event, e, &synth_event_list, list) {
> >
> > remove_synth_event() releases synth_event_mutex, which is racy, as more
> > than one instance can do the deletion.
> >
> > Perhaps we should remove all the events off the synth_event_list under
> > the lock, release the lock, and then remove the trace events attached
> > to them?
> >
>
> Yeah, I think that makes sense, will change..
I suspect a similar race in creation too. The create_synth_event()
checks existing events in the synth_event_list but it releases the
synth_event_mutex before adding a new event to the list. So it's
possible to add two (or more) events have same name IMHO.
Thanks,
Namhyung
Powered by blists - more mailing lists