public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>,
	adrian.hunter@intel.com
Subject: Re: [PATCH 2/2] perf script: Support callindent
Date: Fri, 20 May 2016 17:27:47 -0300	[thread overview]
Message-ID: <20160520202747.GD8897@kernel.org> (raw)
In-Reply-To: <1463773938-26194-2-git-send-email-andi@firstfloor.org>

Em Fri, May 20, 2016 at 12:52:18PM -0700, Andi Kleen escreveu:

> +static void print_sample_callindent(struct perf_sample *sample,
> +				    struct perf_evsel *evsel,
> +				    struct thread *thread,
> +				    struct addr_location *al)
> +{
> +	struct perf_event_attr *attr = &evsel->attr;
> +
> +	if (sample_addr_correlates_sym(attr)) {
> +		static struct call_return_processor *crp;
> +		struct addr_location addr_al;
> +		struct thread *main_thread;
> +		struct comm *comm;
> +
> +		if (!crp)
> +			crp = call_return_processor__new(dummy_call_return,
> +							 NULL);
> +		thread__resolve(thread, &addr_al, sample);
> +		main_thread = db_export__main_thread(al->machine, thread);


What is db_export doing here?

This is specific to machine or thread, you should have moved this from
being a static function in the db_export code to a function, probably:

  struct thread *thread__main(struct thread *thread, struct machine *machine)

And also bear in mind you have to drop the refcount that this function
returns, as follows:

> +		if (main_thread) {
> +			comm = machine__thread_exec_comm(al->machine,
> +							 main_thread);
			thread__put(main_thread);
		}
}

Also do this in a separate, prep patch before this one,

Thanks,

- Arnaldo

> +		thread_stack__process(thread, comm, sample, al, &addr_al,
> +							0, crp);
> +	}
> +	thread_stack__print_indent(thread);
> +}
> +
>  static void print_sample_bts(struct perf_sample *sample,
>  			     struct perf_evsel *evsel,
>  			     struct thread *thread,
> @@ -567,6 +609,9 @@ static void print_sample_bts(struct perf_sample *sample,
>  	struct perf_event_attr *attr = &evsel->attr;
>  	bool print_srcline_last = false;
>  
> +	if (PRINT_FIELD(CALLINDENT))
> +		print_sample_callindent(sample, evsel, thread, al);
> +
>  	/* print branch_from information */
>  	if (PRINT_FIELD(IP)) {
>  		unsigned int print_opts = output[attr->type].print_ip_opts;
> diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
> index 049438d51b9a..02f8255a0b01 100644
> --- a/tools/perf/util/db-export.c
> +++ b/tools/perf/util/db-export.c
> @@ -231,7 +231,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym,
>  	return 0;
>  }
>  
> -static struct thread *get_main_thread(struct machine *machine, struct thread *thread)
> +struct thread *db_export__main_thread(struct machine *machine, struct thread *thread)
>  {
>  	if (thread->pid_ == thread->tid)
>  		return thread__get(thread);
> @@ -308,7 +308,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
>  	if (err)
>  		return err;
>  
> -	main_thread = get_main_thread(al->machine, thread);
> +	main_thread = db_export__main_thread(al->machine, thread);
>  	if (main_thread)
>  		comm = machine__thread_exec_comm(al->machine, main_thread);
>  
> diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
> index 25e22fd76aca..8cb3658172d9 100644
> --- a/tools/perf/util/db-export.h
> +++ b/tools/perf/util/db-export.h
> @@ -103,4 +103,6 @@ int db_export__branch_types(struct db_export *dbe);
>  int db_export__call_path(struct db_export *dbe, struct call_path *cp);
>  int db_export__call_return(struct db_export *dbe, struct call_return *cr);
>  
> +struct thread *db_export__main_thread(struct machine *machine, struct thread *thread);
> +
>  #endif
> diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
> index 679688e70ae7..abea25eb2ccc 100644
> --- a/tools/perf/util/thread-stack.c
> +++ b/tools/perf/util/thread-stack.c
> @@ -753,3 +753,10 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
>  
>  	return err;
>  }
> +
> +void thread_stack__print_indent(struct thread *thread)
> +{
> +	if (!thread->ts)
> +		return;
> +	printf("%*s", (int)thread->ts->cnt * 4, "");
> +}
> diff --git a/tools/perf/util/thread-stack.h b/tools/perf/util/thread-stack.h
> index e1528f1374c3..d7426bd0510b 100644
> --- a/tools/perf/util/thread-stack.h
> +++ b/tools/perf/util/thread-stack.h
> @@ -98,6 +98,7 @@ void thread_stack__sample(struct thread *thread, struct ip_callchain *chain,
>  			  size_t sz, u64 ip);
>  int thread_stack__flush(struct thread *thread);
>  void thread_stack__free(struct thread *thread);
> +void thread_stack__print_indent(struct thread *thread);
>  
>  struct call_return_processor *
>  call_return_processor__new(int (*process)(struct call_return *cr, void *data),
> -- 
> 2.5.5

  reply	other threads:[~2016-05-20 20:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 19:52 [PATCH 1/2] perf pt: Mark PT return events as "return" Andi Kleen
2016-05-20 19:52 ` [PATCH 2/2] perf script: Support callindent Andi Kleen
2016-05-20 20:27   ` Arnaldo Carvalho de Melo [this message]
2016-05-23 12:05 ` [PATCH 1/2] perf pt: Mark PT return events as "return" Adrian Hunter
2016-05-24  0:50   ` Andi Kleen
  -- strict thread matches above, loose matches on Subject: below --
2016-06-10 22:55 Andi Kleen
2016-06-10 22:55 ` [PATCH 2/2] perf script: Support callindent Andi Kleen
2016-06-16 12:41   ` Adrian Hunter

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=20160520202747.GD8897@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --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