kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Simplify kvm timer handler
@ 2011-09-14  7:58 Jan Kiszka
  2011-10-03  7:58 ` Jan Kiszka
  2011-10-19 14:30 ` Marcelo Tosatti
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kiszka @ 2011-09-14  7:58 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm

The vcpu reference of a kvm_timer can't become NULL while the timer is
valid, so drop this redundant test. This also makes it pointless to
carry a separate __kvm_timer_fn, fold it into kvm_timer_fn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/kvm/timer.c |   26 ++++----------------------
 1 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c
index ae432ea..6b85cc6 100644
--- a/arch/x86/kvm/timer.c
+++ b/arch/x86/kvm/timer.c
@@ -18,9 +18,10 @@
 #include <linux/atomic.h>
 #include "kvm_timer.h"
 
-static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
+enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
 {
-	int restart_timer = 0;
+	struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
+	struct kvm_vcpu *vcpu = ktimer->vcpu;
 	wait_queue_head_t *q = &vcpu->wq;
 
 	/*
@@ -40,26 +41,7 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
 
 	if (ktimer->t_ops->is_periodic(ktimer)) {
 		hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
-		restart_timer = 1;
-	}
-
-	return restart_timer;
-}
-
-enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
-{
-	int restart_timer;
-	struct kvm_vcpu *vcpu;
-	struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
-
-	vcpu = ktimer->vcpu;
-	if (!vcpu)
-		return HRTIMER_NORESTART;
-
-	restart_timer = __kvm_timer_fn(vcpu, ktimer);
-	if (restart_timer)
 		return HRTIMER_RESTART;
-	else
+	} else
 		return HRTIMER_NORESTART;
 }
-
-- 
1.7.3.4

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

* Re: [PATCH] KVM: x86: Simplify kvm timer handler
  2011-09-14  7:58 [PATCH] KVM: x86: Simplify kvm timer handler Jan Kiszka
@ 2011-10-03  7:58 ` Jan Kiszka
  2011-10-18 16:23   ` Jan Kiszka
  2011-10-19 14:30 ` Marcelo Tosatti
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2011-10-03  7:58 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm

[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]

On 2011-09-14 09:58, Jan Kiszka wrote:
> The vcpu reference of a kvm_timer can't become NULL while the timer is
> valid, so drop this redundant test. This also makes it pointless to
> carry a separate __kvm_timer_fn, fold it into kvm_timer_fn.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  arch/x86/kvm/timer.c |   26 ++++----------------------
>  1 files changed, 4 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c
> index ae432ea..6b85cc6 100644
> --- a/arch/x86/kvm/timer.c
> +++ b/arch/x86/kvm/timer.c
> @@ -18,9 +18,10 @@
>  #include <linux/atomic.h>
>  #include "kvm_timer.h"
>  
> -static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
> +enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
>  {
> -	int restart_timer = 0;
> +	struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
> +	struct kvm_vcpu *vcpu = ktimer->vcpu;
>  	wait_queue_head_t *q = &vcpu->wq;
>  
>  	/*
> @@ -40,26 +41,7 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
>  
>  	if (ktimer->t_ops->is_periodic(ktimer)) {
>  		hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
> -		restart_timer = 1;
> -	}
> -
> -	return restart_timer;
> -}
> -
> -enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
> -{
> -	int restart_timer;
> -	struct kvm_vcpu *vcpu;
> -	struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
> -
> -	vcpu = ktimer->vcpu;
> -	if (!vcpu)
> -		return HRTIMER_NORESTART;
> -
> -	restart_timer = __kvm_timer_fn(vcpu, ktimer);
> -	if (restart_timer)
>  		return HRTIMER_RESTART;
> -	else
> +	} else
>  		return HRTIMER_NORESTART;
>  }
> -

Ping.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

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

* Re: [PATCH] KVM: x86: Simplify kvm timer handler
  2011-10-03  7:58 ` Jan Kiszka
@ 2011-10-18 16:23   ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2011-10-18 16:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm

On 2011-10-03 09:58, Jan Kiszka wrote:
> On 2011-09-14 09:58, Jan Kiszka wrote:
>> The vcpu reference of a kvm_timer can't become NULL while the
>> timer is valid, so drop this redundant test. This also makes it
>> pointless to carry a separate __kvm_timer_fn, fold it into
>> kvm_timer_fn.
>> 
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- 
>> arch/x86/kvm/timer.c |   26 ++++---------------------- 1 files
>> changed, 4 insertions(+), 22 deletions(-)
>> 
>> diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c index
>> ae432ea..6b85cc6 100644 --- a/arch/x86/kvm/timer.c +++
>> b/arch/x86/kvm/timer.c @@ -18,9 +18,10 @@ #include
>> <linux/atomic.h> #include "kvm_timer.h"
>> 
>> -static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct
>> kvm_timer *ktimer) +enum hrtimer_restart kvm_timer_fn(struct
>> hrtimer *data) { -	int restart_timer = 0; +	struct kvm_timer
>> *ktimer = container_of(data, struct kvm_timer, timer); +	struct
>> kvm_vcpu *vcpu = ktimer->vcpu; wait_queue_head_t *q = &vcpu->wq;
>> 
>> /* @@ -40,26 +41,7 @@ static int __kvm_timer_fn(struct kvm_vcpu
>> *vcpu, struct kvm_timer *ktimer)
>> 
>> if (ktimer->t_ops->is_periodic(ktimer)) { 
>> hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); -
>> restart_timer = 1; -	} - -	return restart_timer; -} - -enum
>> hrtimer_restart kvm_timer_fn(struct hrtimer *data) -{ -	int
>> restart_timer; -	struct kvm_vcpu *vcpu; -	struct kvm_timer
>> *ktimer = container_of(data, struct kvm_timer, timer); - -	vcpu =
>> ktimer->vcpu; -	if (!vcpu) -		return HRTIMER_NORESTART; - -
>> restart_timer = __kvm_timer_fn(vcpu, ktimer); -	if
>> (restart_timer) return HRTIMER_RESTART; -	else +	} else return
>> HRTIMER_NORESTART; } -
> 
> Ping.
> 

Ping II.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [PATCH] KVM: x86: Simplify kvm timer handler
  2011-09-14  7:58 [PATCH] KVM: x86: Simplify kvm timer handler Jan Kiszka
  2011-10-03  7:58 ` Jan Kiszka
@ 2011-10-19 14:30 ` Marcelo Tosatti
  1 sibling, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2011-10-19 14:30 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, kvm

On Wed, Sep 14, 2011 at 09:58:32AM +0200, Jan Kiszka wrote:
> The vcpu reference of a kvm_timer can't become NULL while the timer is
> valid, so drop this redundant test. This also makes it pointless to
> carry a separate __kvm_timer_fn, fold it into kvm_timer_fn.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  arch/x86/kvm/timer.c |   26 ++++----------------------
>  1 files changed, 4 insertions(+), 22 deletions(-)

Applied, thanks.


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

end of thread, other threads:[~2011-10-19 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14  7:58 [PATCH] KVM: x86: Simplify kvm timer handler Jan Kiszka
2011-10-03  7:58 ` Jan Kiszka
2011-10-18 16:23   ` Jan Kiszka
2011-10-19 14:30 ` Marcelo Tosatti

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