Messages in this thread | | | Date | Tue, 3 Mar 2015 10:57:25 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH 19/20] perf tools: Reference count struct thread |
| |
Em Tue, Mar 03, 2015 at 10:42:14PM +0900, Namhyung Kim escreveu: > On Tue, Mar 03, 2015 at 12:26:08AM -0300, Arnaldo Carvalho de Melo wrote: > > +++ b/tools/perf/util/thread.c > > @@ -82,6 +82,20 @@ void thread__delete(struct thread *thread)
> > +struct thread *thread__get(struct thread *thread) > > +{ > > + ++thread->refcnt; > > + return thread; > > +}
> > +void thread__put(struct thread *thread) > > +{ > > + if (thread && --thread->refcnt == 0) { > > + list_del_init(&thread->node); > > + thread__delete(thread); > > + } > > +}
> I think we need to protect refcnt from concurrent accesses from > multiple threads. Not to mention my multi-thread work, perf top > already uses two threads.
Sure
> For perf top case, hist_entry__new() will be called from main thread > and hist_entry__delete() might be called from display thread.
Reference counting is a step in that direction, as to if the integer inc/dec is enough or is already surrounded by existing serialization needs to be checked.
- Arnaldo
| |