All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: The return type of the function could be void
@ 2022-05-06  4:21 Li kunyu
  2022-05-06  7:59 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 4+ messages in thread
From: Li kunyu @ 2022-05-06  4:21 UTC (permalink / raw)
  To: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, tglx,
	mingo, bp, dave.hansen, x86, hpa
  Cc: kvm, linux-kernel, Li kunyu

Perhaps the return value of the function is not used.
It may be possible to optimize the execution instructions.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 arch/x86/kvm/hyperv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 46f9dfb60469..64c0d1f54258 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -608,7 +608,7 @@ static enum hrtimer_restart stimer_timer_callback(struct hrtimer *timer)
  * a) stimer->count is not equal to 0
  * b) stimer->config has HV_STIMER_ENABLE flag
  */
-static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
+static void stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 {
 	u64 time_now;
 	ktime_t ktime_now;
@@ -638,7 +638,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 			      ktime_add_ns(ktime_now,
 					   100 * (stimer->exp_time - time_now)),
 			      HRTIMER_MODE_ABS);
-		return 0;
+		return;
 	}
 	stimer->exp_time = stimer->count;
 	if (time_now >= stimer->count) {
@@ -649,7 +649,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 		 * the past, it will expire immediately."
 		 */
 		stimer_mark_pending(stimer, false);
-		return 0;
+		return;
 	}
 
 	trace_kvm_hv_stimer_start_one_shot(hv_stimer_to_vcpu(stimer)->vcpu_id,
@@ -659,7 +659,6 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 	hrtimer_start(&stimer->timer,
 		      ktime_add_ns(ktime_now, 100 * (stimer->count - time_now)),
 		      HRTIMER_MODE_ABS);
-	return 0;
 }
 
 static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,
-- 
2.18.2


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

* Re: [PATCH] x86: The return type of the function could be void
  2022-05-06  4:21 [PATCH] x86: The return type of the function could be void Li kunyu
@ 2022-05-06  7:59 ` Vitaly Kuznetsov
  0 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2022-05-06  7:59 UTC (permalink / raw)
  To: Li kunyu
  Cc: kvm, linux-kernel, Li kunyu, pbonzini, seanjc, wanpengli,
	jmattson, joro, tglx, mingo, bp, dave.hansen, x86, hpa

Li kunyu <kunyu@nfschina.com> writes:

> Perhaps the return value of the function is not used.
> It may be possible to optimize the execution instructions.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  arch/x86/kvm/hyperv.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 46f9dfb60469..64c0d1f54258 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -608,7 +608,7 @@ static enum hrtimer_restart stimer_timer_callback(struct hrtimer *timer)
>   * a) stimer->count is not equal to 0
>   * b) stimer->config has HV_STIMER_ENABLE flag
>   */
> -static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
> +static void stimer_start(struct kvm_vcpu_hv_stimer *stimer)
>  {
>  	u64 time_now;
>  	ktime_t ktime_now;
> @@ -638,7 +638,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
>  			      ktime_add_ns(ktime_now,
>  					   100 * (stimer->exp_time - time_now)),
>  			      HRTIMER_MODE_ABS);
> -		return 0;
> +		return;
>  	}
>  	stimer->exp_time = stimer->count;
>  	if (time_now >= stimer->count) {
> @@ -649,7 +649,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
>  		 * the past, it will expire immediately."
>  		 */
>  		stimer_mark_pending(stimer, false);
> -		return 0;
> +		return;
>  	}
>  
>  	trace_kvm_hv_stimer_start_one_shot(hv_stimer_to_vcpu(stimer)->vcpu_id,
> @@ -659,7 +659,6 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
>  	hrtimer_start(&stimer->timer,
>  		      ktime_add_ns(ktime_now, 100 * (stimer->count - time_now)),
>  		      HRTIMER_MODE_ABS);
> -	return 0;
>  }
>  
>  static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,

stimer_start() has only one user so it'll likely get inlined by the
compiler which then will be able to figure out that the return value is
not used and thus the assembley code will likely remain the same but
this is a good cleanup nevertheless, so 

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


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

* Re: [PATCH] x86: The return type of the function could be void
  2022-05-11  5:16 Li kunyu
@ 2022-05-11 17:30 ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-05-11 17:30 UTC (permalink / raw)
  To: Li kunyu
  Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen,
	the arch/x86 maintainers, H. Peter Anvin, Linux PM,
	Linux Kernel Mailing List

On Wed, May 11, 2022 at 7:16 AM Li kunyu <kunyu@nfschina.com> wrote:
>
> perhaps the return value of the function is not used.
> it may be possible to optimize the execution instructions.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  arch/x86/kernel/acpi/boot.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 0d01e7f5078c..7e32e33d52fa 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -375,7 +375,7 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
>         isa_irq_to_gsi[bus_irq] = gsi;
>  }
>
> -static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
> +static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
>                         int polarity)
>  {
>  #ifdef CONFIG_X86_MPPARSE
> @@ -387,9 +387,9 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
>         u8 pin;
>
>         if (!acpi_ioapic)
> -               return 0;
> +               return;
>         if (!dev || !dev_is_pci(dev))
> -               return 0;
> +               return;
>
>         pdev = to_pci_dev(dev);
>         number = pdev->bus->number;
> @@ -408,7 +408,6 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
>
>         mp_save_irq(&mp_irq);
>  #endif
> -       return 0;
>  }
>
>  static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
> --

Applied as 5.19 material with rewritten subject and changelog, thanks!

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

* [PATCH] x86: The return type of the function could be void
@ 2022-05-11  5:16 Li kunyu
  2022-05-11 17:30 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Li kunyu @ 2022-05-11  5:16 UTC (permalink / raw)
  To: rafael, len.brown, pavel, tglx, mingo, bp, dave.hansen, x86, hpa
  Cc: linux-pm, linux-kernel, Li kunyu

perhaps the return value of the function is not used.
it may be possible to optimize the execution instructions.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 arch/x86/kernel/acpi/boot.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 0d01e7f5078c..7e32e33d52fa 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -375,7 +375,7 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
 	isa_irq_to_gsi[bus_irq] = gsi;
 }
 
-static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
+static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
 			int polarity)
 {
 #ifdef CONFIG_X86_MPPARSE
@@ -387,9 +387,9 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
 	u8 pin;
 
 	if (!acpi_ioapic)
-		return 0;
+		return;
 	if (!dev || !dev_is_pci(dev))
-		return 0;
+		return;
 
 	pdev = to_pci_dev(dev);
 	number = pdev->bus->number;
@@ -408,7 +408,6 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
 
 	mp_save_irq(&mp_irq);
 #endif
-	return 0;
 }
 
 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
-- 
2.18.2


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

end of thread, other threads:[~2022-05-11 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06  4:21 [PATCH] x86: The return type of the function could be void Li kunyu
2022-05-06  7:59 ` Vitaly Kuznetsov
2022-05-11  5:16 Li kunyu
2022-05-11 17:30 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.