From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: acme@kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org,
tglx@linutronix.de, jolsa@kernel.org, eranian@google.com,
alexander.shishkin@linux.intel.com, ak@linux.intel.com
Subject: Re: [RESEND PATCH V3 3/8] perf/x86/intel: Support hardware TopDown metrics
Date: Thu, 29 Aug 2019 12:56:02 -0400 [thread overview]
Message-ID: <cc2ee16d-b10f-a31e-7411-320e90413ceb@linux.intel.com> (raw)
In-Reply-To: <20190829135256.GW2369@hirez.programming.kicks-ass.net>
On 8/29/2019 9:52 AM, Peter Zijlstra wrote:
> On Thu, Aug 29, 2019 at 09:31:37AM -0400, Liang, Kan wrote:
>> On 8/28/2019 11:19 AM, Peter Zijlstra wrote:
>>>> +static int icl_set_topdown_event_period(struct perf_event *event)
>>>> +{
>>>> + struct hw_perf_event *hwc = &event->hw;
>>>> + s64 left = local64_read(&hwc->period_left);
>>>> +
>>>> + /*
>>>> + * Clear PERF_METRICS and Fixed counter 3 in initialization.
>>>> + * After that, both MSRs will be cleared for each read.
>>>> + * Don't need to clear them again.
>>>> + */
>>>> + if (left == x86_pmu.max_period) {
>>>> + wrmsrl(MSR_CORE_PERF_FIXED_CTR3, 0);
>>>> + wrmsrl(MSR_PERF_METRICS, 0);
>>>> + local64_set(&hwc->period_left, 0);
>>>> + }
>>> This really doesn't make sense to me; if you set FIXED_CTR3 := 0, you'll
>>> never trigger the overflow there; this then seems to suggest the actual
>>> counter value is irrelevant. Therefore you don't actually need this.
>>>
>>
>> Could you please elaborate on why initialization to 0 never triggers an
>> overflow?
>
> Well, 'never' as in a 'long' time.
>
>> As of my understanding, initialization to 0 only means that it will take
>> more time than initialization to -max_period (0x8000 0000 0001) to trigger
>> an overflow.
>
> Only twice as long. And why do we care about that?
>
> The problem with it is though that you get the overflow at the end of
> the whole period, instead of halfway through, so reconstruction is
> trickier.
>
>> Maybe 0 is too tricky. We can set the initial value to 1.
>
> That's even worse. I'm still not understanding why we can't use the
> normal code.
>
>> I think the bottom line is that we need a small initial value for FIXED_CTR3
>> here.
>
> But why?!
>
>> PERF_METRICS reports an 8bit integer fraction which is something like 0xff *
>> internal counters / FIXCTR3.
>> The internal counters only start counting from 0. (SW cannot set an
>> arbitrary initial value for internal counters.)
>> If the initial value of FIXED_CTR3 is too big, PERF_METRICS could always
>> remain constant, e.g. 0.
>
> What what? The PERF_METRICS contents depends on the FIXCTR3 value ?!
Yes.
For current implementation, PERF_METRIC MSR is composed by four fields,
backend bound, frontend bound, bad speculation and retiring.
Each of the fields are populated using the below formula for eg:
PERF_METRIC[RETIRING] = (0xFF *
PERF_METRICS_RETIRING_INTERNAL_48bit_COUNTER)
/ FIXCTR3
The METRICS_OVF indicates the overflow of any internal counters.
The internal counters only start counting from 0, which cannot be
programmed by SW. But resetting the PERF_METRIC would implicitly
resetting the internal counters.
Thanks,
Kan
> That's bloody insane. /me goes find the SDM. The SDM is bloody useless
> :-(.
>
> Please give a complete and coherent description of all of this. I can't
> very well review any of this until I know how the hardware works, now
> can I.
>
> In this write-up, include the exact condition for METRICS_OVF (the SDM
> states: 'it indicates that PERF_METRIC counter has overflowed', which is
> gramatically incorrect and makes no sense even with the missing article
> injected).
>
next prev parent reply other threads:[~2019-08-29 16:56 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 14:47 [RESEND PATCH V3 0/8] TopDown metrics support for Icelake kan.liang
2019-08-26 14:47 ` [RESEND PATCH V3 1/8] perf/x86/intel: Set correct mask for TOPDOWN.SLOTS kan.liang
2019-08-28 7:48 ` Peter Zijlstra
2019-08-26 14:47 ` [RESEND PATCH V3 2/8] perf/x86/intel: Basic support for metrics counters kan.liang
2019-08-28 7:48 ` Peter Zijlstra
2019-08-28 7:52 ` Peter Zijlstra
2019-08-28 13:59 ` Liang, Kan
2019-08-28 8:44 ` Peter Zijlstra
2019-08-28 9:02 ` Peter Zijlstra
2019-08-28 9:37 ` Peter Zijlstra
2019-08-28 13:51 ` Liang, Kan
2019-08-28 8:52 ` Peter Zijlstra
2019-08-26 14:47 ` [RESEND PATCH V3 3/8] perf/x86/intel: Support hardware TopDown metrics kan.liang
2019-08-28 15:02 ` Peter Zijlstra
2019-08-28 19:04 ` Andi Kleen
2019-08-31 9:19 ` Peter Zijlstra
2019-09-09 13:40 ` Liang, Kan
2019-08-28 19:35 ` Liang, Kan
2019-08-28 15:19 ` Peter Zijlstra
2019-08-28 16:11 ` [PATCH] x86/math64: Provide a sane mul_u64_u32_div() implementation for x86_64 Peter Zijlstra
2019-08-29 9:30 ` Peter Zijlstra
2019-08-28 16:17 ` [RESEND PATCH V3 3/8] perf/x86/intel: Support hardware TopDown metrics Andi Kleen
2019-08-28 16:28 ` Peter Zijlstra
2019-08-29 3:11 ` Andi Kleen
2019-08-29 9:17 ` Peter Zijlstra
2019-08-29 13:31 ` Liang, Kan
2019-08-29 13:52 ` Peter Zijlstra
2019-08-29 16:56 ` Liang, Kan [this message]
2019-08-31 9:18 ` Peter Zijlstra
2019-08-30 23:18 ` Stephane Eranian
2019-08-31 0:31 ` Andi Kleen
2019-08-31 9:13 ` Stephane Eranian
2019-08-31 9:29 ` Peter Zijlstra
2019-08-31 17:53 ` Andi Kleen
2019-08-26 14:47 ` [RESEND PATCH V3 4/8] perf/x86/intel: Support per thread RDPMC " kan.liang
2019-08-26 14:47 ` [RESEND PATCH V3 5/8] perf/x86/intel: Export TopDown events for Icelake kan.liang
2019-08-26 14:47 ` [RESEND PATCH V3 6/8] perf/x86/intel: Disable sampling read slots and topdown kan.liang
2019-08-26 14:47 ` [RESEND PATCH V3 7/8] perf, tools, stat: Support new per thread TopDown metrics kan.liang
2019-08-26 14:47 ` [RESEND PATCH V3 8/8] perf, tools: Add documentation for topdown metrics kan.liang
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=cc2ee16d-b10f-a31e-7411-320e90413ceb@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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