[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] xen/x86: ioapic: Bail out from timer_irq_works() as soon as possible


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 7 Sep 2023 16:28:21 +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=TiCBhD+IhfAN28vO1QAQM86F+nxEnVn+3e3jFJX+R4s=; b=bmqYt2ja/p3gQ16U4fCyVz9zQ2zX/UZDdnohPNOGYQID/VzuXBrllCoiHGNwJmPBpFRlkgug2WfmDYXHHWyxMQnS7+soMQUuzvYSngSwX4hf216X2t040KOp0/MJpkzSf+whUQJEGSwDz0vNNkrP4rJCk8jcbtNZ9u4wg+oa4HXavOribzldVt6v9WpkZS048NRn2Lq2yjwcAXXwjgO+vhI2zzFDvegc7Wx9f3vqmIf2F/fxp4dE+BBy2HBiZIBumia1OGC6TF8KDmxMCeKkcaeOwu2XQTJL8mKjW8jNWwtZvEJwG5lH4x+cNTk36FjN3TbO1R3diqyBwpq3YIHKRA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=md5xo0ePuzsX2JAQh+N5hA+MpTxStftUfJbwdYJs5+NhpvFvNlEgTz0MMjKfWi7gfdzuNym3u8pm3r4TBtHLUAAPr8AehvU3Y2TEs5VM80vRv0JMTyiq1h1Biw0nclwxElCk6jVWfx7RVtigqNkWTdi7QUVrZ1hdMM1KKfvdeu75mr6g9GAXt4Mjdv3iM7yHtDvAmYnmJTrVDuGVvWg+Uh9Wc6po2QySmNTeDnPNtlf/e04mwjLf7cgUedwn/iOfXIjTxt+L2lhr6IZG8YRHd83NuBXQtrkpF4NNpDCn+ZyJKaPlkBzryWGngRvDeu8c3c3ZUaa26l4RSyXFMvseRg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 07 Sep 2023 14:29:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18.08.2023 15:44, Julien Grall wrote:
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> Currently timer_irq_works() will wait the full 100ms before checking
> that pit0_ticks has been incremented at least 4 times.
> 
> However, the bulk of the BIOS/platform should not have a buggy timer.
> So waiting for the full 100ms is a bit harsh.
> 
> Rework the logic to only wait until 100ms passed or we saw more than
> 4 ticks. So now, in the good case, this will reduce the wait time
> to ~50ms.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

In principle this is all fine. There's a secondary aspect though which
may call for a slight rework of the patch.

> --- a/xen/arch/x86/io_apic.c
> +++ b/xen/arch/x86/io_apic.c
> @@ -1509,6 +1509,8 @@ static void __init setup_ioapic_ids_from_mpc(void)
>  static int __init timer_irq_works(void)
>  {
>      unsigned long t1, flags;
> +    /* Wait for maximum 10 ticks */
> +    unsigned long msec = (10 * 1000) / HZ;

(Minor remark: I don't think this needs to be unsigned long; unsigned
in will suffice.)

> @@ -1517,19 +1519,25 @@ static int __init timer_irq_works(void)
>  
>      local_save_flags(flags);
>      local_irq_enable();
> -    /* Let ten ticks pass... */
> -    mdelay((10 * 1000) / HZ);
> -    local_irq_restore(flags);
>  
> -    /*
> -     * Expect a few ticks at least, to be sure some possible
> -     * glue logic does not lock up after one or two first
> -     * ticks in a non-ExtINT mode.  Also the local APIC
> -     * might have cached one ExtINT interrupt.  Finally, at
> -     * least one tick may be lost due to delays.
> -     */
> -    if ( (ACCESS_ONCE(pit0_ticks) - t1) > 4 )
> +    while ( msec-- )
> +    {
> +        mdelay(1);
> +        /*
> +         * Expect a few ticks at least, to be sure some possible
> +         * glue logic does not lock up after one or two first
> +         * ticks in a non-ExtINT mode.  Also the local APIC
> +         * might have cached one ExtINT interrupt.  Finally, at
> +         * least one tick may be lost due to delays.
> +         */
> +        if ( (ACCESS_ONCE(pit0_ticks) - t1) <= 4 )
> +            continue;
> +
> +        local_irq_restore(flags);
>          return 1;
> +    }
> +
> +    local_irq_restore(flags);
>  
>      return 0;
>  }

While Andrew has a patch pending (not sure why it didn't go in yet)
to simplify local_irq_restore(), and while further it shouldn't really
need using here (local_irq_disable() ought to be fine), I can see that
you don't want to make such an adjustment here. But then I'd prefer if
we got away with just a single instance, adjusting the final return
statement accordingly (easiest would likely be to go from the value of
"msec").

Jan



 


Rackspace

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