[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 1/4] x86/APIC: calibrate against platform timer when possible
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Mon, 4 Apr 2022 13:55:56 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=tCKvEFJvw+lpfdXbT+KPfCyUEtPemYHb6h5cHDSCVDY=; b=GfIBFM6h8olQ+HvWFxF6hCzjLLO6APHh67m0TyKDMAUDHBb/bE9Iu3zUoA341bRAh4lFvbcegyzQPepMEU7eBKBbY4dQAiTu4/0RrXmJ3lgciYRugp3i0AfdW7q7DtvwFKcgUFSYCmtjo5ei6MpoUqCTTLMgG2c/Dwq/6hUsDcm+CKd1hQ6CbbuBePW3NKVFvKQ2YMIq+KJU+dBGmKtV70WMkXCJf7l6PPEggnLUE7EYyN2Fm8j+4Z0SKVnXbW6p8bcGlSSys/qy9lNmn2YNCiW4PVRJs+DiQOQb7KzG8wXJgtHZzXFJzDvvR+joosbQTRY5g897E1Y9/r0o5ERDtg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N/Jgdma9NP7/q/DqSOFU5bh6bOT1DTpocqCzuOiR6VUHYXO7gl24CT4uREtaurG9FhXZWQY6HsxtyrPnMzgkQ/O1TErrUJZJItb4Ee2T2J4VNaoW5kfoVyleokntyh5u5BOPNy4Ub8QvoyEfzFbKTecY41s2NdiGlEwkJ5CeVbqpxqwpJAKhShhLP1EFupMw9g7OW/mq1AyJTw3dAeJ/B7uwLf+cw3tRJysHXBDoncmLm6O7GHz8r0swCQWSKxgkOCgUoxaqY3jfdWxjMveRiTuCMoRZUxvofABkEok8lz6ebjpaxBe6pPNux2L2O1w4QmG/0rTeKvbFPxvdXnFhCA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 04 Apr 2022 11:56:05 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 04.04.2022 13:46, Roger Pau Monné wrote:
> On Thu, Mar 31, 2022 at 11:29:44AM +0200, Jan Beulich wrote:
>> +uint64_t __init calibrate_apic_timer(void)
>> +{
>> + uint32_t start, end;
>> + uint64_t count = read_pt_and_tmcct(&start), elapsed;
>> + uint64_t target = CALIBRATE_VALUE(plt_src.frequency), actual;
>> + uint64_t mask = (uint64_t)~0 >> (64 - plt_src.counter_bits);
>> +
>> + /*
>> + * PIT cannot be used here as it requires the timer interrupt to
>> maintain
>> + * its 32-bit software counter, yet here we run with IRQs disabled.
>> + */
>> + if ( using_pit )
>> + return 0;
>> +
>> + while ( ((plt_src.read_counter() - count) & mask) < target )
>> + continue;
>> +
>> + actual = read_pt_and_tmcct(&end) - count;
>
> Don't you need to apply the pt mask here?
Oh, yes, of course. I guess I did clone an earlier mistake from
calibrate_tsc().
>> + elapsed = start - end;
>> +
>> + if ( likely(actual > target) )
>> + {
>> + /* See the comment in calibrate_tsc(). */
>
> I would maybe add that the counters used here might have > 32 bits,
> and hence we need to trim the values for muldiv64 to scale properly.
Sure - I've added "But first scale down values to actually fit
muldiv64()'s input range."
Jan
|