[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xen 4.14.3 incorrect (~3x) cpu frequency reported
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Mon, 10 Jan 2022 15:49:02 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9/rOWBZkCHOf6m+suA2xJZXcPVQDCubqcGBRn1yALfc=; b=PN3ec06BkPv/0/fyPVe9BrInJrpG/+HX2rrZjjPrPjK7EoUSKDLPBCcVP2MUBMNYYqxB6tEJWOyB9q+hkNhr7OJVBBeSKjFwad1Wmb5ONrwEHhLb6A1342wj8JgmZj2GgOOvV4nhdlYotSjBr6iOUV+p0IhpGjXz8xuU+BWxt2Gdw7wblkXPo3LsdObHTAj5RpIBRHKcZONUvSie5v2a6Nc8BCqsBidRg4d0NFroBg3/DfKZ31n06KFIx9lb4SbEgDzhoyyfDpMbdUXTwvOYM0kP97x6F14I1CvtHisuxRDh0/VD18AJhQ61qLx8weqUIh3AKtUqAwvAaJkih4VG7w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ignES6sGSkX1nBBzRN80OHPdB6yJ5IUCCGvXn7tUOk39UG1MlPbJm0gOZXsVbRoG9M6IM8ugqKtXGQWcAc0uwU/3sc6QO1KK5bt/8uabAcyKWpfYsKnqv9ysGhvP3Z2ppZXKZzq8e2kXMFgnf5mY92fWt3NGQKnmRnVy44HWLsfKSpe6zwrSkGWEtCaLAZwaf/NVl2XGUOE7qBJHRgaDLjPfTNtYeLs3yq4gIcLeTgKpWHqI7FEDa3fJzDfRVkj2OLdvhHrbwRvsV9YUByQsqKxNp01p+0i/iUT+tJxXnZUVK7HaCvyxQUu6HqYpXDPJW8Yp8xbhxAZ8FbE4smsJrQ==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: James Dingwall <james-xen@xxxxxxxxxxxxxx>, <alexander.rossa@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Delivery-date: Mon, 10 Jan 2022 14:49:42 +0000
- Ironport-data: A9a23:NvHINKqZqqbypnRrAtGhBKFkgqleBmKXYhIvgKrLsJaIsI4StFCzt garIBmCOfffamf3ct50aInjphgP6MDdytNmQQs+/ilgQyoRo5uZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlZT4vE2xbuKU5NTsY0idfic5Dndx4f5fs7Rh2NQw2IHhW1nlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCnb+wQB9xFa6QpNUyYhQGPX9DIvRD6oaSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFJkYtXx6iynQEN4tQIzZQrWM7thdtNs1rp4XQKaGN pdBAdZpRDbhTiceAVo8NM59s/yt1yf0TiN9invA8MLb5ECMlVcsgdABKuH9c9iHVcxTkkuC4 HjB5H/wKhcRLpqUzj/t2mKhgKrDkD32XKoWFaak7bh6jVuL3GsRBRYKE1yhrpGRiESzRtZeI Ew84Tc1oO4580nDZtv0WhCj5W6JuDYQWtxfDOQ+7EeIx+zJ4G6k6nMsF2AbLoZ87YlvGGJsh gThc87V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GgM1/qB/9SNIVyaygcZ79 YcT0EcMqyPMbEZt7eC3ODQKb9Jq7PmgcOVbKXlvg9QpGlRGt5dBmxCe2Cm+yNNNW177c1TLu vh2iMLnUvpRV0nKuCAQlUVVenKoNPG0LrgfB49HhYirC2Dlymh5rLWGwWRmk52aUIE/Z4StU z+1yDp7KSqtP+2jjfaym/o9pxT3P/s0MFKCsCggtUcbh/slgGrToJ8XKDqhkF/nMifrHIR1P XcqRYpOMp+r1vXY2GOuBPonzLt1T4/gkWSvmOwsD/Gm4jUVTg6A81OicZyaR3C8Xctu9l6ze Ziw3+Zn4A/N2KOoA3No/zzEz16nEu9pnQv1cQJiWZEbIcYYLhN6aQC4UJuFosaFi6S0vFqLA BXNrCc2B9qSyLbU5iA1VMfg+BEH05DUytue3Jy9PB8iFNt7TJEJ0hx/r1qop5PzuN5d3B+3Z W1Dk1frsA6ciYnV9MNOA4/e7rFNoXse2O7DIvAGyWvKEk4U0i92aIfpo9FoN2XRA==
- Ironport-sdr: ZjF7PJMPwyZj75V6o2pxyMLidfMXbwsGnXfbir0IPinh9FOsXq7errm7VTj79BnHTtnGiUqVdf v/sKFUFxpTXtRPTCaUO6rkYpd6uOX1TaO5gx+BUn43XIou7BbjEeHroqmFNJiDxs5PWCxAu3CX 87STZYPN3QrPPuiWF53jEmbGt+40Uy8YVNziG9OZs8FqBQ1p0lgGVXT5RujL2Qj2RKurKoatyq xqCjI52yzwIWwzkyieagWE09bHMNruetyjoJ7/xi9jaUvij3hQtHoNR8/6so6Tfvf11LDoZhdI 6qSA/oi8NLjDLXt4SpiHol2g
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, Jan 10, 2022 at 08:52:55AM +0100, Jan Beulich wrote:
> On 07.01.2022 12:39, Jan Beulich wrote:
> > --- a/xen/arch/x86/time.c
> > +++ b/xen/arch/x86/time.c
> > @@ -378,8 +378,9 @@ static u64 read_hpet_count(void)
> >
> > static int64_t __init init_hpet(struct platform_timesource *pts)
> > {
> > - uint64_t hpet_rate, start;
> > + uint64_t hpet_rate, start, expired;
> > uint32_t count, target;
> > +unsigned int i;//temp
> >
> > if ( hpet_address && strcmp(opt_clocksource, pts->id) &&
> > cpuidle_using_deep_cstate() )
> > @@ -415,16 +416,35 @@ static int64_t __init init_hpet(struct p
> >
> > pts->frequency = hpet_rate;
> >
> > +for(i = 0; i < 16; ++i) {//temp
> > count = hpet_read32(HPET_COUNTER);
> > start = rdtsc_ordered();
> > target = count + CALIBRATE_VALUE(hpet_rate);
> > if ( target < count )
> > while ( hpet_read32(HPET_COUNTER) >= count )
> > continue;
> > - while ( hpet_read32(HPET_COUNTER) < target )
> > + while ( (count = hpet_read32(HPET_COUNTER)) < target )
> > continue;
>
> Unlike I first thought but matching my earlier reply, this only reduces
> the likelihood of encountering an issue. In particular, a long-duration
> event ahead of the final HPET read above would be covered, but ...
>
> > - return (rdtsc_ordered() - start) * CALIBRATE_FRAC;
> > + expired = rdtsc_ordered() - start;
>
> ... such an event occurring between the final HPET read and the TSC
> read would still be an issue. So far I've only been able to think of an
> ugly way to further reduce likelihood for this window, but besides that
> neither being neat nor excluding the possibility altogether, I have to
> point out that we have the same issue in a number of other places:
> Back-to-back reads of platform timer and TSC are assumed to happen
> close together elsewhere as well.
Right, sorry replied to the patch first without reading this.
> Cc-ing other x86 maintainers to see whether they have any helpful
> thoughts ...
I'm not sure there's much we can do, we could maybe count NMIs and
retry if we detect an NMI has happened during calibration, but we
can't do this for SMIs, as I don't think there's a way to get this
information on all hardware we support. The MSR_SMI_COUNT (0x34) is
Intel-only and requires Nehalem or later.
Thanks, Roger.
|