[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 4 Apr 2022 14:43:26 +0200
  • 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=HciF5PxIQ/A+isnDsu/+Q86UpJzaLpfYjgLF8qaTJ00=; b=QjJEt1fSSRsGLphpQ8X9MSr2ioHTfDW4XBGjuSkJgvX74DoWWthJAwnCwt0DOk/g5ib5TmBTmAh/BjL4j23DQzIXhY8XPGUT6VqmqCLROXAKsLtLZy/YdW1QQNH8csE7nmXytT1B54AvqrJYm+Y/kxM6IFgtwb5ngV5GUo+rc36D3avXFDm8L7vaax8rEnIRLKO0U9aOtzulLvU9wn8tEtwaOqDz1gFKsh5bNS5qpPzFA7go9yDz8cEaOjjcZFwjcWzFxYM5n+R3arSse5WRgmJSwzvUwXs4LwNvc81VxSrDslDY+yIHiFNjYsmSUpmfgpDCkTbE35LRDn24PSfgsQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IpZT1mAGIxjOyPVXOdMLaNOZX5xzbtZg6ngfM5oyifGvj1ZvELFfmjMI3p1mCkKy6X3hRCPCI5eNECN6ueniqU90It2kJnor8L89zImLBvLXqf/wBAsgqqcsoe5lCh0WbbGnw/uGsOrl+PutOLHnlQ9SBHdFqU9uVPrepsC33Kg3tL+wBUwAiUgQptcTfqaI4h7VjihgJMG917FEO6UKuxd70lPldXseh42X4pm5J8Btvag6eFy5oGyp0gP3pBE6BfVr3eE96V4rNX7lXdO2meDTazR/Xx7UEgyrt41wKgl//ZgnY8AYlw5XEwCNu+BSIRzlsTTd7e4oV5seXm0SiA==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 04 Apr 2022 12:43:58 +0000
  • Ironport-data: A9a23:3qAlL6DnQyZJFBVW/z/jw5YqxClBgxIJ4kV8jS/XYbTApGsnhDMDx 2VODWzXbPncZjSjLdtzPtiw905S7JSEx4VqQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Jh3tYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPgy8 /xk5duoUDx2P5f9ouEvdTUGOC1XaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguw5K8bmJsUHs2xIxjDFF/c2B5vERs0m4PcGjGxs3ZgeRZ4yY eI9ORBJSSr6USF2BX0wBIhl2+qZu1jGJmgwRFW9+vNsvjm7IBZK+KfpGMrYfJqNX8o9tlaVo CfK8nr0BjkeNceD0nyV/3S0nOjNkCjnHoUIG9WQ9PRnnVmSzWw7EwANWB2wpvzRt6Klc4sBc QpOoHNo9PVsshzwJjXgY/GmiD2/lzdMHMJJKLI70jC3z5jyz1iyCkFRG1atd+canMM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rl56cm6XXZ3uBRr22uvKCfMOlaWXRKA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Apr 04, 2022 at 01:55:56PM +0200, Jan Beulich wrote:
> 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."

With those taken care of:

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.