[PATCH v2 3/3] LoongArch: Add paravirt preempt print prompt

Bibo Mao posted 3 patches 1 week ago
[PATCH v2 3/3] LoongArch: Add paravirt preempt print prompt
Posted by Bibo Mao 1 week ago
Add paravirt preempt print prompt together with steal timer information,
so that it is easy to check whether paravirt preempt feature is enabled
or not.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 arch/loongarch/kernel/paravirt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c
index d4163679adc4..ffe1cf284c41 100644
--- a/arch/loongarch/kernel/paravirt.c
+++ b/arch/loongarch/kernel/paravirt.c
@@ -300,6 +300,7 @@ static struct notifier_block pv_reboot_nb = {
 int __init pv_time_init(void)
 {
 	int r;
+	bool pv_preempted = false;
 
 	if (!kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
 		return 0;
@@ -322,8 +323,10 @@ int __init pv_time_init(void)
 		return r;
 	}
 
-	if (kvm_para_has_feature(KVM_FEATURE_PREEMPT))
+	if (kvm_para_has_feature(KVM_FEATURE_PREEMPT)) {
 		static_branch_enable(&virt_preempt_key);
+		pv_preempted = true;
+	}
 #endif
 
 	static_call_update(pv_steal_clock, paravt_steal_clock);
@@ -334,7 +337,10 @@ int __init pv_time_init(void)
 		static_key_slow_inc(&paravirt_steal_rq_enabled);
 #endif
 
-	pr_info("Using paravirt steal-time\n");
+	if (pv_preempted)
+		pr_info("Using paravirt steal-time with preempt hint enabled\n");
+	else
+		pr_info("Using paravirt steal-time with preempt hint disabled\n");
 
 	return 0;
 }
-- 
2.39.3
Re: [PATCH v2 3/3] LoongArch: Add paravirt preempt print prompt
Posted by Huacai Chen 1 week ago
Hi, Bibo,

On Mon, Nov 24, 2025 at 11:54 AM Bibo Mao <maobibo@loongson.cn> wrote:
>
> Add paravirt preempt print prompt together with steal timer information,
> so that it is easy to check whether paravirt preempt feature is enabled
> or not.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>  arch/loongarch/kernel/paravirt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c
> index d4163679adc4..ffe1cf284c41 100644
> --- a/arch/loongarch/kernel/paravirt.c
> +++ b/arch/loongarch/kernel/paravirt.c
> @@ -300,6 +300,7 @@ static struct notifier_block pv_reboot_nb = {
>  int __init pv_time_init(void)
>  {
>         int r;
> +       bool pv_preempted = false;
>
>         if (!kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
>                 return 0;
> @@ -322,8 +323,10 @@ int __init pv_time_init(void)
>                 return r;
>         }
>
> -       if (kvm_para_has_feature(KVM_FEATURE_PREEMPT))
> +       if (kvm_para_has_feature(KVM_FEATURE_PREEMPT)) {
>                 static_branch_enable(&virt_preempt_key);
> +               pv_preempted = true;
> +       }
>  #endif
>
>         static_call_update(pv_steal_clock, paravt_steal_clock);
> @@ -334,7 +337,10 @@ int __init pv_time_init(void)
>                 static_key_slow_inc(&paravirt_steal_rq_enabled);
>  #endif
>
> -       pr_info("Using paravirt steal-time\n");
> +       if (pv_preempted)
No pv_preempted needed, you can just use
static_key_enabled(&virt_preempt_key) and merge this patch to Patch-2.


Huacai

> +               pr_info("Using paravirt steal-time with preempt hint enabled\n");
> +       else
> +               pr_info("Using paravirt steal-time with preempt hint disabled\n");
>
>         return 0;
>  }
> --
> 2.39.3
>
Re: [PATCH v2 3/3] LoongArch: Add paravirt preempt print prompt
Posted by Bibo Mao 1 week ago

On 2025/11/24 下午2:33, Huacai Chen wrote:
> Hi, Bibo,
> 
> On Mon, Nov 24, 2025 at 11:54 AM Bibo Mao <maobibo@loongson.cn> wrote:
>>
>> Add paravirt preempt print prompt together with steal timer information,
>> so that it is easy to check whether paravirt preempt feature is enabled
>> or not.
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> ---
>>   arch/loongarch/kernel/paravirt.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c
>> index d4163679adc4..ffe1cf284c41 100644
>> --- a/arch/loongarch/kernel/paravirt.c
>> +++ b/arch/loongarch/kernel/paravirt.c
>> @@ -300,6 +300,7 @@ static struct notifier_block pv_reboot_nb = {
>>   int __init pv_time_init(void)
>>   {
>>          int r;
>> +       bool pv_preempted = false;
>>
>>          if (!kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
>>                  return 0;
>> @@ -322,8 +323,10 @@ int __init pv_time_init(void)
>>                  return r;
>>          }
>>
>> -       if (kvm_para_has_feature(KVM_FEATURE_PREEMPT))
>> +       if (kvm_para_has_feature(KVM_FEATURE_PREEMPT)) {
>>                  static_branch_enable(&virt_preempt_key);
>> +               pv_preempted = true;
>> +       }
>>   #endif
>>
>>          static_call_update(pv_steal_clock, paravt_steal_clock);
>> @@ -334,7 +337,10 @@ int __init pv_time_init(void)
>>                  static_key_slow_inc(&paravirt_steal_rq_enabled);
>>   #endif
>>
>> -       pr_info("Using paravirt steal-time\n");
>> +       if (pv_preempted)
> No pv_preempted needed, you can just use
> static_key_enabled(&virt_preempt_key) and merge this patch to Patch-2.
yes, good idea.
Will do in next version with these two points.

Regards
Bibo Mao
> 
> 
> Huacai
> 
>> +               pr_info("Using paravirt steal-time with preempt hint enabled\n");
>> +       else
>> +               pr_info("Using paravirt steal-time with preempt hint disabled\n");
>>
>>          return 0;
>>   }
>> --
>> 2.39.3
>>