linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/2] KVM: Introduce pv check helpers
@ 2020-02-11  1:55 linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-02-11  1:55 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Vitaly Kuznetsov,
	Jim Mattson, Joerg Roedel, LKML, kvm

Hi:
Wanpeng Li <kernellwp@gmail.com> wrote:
> Introduce some pv check helpers for consistency.
>
> Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
>  arch/x86/kernel/kvm.c | 34 ++++++++++++++++++++++++----------
>  1 file changed, 24 insertions(+), 10 deletions(-)

Looks good for me. Thanks.
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/2] KVM: Introduce pv check helpers
  2020-02-10  6:37 Wanpeng Li
@ 2020-02-10 15:38 ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 3+ messages in thread
From: Konrad Rzeszutek Wilk @ 2020-02-10 15:38 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: LKML, kvm, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
	Vitaly Kuznetsov, Jim Mattson, Joerg Roedel

On Mon, Feb 10, 2020 at 02:37:30PM +0800, Wanpeng Li wrote:
> From: Wanpeng Li <wanpengli@tencent.com>
> 
> Introduce some pv check helpers for consistency.
> 
> Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Thank you!
> ---
>  arch/x86/kernel/kvm.c | 34 ++++++++++++++++++++++++----------
>  1 file changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index d817f25..76ea8c4 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -425,7 +425,27 @@ static void __init sev_map_percpu_data(void)
>      }
>  }
> 
> +static bool pv_tlb_flush_supported(void)
> +{
> +    return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
> +        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> +        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
> +}
> +
>  #ifdef CONFIG_SMP
> +
> +static bool pv_ipi_supported(void)
> +{
> +    return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI);
> +}
> +
> +static bool pv_sched_yield_supported(void)
> +{
> +    return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
> +        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> +        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
> +}
> +
>  #define KVM_IPI_CLUSTER_SIZE    (2 * BITS_PER_LONG)
> 
>  static void __send_ipi_mask(const struct cpumask *mask, int vector)
> @@ -619,9 +639,7 @@ static void __init kvm_guest_init(void)
>          pv_ops.time.steal_clock = kvm_steal_clock;
>      }
> 
> -    if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
> -        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> -        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
> +    if (pv_tlb_flush_supported()) {
>          pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
>          pv_ops.mmu.tlb_remove_table = tlb_remove_table;
>      }
> @@ -632,9 +650,7 @@ static void __init kvm_guest_init(void)
>  #ifdef CONFIG_SMP
>      smp_ops.smp_prepare_cpus = kvm_smp_prepare_cpus;
>      smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu;
> -    if (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
> -        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> -        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
> +    if (pv_sched_yield_supported()) {
>          smp_ops.send_call_func_ipi = kvm_smp_send_call_func_ipi;
>          pr_info("KVM setup pv sched yield\n");
>      }
> @@ -700,7 +716,7 @@ static uint32_t __init kvm_detect(void)
>  static void __init kvm_apic_init(void)
>  {
>  #if defined(CONFIG_SMP)
> -    if (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI))
> +    if (pv_ipi_supported())
>          kvm_setup_pv_ipi();
>  #endif
>  }
> @@ -739,9 +755,7 @@ static __init int kvm_setup_pv_tlb_flush(void)
>      if (!kvm_para_available() || nopv)
>          return 0;
> 
> -    if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
> -        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> -        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
> +    if (pv_tlb_flush_supported()) {
>          for_each_possible_cpu(cpu) {
>              zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, cpu),
>                  GFP_KERNEL, cpu_to_node(cpu));
> --
> 2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] KVM: Introduce pv check helpers
@ 2020-02-10  6:37 Wanpeng Li
  2020-02-10 15:38 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 3+ messages in thread
From: Wanpeng Li @ 2020-02-10  6:37 UTC (permalink / raw)
  To: LKML, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Vitaly Kuznetsov,
	Jim Mattson, Joerg Roedel

From: Wanpeng Li <wanpengli@tencent.com>

Introduce some pv check helpers for consistency.

Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
 arch/x86/kernel/kvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index d817f25..76ea8c4 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -425,7 +425,27 @@ static void __init sev_map_percpu_data(void)
     }
 }

+static bool pv_tlb_flush_supported(void)
+{
+    return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
+        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
+}
+
 #ifdef CONFIG_SMP
+
+static bool pv_ipi_supported(void)
+{
+    return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI);
+}
+
+static bool pv_sched_yield_supported(void)
+{
+    return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
+        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
+        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
+}
+
 #define KVM_IPI_CLUSTER_SIZE    (2 * BITS_PER_LONG)

 static void __send_ipi_mask(const struct cpumask *mask, int vector)
@@ -619,9 +639,7 @@ static void __init kvm_guest_init(void)
         pv_ops.time.steal_clock = kvm_steal_clock;
     }

-    if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
-        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
-        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
+    if (pv_tlb_flush_supported()) {
         pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
         pv_ops.mmu.tlb_remove_table = tlb_remove_table;
     }
@@ -632,9 +650,7 @@ static void __init kvm_guest_init(void)
 #ifdef CONFIG_SMP
     smp_ops.smp_prepare_cpus = kvm_smp_prepare_cpus;
     smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu;
-    if (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
-        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
-        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
+    if (pv_sched_yield_supported()) {
         smp_ops.send_call_func_ipi = kvm_smp_send_call_func_ipi;
         pr_info("KVM setup pv sched yield\n");
     }
@@ -700,7 +716,7 @@ static uint32_t __init kvm_detect(void)
 static void __init kvm_apic_init(void)
 {
 #if defined(CONFIG_SMP)
-    if (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI))
+    if (pv_ipi_supported())
         kvm_setup_pv_ipi();
 #endif
 }
@@ -739,9 +755,7 @@ static __init int kvm_setup_pv_tlb_flush(void)
     if (!kvm_para_available() || nopv)
         return 0;

-    if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
-        !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
-        kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
+    if (pv_tlb_flush_supported()) {
         for_each_possible_cpu(cpu) {
             zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, cpu),
                 GFP_KERNEL, cpu_to_node(cpu));
--
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-11  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11  1:55 [PATCH v2 1/2] KVM: Introduce pv check helpers linmiaohe
  -- strict thread matches above, loose matches on Subject: below --
2020-02-10  6:37 Wanpeng Li
2020-02-10 15:38 ` Konrad Rzeszutek Wilk

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).