mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Tony Lu <zlu@tilera.com>
Cc: Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chris Metcalf <cmetcalf@tilera.com>
Subject: Re: [BUG] perf: can not resolve symbols for forked threads
Date: Mon, 23 Jun 2014 11:12:43 +0200	[thread overview]
Message-ID: <20140623091243.GN19860@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <BAB94DBB0E89D8409949BC28AC95914C5D762567@USMAExch1.tad.internal.tilera.com>

On Thu, Jun 19, 2014 at 07:39:42AM +0000, Tony Lu wrote:
> Hi
> 
> I got the below output that shows perf can not resolve symbols for
> forked threads. I did a system-wide collection from all CPUs after the
> application hello run.

There's no fork() in... :-)

> #include <pthread.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #define NUM_THREADS     5
> 
> void foo(void)
> {
>   long i = 1000000000;
>   while (i--) {
>     ;
>   }
> }
> 
> void *PrintHello(void *threadid)
> {
>    long tid;
>    tid = (long)threadid;
>    printf("Hello World! It's me, thread #%ld!\n", tid);
>    foo();
>    pthread_exit(NULL);
> }
> 
> int main(int argc, char *argv[])
> {
>    pthread_t threads[NUM_THREADS];
>    int rc;
>    long t;
>    for(t=0;t<NUM_THREADS;t++){
>      printf("In main: creating thread %ld\n", t);
>      rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
>      if (rc){
>        printf("ERROR; return code from pthread_create() is %d\n", rc);
>        exit(-1);
>        }
>      }
> 
>    /* Last thing that main() should do */
>    pthread_exit(NULL);
> }

That pthread_exit() is the problem; this results in:

29456 pts/23   Zl     0:00          |               \_ [hello] <defunct>

You want to wait for the threads to complete using pthread_join().

I suspect the defunct state hides the process.

  reply	other threads:[~2014-06-23  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19  7:39 Tony Lu
2014-06-23  9:12 ` Peter Zijlstra [this message]
2014-06-24  6:47   ` Tony Lu
2014-06-24 10:42     ` Peter Zijlstra

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=20140623091243.GN19860@laptop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@ghostprotocols.net \
    --cc=cmetcalf@tilera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=zlu@tilera.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

all inboxes | Powered by JetHome®