From: Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
David Ahern <dsahern@gmail.com>,
linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
yrl.pp-manager.tt@hitachi.com, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH -tip v3 2/5] perf: change perf_event_header.misc to PERF_RECORD_MISC_USER for BTS
Date: Wed, 17 Aug 2011 11:19:39 +0900 [thread overview]
Message-ID: <4E4B253B.4000703@hitachi.com> (raw)
In-Reply-To: <1313065126.7144.6.camel@twins>
(2011/08/11 21:18), Peter Zijlstra wrote:
> On Thu, 2011-08-11 at 21:06 +0900, Akihiro Nagai wrote:
>> Change perf_event_headder.misc to PERF_RECORD_MISC_USER for
>> BTS records, because BTS traces both kernel and user spaces
>> nevertheless perf specifies to trace only kernel or user space.
>
> Now I'm confused..
>
> If BTS traces both kernel and user, the MISC bit should reflect the
> right state per-sample, on x86 that's easy enough to do by the address.
Yes.
However, PERF_RECORD_MISC_KERNEL can be specified only when
both from_addr and to_addr are kernel-space. Since current perf always enables
IA32_DEBUGCTL_MSR.BTS_OFF_OS flag when it uses BTS, such BTS records are not
output. So, it's enough to specify only PERF_RECORD_MISC_USER.
>
>
>> ---
>>
>> arch/x86/kernel/cpu/perf_event_intel_ds.c | 8 ++++++++
>> 1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
>> index 1b1ef3a..323f3f0 100644
>> --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
>> +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
>> @@ -340,6 +340,14 @@ static int intel_pmu_drain_bts_buffer(void)
>> */
>> perf_prepare_sample(&header,&data, event,®s);
>>
>> + /*
>> + * Since BTS can not trace kernel and user space separately, set
>
> Uhm, IA32_DEBUGCTL_MSR.BTS_OFF_{OS,USR} seem to suggest it can?!
Current perf always enables IA32_DEBUGCTL_MSR.BTS_OFF_OS when traces with BTS.
However, BTS records branches which jump from kernel(irq_return) to user, because
the msr is to stop tracing in Ring0. It's different with kernel-space in the
strict sense.
>
>> + * PERF_RECORD_MISC_USER in header.misc to resolve both kernel and
>> + * user DSOs and symbols.
>> + */
>> + header.misc&= ~PERF_RECORD_MISC_CPUMODE_MASK;
>> + header.misc |= PERF_RECORD_MISC_USER;
>
>
> So what's wrong with something like:
>
> header.misc |= is_kernel_address(at->from) ?
> PERF_RECORD_MISC_KERNEL :
> PERF_RECORD_MISC_USER;
>
It looks good.
However, current perf doesn't output "kernel to kernel" BTS records.
So, it is unnecessary yet.
Thank you.
>> if (perf_output_begin(&handle, event, header.size * (top - at)))
>> return 1;
>>
>>
>
>
next prev parent reply other threads:[~2011-08-17 2:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 12:05 [PATCH -tip v3 0/5] perf script: add BTS analysis features Akihiro Nagai
2011-08-11 12:06 ` [PATCH -tip v3 1/5] perf-script: unify the expressions indicate "unknown" Akihiro Nagai
2011-08-22 13:00 ` David Ahern
2011-08-11 12:06 ` [PATCH -tip v3 2/5] perf: change perf_event_header.misc to PERF_RECORD_MISC_USER for BTS Akihiro Nagai
2011-08-11 12:18 ` Peter Zijlstra
2011-08-17 2:19 ` Akihiro Nagai [this message]
2011-08-22 9:02 ` Peter Zijlstra
2011-08-11 12:06 ` [PATCH -tip v3 3/5] perf script: enhance IP and ADDR correlate detection " Akihiro Nagai
2011-08-22 13:00 ` David Ahern
2011-08-11 12:06 ` [PATCH -tip v3 4/5] perf script: add the offset field specifier Akihiro Nagai
2011-08-22 13:02 ` David Ahern
2011-08-11 12:06 ` [PATCH -tip v3 5/5] perf script: add option resolving vmlinux path Akihiro Nagai
2011-08-22 13:03 ` David Ahern
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=4E4B253B.4000703@hitachi.com \
--to=akihiro.nagai.hw@hitachi.com \
--cc=acme@infradead.org \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=yrl.pp-manager.tt@hitachi.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
Powered by JetHome