lkml.org 
[lkml]   [2015]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2015-03-03 15:21    [W:0.065 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site