linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Melo <acme@ghostprotocols.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mike Galbraith <efault@gmx.de>, Jiri Olsa <jolsa@redhat.com>,
	Stephane Eranian <eranian@google.com>,
	Pekka Enberg <penberg@kernel.org>
Subject: Re: [PATCH 6/8] perf sched: Introduce timehist command
Date: Thu, 28 Nov 2013 09:01:23 -0700	[thread overview]
Message-ID: <529768D3.1000507@gmail.com> (raw)
In-Reply-To: <CAM9d7cg4t_HD-225GawXnUHXG1D-f91ZDS_xsfy19baHSM624w@mail.gmail.com>

On 11/28/13, 8:38 AM, Namhyung Kim wrote:
> On Tue, Nov 19, 2013 at 5:32 AM, David Ahern <dsahern@gmail.com> wrote:
>
> [SNIP]
>> +static bool is_idle_sample(struct perf_sample *sample,
>> +                          struct perf_evsel *evsel,
>> +                          struct machine *machine)
>> +{
>> +       struct thread *thread;
>> +       struct callchain_cursor *cursor = &callchain_cursor;
>> +       struct callchain_cursor_node *node;
>> +       struct addr_location al;
>> +       int iter = 5;
>
> Shouldn't it be sched->max_stack somehow?

max_stack is used to dump callstack to the user. In this case we are 
walking the stack looking for an idle symbol.

>
>> +
>> +       /* pid 0 == swapper == idle task */
>> +       if (sample->pid == 0)
>> +               return true;
>> +
>> +       /* want main thread for process - has maps */
>> +       thread = machine__findnew_thread(machine, sample->pid, sample->pid);
>> +       if (thread == NULL) {
>> +               pr_debug("Failed to get thread for pid %d.\n", sample->pid);
>> +               return false;
>> +       }
>> +
>> +       if (!symbol_conf.use_callchain || sample->callchain == NULL)
>> +               return false;
>> +
>> +       if (machine__resolve_callchain(machine, evsel, thread,
>> +                                       sample, NULL, &al, PERF_MAX_STACK_DEPTH) != 0) {
>> +               if (verbose)
>> +                       error("Failed to resolve callchain. Skipping\n");
>> +
>> +               return false;
>> +       }
>
> I think this callchain resolving logic should be moved to the
> beginning of perf_hist__process_sample() like other commands do.  It's
> not for idle threads only.

I'll see what can be done.

>
> And it also needs to pass sched->max_stack.

Per above, max_stack has a different purpose

>
>
>> +       callchain_cursor_commit(cursor);
>> +
>> +       /* idle symbol should be early in the stack */
>> +       while (iter) {
>> +               node = callchain_cursor_current(cursor);
>> +               if (!node)
>> +                       break;
>> +
>> +               if (symbol__is_idle(node->sym))
>> +                       return true;
>> +
>> +               callchain_cursor_advance(cursor);
>> +
>> +               iter--;
>> +       }
>> +
>> +       return false;
>> +}
>
> [SNIP]
>> +       /* show wakeups if requested */
>> +       if (sched->show_wakeups && !sched->summary_only)
>
> Hmm.. maybe we can emit a warning if -w and -s options are given at
> the same time.

ok.

>
>
>> +               timehist_print_wakeup_event(sched, sample, machine, thread);
>> +
>> +       return 0;
>> +}
>
> [SNIP]
>> +static int parse_target_str(struct perf_sched *sched)
>> +{
>> +       if (sched->target.pid) {
>> +               sched->pid = intlist__new(sched->target.pid);
>> +               if (sched->pid == NULL) {
>> +                       pr_err("Error parsing process id string\n");
>> +                       return -EINVAL;
>> +               }
>> +       }
>> +
>> +       if (sched->target.tid) {
>> +               sched->tid = intlist__new(sched->target.tid);
>> +               if (sched->tid == NULL) {
>> +                       pr_err("Error parsing thread id string\n");
>
>
> Need to call intlist__delete(sched->pid) here?

indeed. thanks.


>> +       const struct option timehist_options[] = {
>> +       OPT_STRING('i', "input", &input_name, "file",
>> +                   "input file name"),
>> +       OPT_INCR('v', "verbose", &verbose,
>> +                   "be more verbose (show symbol address, etc)"),
>> +       OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
>> +                  "file", "vmlinux pathname"),
>> +       OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
>> +                  "file", "kallsyms pathname"),
>> +       OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
>> +                  "only display events for these comms"),
>> +       OPT_STRING('p', "pid", &sched.target.pid, "pid",
>> +                  "analyze events only for given process id(s)"),
>> +       OPT_STRING('t', "tid", &sched.target.tid, "tid",
>> +                   "analyze events only for given thread id(s)"),
>> +       OPT_BOOLEAN('g', "call-graph", &sched.show_callchain,
>> +                   "Display call chains if present (default on)"),
>> +       OPT_UINTEGER(0, "max-stack", &sched.max_stack,
>> +                  "Maximum number of functions to display backtrace."),
>> +       OPT_STRING('x', "excl", &excl_sym_list_str, "sym[,sym...]",
>
> Why not renaming long option name to --exclude or --exclude-symbols?

ok.

David

  reply	other threads:[~2013-11-28 16:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18 20:32 [PATCH 0/8] perf: sched timehist command David Ahern
2013-11-18 20:32 ` [PATCH 1/8] perf tool: Skip ignored symbols while printing callchain David Ahern
2013-11-30 12:52   ` [tip:perf/core] perf evsel: " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 2/8] perf symbols: Move idle syms check from top to generic function David Ahern
2013-11-28  8:36   ` Namhyung Kim
2013-11-30 15:58     ` David Ahern
2013-11-30 12:52   ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 3/8] perf symbol: Save vmlinux or kallsyms path loaded David Ahern
2013-11-22 18:44   ` Arnaldo Carvalho de Melo
2013-11-22 19:13     ` David Ahern
2013-11-22 19:40       ` Arnaldo Carvalho de Melo
2013-11-22 20:09         ` David Ahern
2013-11-18 20:32 ` [PATCH 4/8] perf thread: Move comm_list check into function David Ahern
2013-11-30 12:52   ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 5/8] perf tool: export setup_list David Ahern
2013-11-28  8:45   ` Namhyung Kim
2013-11-30 12:52   ` [tip:perf/core] perf tools: Export setup_list tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 6/8] perf sched: Introduce timehist command David Ahern
2013-11-28  9:50   ` Namhyung Kim
2013-11-28 16:01     ` David Ahern
2013-11-28 15:38   ` Namhyung Kim
2013-11-28 16:01     ` David Ahern [this message]
2013-11-29  0:48       ` Namhyung Kim
2013-11-29  1:58         ` David Ahern
2013-12-04  4:15           ` David Ahern
2013-11-18 20:32 ` [PATCH 7/8] perf sched timehist: Add support for context-switch event David Ahern
2013-11-18 20:32 ` [PATCH 8/8] perf sched : Add documentation for timehist options David Ahern
2013-11-28 15:42   ` Namhyung Kim

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=529768D3.1000507@gmail.com \
    --to=dsahern@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=penberg@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;
as well as URLs for NNTP newsgroup(s).