Re: [PATCH] perf report: auto-detect branch stack sampling mode

From: Stephane Eranian
Date: Fri Feb 24 2012 - 10:40:39 EST


On Fri, Feb 24, 2012 at 4:31 PM, David Ahern <dsahern@xxxxxxxxx> wrote:
> On 2/24/12 8:28 AM, Stephane Eranian wrote:
>>
>> On Fri, Feb 24, 2012 at 4:24 PM, David Ahern<dsahern@xxxxxxxxx> Âwrote:
>>>
>>> On 2/24/12 2:40 AM, Stephane Eranian wrote:
>>>>
>>>>
>>>>
>>>> This patch adds auto-detection of samples with taken branch stacks.
>>>> The auto-detection avoids having to specify the -b or --branch-stack
>>>> option on the cmdline.
>>>>
>>>> The patch adds a new feature bit HEADER_BRANCH_STACK to mark the
>>>> presence of branch stacks in samples.
>>>>
>>>> You can now do:
>>>> $ perf record -b any noploop 2
>>>> $ perf report
>>>> # Events: 8K cycles
>>>> #
>>>> # Overhead ÂCommand ÂSource Shared Object    ÂSource Symbol ÂTarget
>>>> Shared Object    Target Symbol
>>>> # ........ Â....... Â.................... Â...................
>>>> Â.................... Â..................
>>>> #
>>>>   91.56% Ânoploop Ânoploop        [.] noploop
>>>> Â noploop Â[.] noploop
>>>> Â Â Â0.42% Ânoploop Â[kernel.kallsyms] Â Â [k] __lock_acquire
>>>> Â[kernel.kallsyms] Â[k] __lock_acquire
>>>>
>>>>
>>>> To force regular reporting based on the instruction address:
>>>> $ perf report --no-branch-stack
>>>> #
>>>> # Events: 2K cycles
>>>> #
>>>> # Overhead ÂCommand   ÂShared Object              Symbol
>>>> # ........ Â....... Â................. Â...............................
>>>> #
>>>>   92.03% Ânoploop Ânoploop      Â[.] noploop
>>>> Â Â Â1.00% Ânoploop Â[kernel.kallsyms] Â[k] lock_acquire
>>>>
>>>>
>>>> Signed-off-by: Stephane Eranian<eranian@xxxxxxxxxx>
>>>> ---
>>>>
>>>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>>>> index 1c49d4e..5e833a2 100644
>>>> --- a/tools/perf/builtin-record.c
>>>> +++ b/tools/perf/builtin-record.c
>>>> @@ -473,6 +473,9 @@ static int __cmd_record(struct perf_record *rec, int
>>>> argc, const char **argv)
>>>> Â Â Â Âif (!have_tracepoints(&evsel_list->entries))
>>>> Â Â Â Â Â Â Â Âperf_header__clear_feat(&session->header,
>>>> HEADER_TRACE_INFO);
>>>>
>>>> + Â Â Â if (!rec->opts.branch_stack)
>>>> + Â Â Â Â Â Â Â perf_header__clear_feat(&session->header,
>>>> HEADER_BRANCH_STACK);
>>>
>>>
>>>
>>> branch tracing is user requested on, so shouldn't feature default off and
>>> only be enabled when requested?
>>>
>> Well, what Ingo was suggesting is that perf report auto-detects whether or
>> not branch mode is necessary by looking at the perf.data file. Most likely
>> if you've recorded with -b, you are interested in a branch mode view
>> rather
>> that the instruction view (default). So all this does is elimintate the
>> need
>> to pass -b to perf report to enable branch mode.
>
>
> Right. My point is that HEADER_BRANCH_STACK feature should be off by default
> and only enabled by builtin-record when branch stack is requested. You have
> the reverse -- enabled by default and off in record if not requested.
>
No, I don't. Read the code carefully. The for loop sets all known feature bits.
Then, the ones not necessary or unused are turned off individually.

> David
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/