From patchwork Fri Aug 18 13:44:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 13357820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56D09C71150 for ; Fri, 18 Aug 2023 13:45:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.586327.917542 (Exim 4.92) (envelope-from ) id 1qWzmV-0003A9-Vp; Fri, 18 Aug 2023 13:44:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 586327.917542; Fri, 18 Aug 2023 13:44:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-0003A2-Sc; Fri, 18 Aug 2023 13:44:51 +0000 Received: by outflank-mailman (input) for mailman id 586327; Fri, 18 Aug 2023 13:44:50 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmU-0002v7-6t for xen-devel@lists.xenproject.org; Fri, 18 Aug 2023 13:44:50 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmU-0002FH-2Z; Fri, 18 Aug 2023 13:44:50 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qWzmT-00023L-Ot; Fri, 18 Aug 2023 13:44:49 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=BWbxLpVcdsByN5EAo3XWXuGnYzzBqiMaCs+W1sR2CtM=; b=XMFfOQU69Z2v/hs5HEQwqQrRKn uAVOYjQ8bZJZUmUytMc2iHxKKF8KUIgeLWwrBUvNcsdSFvuXLC8heMhKIu3yZbLvgIobQDjE7kzhK wDV/YRfTsjh69Lge3KLwu2VOphcKk84hDXIv1lkjLe66M3V2P7evp5A1BLBE0JC5feLk=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 1/2] xen/x86: io_apic: Introduce a command line option to skip timer check Date: Fri, 18 Aug 2023 14:44:40 +0100 Message-Id: <20230818134441.45586-2-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230818134441.45586-1-julien@xen.org> References: <20230818134441.45586-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Currently, Xen will spend ~100ms to check if the timer works. If the Admin knows their platform have a working timer, then it would be handy to be able to bypass the check. Introduce a command line option 'no_timer_check' (the name is matching the Linux parameter) for this purpose. Signed-off-by: Julien Grall --- docs/misc/xen-command-line.pandoc | 7 +++++++ xen/arch/x86/io_apic.c | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 4872b9098e83..1f9d3106383f 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1896,6 +1896,13 @@ This option is ignored in **pv-shim** mode. ### nr_irqs (x86) > `= ` +### no_timer_works (x86) +> `=` + +> Default: `true` + +Disables the code which tests for broken timer IRQ sources. + ### irq-max-guests (x86) > `= ` diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index b3afef8933d7..4875bb97003f 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -57,6 +57,14 @@ bool __initdata ioapic_ack_forced; int __read_mostly nr_ioapic_entries[MAX_IO_APICS]; int __read_mostly nr_ioapics; +/* + * The logic to check if the timer is working is expensive. So allow + * the admin to bypass it if they know their platform doesn't have + * a buggy timer. + */ +static bool __initdata no_timer_check; +boolean_param("no_timer_check", no_timer_check); + /* * Rough estimation of how many shared IRQs there are, can * be changed anytime. @@ -1502,6 +1510,9 @@ static int __init timer_irq_works(void) { unsigned long t1, flags; + if ( no_timer_check ) + return 1; + t1 = ACCESS_ONCE(pit0_ticks); local_save_flags(flags); From patchwork Fri Aug 18 13:44:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 13357819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E22AC71149 for ; Fri, 18 Aug 2023 13:45:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.586328.917551 (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pz-5r; Fri, 18 Aug 2023 13:44:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 586328.917551; Fri, 18 Aug 2023 13:44:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pq-32; Fri, 18 Aug 2023 13:44:53 +0000 Received: by outflank-mailman (input) for mailman id 586328; Fri, 18 Aug 2023 13:44:51 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-00034T-6g for xen-devel@lists.xenproject.org; Fri, 18 Aug 2023 13:44:51 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-0002FT-36; Fri, 18 Aug 2023 13:44:51 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qWzmU-00023L-Rg; Fri, 18 Aug 2023 13:44:51 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lf3E6qWM/eYtxtUMYYrXFPP69s9JP5c1zgdxZnGHfo4=; b=swKHiGCGFvxejmKdL/hpiUNxhz 8ZF+q6EvrHvFPpN8MQQm0/6gaNJgVZLE9eioHmEJ57dct1wC911FKpZLKKiBsr7201nAVfRkO7NZ5 ulmZuuFDt9abwG4IWVonkSF4HDFu8Dc0oFmXP4nL3SQ15/xBPoq4GCu5k1XScQiCznZM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/2] xen/x86: ioapic: Bail out from timer_irq_works() as soon as possible Date: Fri, 18 Aug 2023 14:44:41 +0100 Message-Id: <20230818134441.45586-3-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230818134441.45586-1-julien@xen.org> References: <20230818134441.45586-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall 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 --- xen/arch/x86/io_apic.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 4875bb97003f..0bd774962a68 100644 --- 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; if ( no_timer_check ) return 1; @@ -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; }