kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: "Nikunj A. Dadhania" <nikunj@linux.vnet.ibm.com>
Cc: peterz@infradead.org, avi@redhat.com, raghukt@linux.vnet.ibm.com,
	alex.shi@intel.com, mingo@elte.hu, kvm@vger.kernel.org,
	hpa@zytor.com
Subject: Re: [PATCH v3 6/8] KVM-HV: Add flush_on_enter before guest enter
Date: Thu, 2 Aug 2012 17:14:02 -0300	[thread overview]
Message-ID: <20120802201402.GA772@amt.cnet> (raw)
In-Reply-To: <20120731104859.16662.8738.stgit@abhimanyu.in.ibm.com>

On Tue, Jul 31, 2012 at 04:19:02PM +0530, Nikunj A. Dadhania wrote:
> From: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
> 
> PV-Flush guest would indicate to flush on enter, flush the TLB before
> entering and exiting the guest.
> 
> Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
> ---
>  arch/x86/kvm/x86.c |   23 +++++++----------------
>  1 files changed, 7 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 580abcf..a67e971 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1557,20 +1557,9 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
>  		&vcpu->arch.st.steal, sizeof(struct kvm_steal_time));
>  }
>  
> -static void kvm_set_atomic(u64 *addr, u64 old, u64 new)
> -{
> -	int loop = 1000000;
> -	while (1) {
> -		if (cmpxchg(addr, old, new) == old)
> -			break;
> -		loop--;
> -		if (!loop) {
> -			pr_info("atomic cur: %lx old: %lx new: %lx\n",
> -				*addr, old, new);
> -			break;
> -		}
> -	}
> -}
> +#define VS_NOT_IN_GUEST      (0)
> +#define VS_IN_GUEST          (1 << KVM_VCPU_STATE_IN_GUEST_MODE)
> +#define VS_SHOULD_FLUSH      (1 << KVM_VCPU_STATE_SHOULD_FLUSH)
>  
>  static void kvm_set_vcpu_state(struct kvm_vcpu *vcpu)
>  {
> @@ -1584,7 +1573,8 @@ static void kvm_set_vcpu_state(struct kvm_vcpu *vcpu)
>  	kaddr = kmap_atomic(vcpu->arch.v_state.vs_page);
>  	kaddr += vcpu->arch.v_state.vs_offset;
>  	vs = kaddr;
> -	kvm_set_atomic(&vs->state, 0, 1 << KVM_VCPU_STATE_IN_GUEST_MODE);
> +	if (xchg(&vs->state, VS_IN_GUEST) == VS_SHOULD_FLUSH)
> +		kvm_x86_ops->tlb_flush(vcpu);
>  	kunmap_atomic(kaddr);
>  }
>  
> @@ -1600,7 +1590,8 @@ static void kvm_clear_vcpu_state(struct kvm_vcpu *vcpu)
>  	kaddr = kmap_atomic(vcpu->arch.v_state.vs_page);
>  	kaddr += vcpu->arch.v_state.vs_offset;
>  	vs = kaddr;
> -	kvm_set_atomic(&vs->state, 1 << KVM_VCPU_STATE_IN_GUEST_MODE, 0);
> +	if (xchg(&vs->state, VS_NOT_IN_GUEST) == VS_SHOULD_FLUSH)
> +		kvm_x86_ops->tlb_flush(vcpu);
>  	kunmap_atomic(kaddr);
>  }

Nevermind the early comment (the other comments on that message are
valid).


  reply	other threads:[~2012-08-02 20:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 10:47 [PATCH v3 0/8] KVM paravirt remote flush tlb Nikunj A. Dadhania
2012-07-31 10:47 ` [PATCH v3 1/8] mm, x86: Add HAVE_RCU_TABLE_FREE support Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 2/8] mm: Add missing TLB invalidate to RCU page-table freeing Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 3/8] KVM Guest: Add VCPU running/pre-empted state for guest Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 4/8] KVM-HV: " Nikunj A. Dadhania
2012-08-02 19:56   ` Marcelo Tosatti
2012-08-03  5:17     ` Nikunj A Dadhania
2012-08-03  5:55     ` Nikunj A Dadhania
2012-08-03 17:31       ` Marcelo Tosatti
2012-08-04 18:33         ` Nikunj A Dadhania
2012-07-31 10:48 ` [PATCH v3 5/8] KVM Guest: Add paravirt kvm_flush_tlb_others Nikunj A. Dadhania
2012-07-31 10:49 ` [PATCH v3 6/8] KVM-HV: Add flush_on_enter before guest enter Nikunj A. Dadhania
2012-08-02 20:14   ` Marcelo Tosatti [this message]
2012-08-02 20:16     ` Marcelo Tosatti
2012-08-03  5:37       ` Nikunj A Dadhania
2012-08-03 17:31         ` Marcelo Tosatti
2012-07-31 10:49 ` [PATCH v3 7/8] Enable HAVE_RCU_TABLE_FREE for kvm when PARAVIRT_TLB_FLUSH is enabled Nikunj A. Dadhania
2012-07-31 10:49 ` [PATCH v3 8/8] KVM-doc: Add paravirt tlb flush document Nikunj A. Dadhania

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=20120802201402.GA772@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=alex.shi@intel.com \
    --cc=avi@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=raghukt@linux.vnet.ibm.com \
    /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).