public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>, David Ahern <dsahern@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] segfault in perf-top -- thread refcnt
Date: Tue, 31 Mar 2015 09:15:15 +0900	[thread overview]
Message-ID: <20150331001515.GD32033@sejong> (raw)
In-Reply-To: <20150330140239.GB32560@kernel.org>

Hi Arnaldo,

On Mon, Mar 30, 2015 at 11:02:39AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Mar 30, 2015 at 10:06:35PM +0900, Namhyung Kim escreveu:
> > On Mon, Mar 30, 2015 at 9:56 PM, Jiri Olsa <jolsa@redhat.com> wrote:
> > > On Mon, Mar 30, 2015 at 09:48:52PM +0900, Namhyung Kim wrote:
> > >> > @@ -380,10 +381,13 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
> > >> >     if (!create)
> > >> >             return NULL;
> > >> >
> > >> > -   th = thread__new(pid, tid);
> > >> > +   th = thread__new(machine, pid, tid);
> > >> >     if (th != NULL) {
> > >> > +
> > >> > +           pthread_mutex_lock(&machine->threads_lock);
> > >> >             rb_link_node(&th->rb_node, parent, p);
> > >> >             rb_insert_color(&th->rb_node, &machine->threads);
> > >> > +           pthread_mutex_unlock(&machine->threads_lock);
> > >>
> > >> I think you also need to protect the rb tree traversal above.
> > >
> > > yep, I already have another version.. but it blows on another place ;-)
> > >
> > >>
> > >> But this makes every sample processing grabs and releases the lock so
> > >> might cause high overhead.  It can be a problem if such processing is
> > >> done parallelly like my multi-thread work. :-/
> > >
> > > yep.. perhaps instead of more locking we need to find a way where
> > > only single thread do the update on hists/threads
> > 
> > Agreed.
> > 
> > AFAIK the reason we do ref-counting is to cleanup dead/exited thread
> > for live session like perf top.  In that case we can somehow mark
> > to-be-deleted thread and kill it in a safe time/place..
> 
> Humm, you mean have another list node in struct threads and add threads
> to another dead_threads like list, i.e. one that is _really_ dead as no
> more refcounts point to it, and then amortize the costs of removing it
> from the rb_tree by removing multiple threads instead of just one?

Yes, I really want to avoid any overhead on the fastpath.  Instead of
refcnt, how about marking and deleting dead threads by the perf top's
display thread unless it's not a selected one?

Thanks,
Namhyung

  reply	other threads:[~2015-03-31  0:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27 17:31 [BUG] segfault in perf-top -- thread refcnt David Ahern
2015-03-27 19:51 ` Arnaldo Carvalho de Melo
2015-03-27 20:11 ` Arnaldo Carvalho de Melo
2015-03-27 20:13   ` David Ahern
2015-03-30  8:07     ` Jiri Olsa
2015-03-30 10:22       ` Jiri Olsa
2015-03-30 11:21         ` Jiri Olsa
2015-03-30 11:49           ` Jiri Olsa
2015-03-30 12:48             ` Namhyung Kim
2015-03-30 12:56               ` Jiri Olsa
2015-03-30 13:06                 ` Namhyung Kim
2015-03-30 14:02                   ` Arnaldo Carvalho de Melo
2015-03-31  0:15                     ` Namhyung Kim [this message]
2015-03-30 13:07                 ` Arnaldo Carvalho de Melo
2015-03-30 13:20                   ` Jiri Olsa
2015-03-30 13:59                     ` Arnaldo Carvalho de Melo
2015-03-30 14:58               ` Arnaldo Carvalho de Melo
2015-03-30 15:13                 ` Arnaldo Carvalho de Melo
2015-03-31  0:27                   ` Namhyung Kim
2015-03-31  0:46                     ` Arnaldo Carvalho de Melo
2015-03-31  7:21                       ` Namhyung Kim
2015-03-30 13:22             ` Arnaldo Carvalho de Melo
2015-03-30 13:09         ` Arnaldo Carvalho de Melo
2015-03-30 13:17         ` Arnaldo Carvalho de Melo

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=20150331001515.GD32033@sejong \
    --to=namhyung@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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