From: Praveen Kumar <kumarpraveen@linux.microsoft.com>
To: Tianyu Lan <ltykernel@gmail.com>,
kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
x86@kernel.org, hpa@zytor.com, michael.h.kelley@microsoft.com
Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
vkuznets@redhat.com
Subject: Re: [PATCH] x86/Hyper-V: Initialize Hyper-V stimer after enabling lapic
Date: Thu, 5 Aug 2021 12:11:18 +0530 [thread overview]
Message-ID: <db8d38c9-e11d-1abe-8617-d8a231cc22e2@linux.microsoft.com> (raw)
In-Reply-To: <20210804184843.513524-1-ltykernel@gmail.com>
On 05-08-2021 00:18, Tianyu Lan wrote:
> From: Tianyu Lan <Tianyu.Lan@microsoft.com>
>
> Hyper-V Isolation VM doesn't have PIT/HPET legacy timer and only
> provide stimer. Initialize Hyper-v stimer just after enabling
> lapic to avoid kernel stuck during calibrating TSC due to no
> available timer.
>
> Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> ---
> arch/x86/hyperv/hv_init.c | 29 -----------------------------
> arch/x86/kernel/cpu/mshyperv.c | 22 ++++++++++++++++++++++
> 2 files changed, 22 insertions(+), 29 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 6f247e7e07eb..4a643a85d570 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -271,25 +271,6 @@ static struct syscore_ops hv_syscore_ops = {
> .resume = hv_resume,
> };
>
> -static void (* __initdata old_setup_percpu_clockev)(void);
> -
> -static void __init hv_stimer_setup_percpu_clockev(void)
> -{
> - /*
> - * Ignore any errors in setting up stimer clockevents
> - * as we can run with the LAPIC timer as a fallback.
> - */
> - (void)hv_stimer_alloc(false);
> -
> - /*
> - * Still register the LAPIC timer, because the direct-mode STIMER is
> - * not supported by old versions of Hyper-V. This also allows users
> - * to switch to LAPIC timer via /sys, if they want to.
> - */
> - if (old_setup_percpu_clockev)
> - old_setup_percpu_clockev();
> -}
> -
> static void __init hv_get_partition_id(void)
> {
> struct hv_get_partition_id *output_page;
> @@ -396,16 +377,6 @@ void __init hyperv_init(void)
> wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> }
>
> - /*
> - * hyperv_init() is called before LAPIC is initialized: see
> - * apic_intr_mode_init() -> x86_platform.apic_post_init() and
> - * apic_bsp_setup() -> setup_local_APIC(). The direct-mode STIMER
> - * depends on LAPIC, so hv_stimer_alloc() should be called from
> - * x86_init.timers.setup_percpu_clockev.
> - */
> - old_setup_percpu_clockev = x86_init.timers.setup_percpu_clockev;
> - x86_init.timers.setup_percpu_clockev = hv_stimer_setup_percpu_clockev;
> -
> hv_apic_init();
>
> x86_init.pci.arch_init = hv_pci_init;
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 6b5835a087a3..dcfbd2770d7f 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -214,6 +214,20 @@ static void __init hv_smp_prepare_boot_cpu(void)
> #endif
> }
>
> +static void (* __initdata old_setup_initr_mode)(void);
> +
> +static void __init hv_setup_initr_mode(void)
> +{
> + if (old_setup_initr_mode)
> + old_setup_initr_mode();
> +
> + /*
> + * The direct-mode STIMER depends on LAPIC and so allocate
> + * STIMER after calling initr node callback.
> + */
> + (void)hv_stimer_alloc(false);
In my understanding, in previous implementation we were ignoring the return error as there was a fallback handling for LAPIC.
However, I'm not seeing the same here, or am I missing something ?
> +}
> +
> static void __init hv_smp_prepare_cpus(unsigned int max_cpus)
> {
> #ifdef CONFIG_X86_64
> @@ -424,6 +438,7 @@ static void __init ms_hyperv_init_platform(void)
> /* Register Hyper-V specific clocksource */
> hv_init_clocksource();
> #endif
> +
> /*
> * TSC should be marked as unstable only after Hyper-V
> * clocksource has been initialized. This ensures that the
> @@ -431,6 +446,13 @@ static void __init ms_hyperv_init_platform(void)
> */
> if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> mark_tsc_unstable("running on Hyper-V");
> +
> + /*
> + * Override initr mode callback in order to allocate STIMER
> + * after initalizing LAPIC.
> + */
> + old_setup_initr_mode = x86_init.irqs.intr_mode_init;
> + x86_init.irqs.intr_mode_init = hv_setup_initr_mode;
> }
>
> static bool __init ms_hyperv_x2apic_available(void)
>
Regards,
~Praveen.
next prev parent reply other threads:[~2021-08-05 6:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-04 18:48 [PATCH] x86/Hyper-V: Initialize Hyper-V stimer after enabling lapic Tianyu Lan
2021-08-05 6:41 ` Praveen Kumar [this message]
2021-08-05 12:45 ` Tianyu Lan
2021-08-05 17:35 ` Michael Kelley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db8d38c9-e11d-1abe-8617-d8a231cc22e2@linux.microsoft.com \
--to=kumarpraveen@linux.microsoft.com \
--cc=Tianyu.Lan@microsoft.com \
--cc=bp@alien8.de \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ltykernel@gmail.com \
--cc=michael.h.kelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).