All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, KVM list <kvm@vger.kernel.org>,
	kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 6/8] KVM: PPC: E500: Implement MMU notifiers
Date: Tue, 07 Aug 2012 13:30:36 +0000	[thread overview]
Message-ID: <5021187C.50301@redhat.com> (raw)
In-Reply-To: <1344337036-22244-7-git-send-email-agraf@suse.de>

On 08/07/2012 01:57 PM, Alexander Graf wrote:
> The e500 target has lived without mmu notifiers ever since it got
> introduced, but fails for the user space check on them with hugetlbfs.
> 
> So in order to get that one working, implement mmu notifiers in a
> reasonably dumb fashion and be happy. On embedded hardware, we almost
> never end up with mmu notifier calls, since most people don't overcommit.
> 
>  
> +static void kvmppc_check_requests(struct kvm_vcpu *vcpu)
> +{
> +#if defined(CONFIG_KVM_E500V2) || defined(CONFIG_KVM_E500MC)
> +	if (vcpu->requests)
> +		if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
> +			kvmppc_core_flush_tlb(vcpu);
> +#endif
> +}
> +
>  /*
>   * Common checks before entering the guest world.  Call with interrupts
>   * disabled.
> @@ -485,12 +494,24 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
>  			break;
>  		}
>  
> +		smp_mb();
> +		kvmppc_check_requests(vcpu);
> +

On x86 we do the requests processing while in normal preemptible
context, then do an additional check for requests != 0 during guest
entry.  This allows us to do sleepy things in request processing, and
reduces the amount of work we do with interrupts disabled.

>  		if (kvmppc_core_prepare_to_enter(vcpu)) {
>  			/* interrupts got enabled in between, so we
>  			   are back at square 1 */
>  			continue;
>  		}
>  
> +		if (vcpu->mode = EXITING_GUEST_MODE) {
> +			r = 1;
> +			break;
> +		}
> +
> +		/* Going into guest context! Yay! */
> +		vcpu->mode = IN_GUEST_MODE;
> +		smp_wmb();
> +
>  		break;
>  	}
>  
> @@ -560,6 +581,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  #endif
>  
>  	kvm_guest_exit();
> +	vcpu->mode = OUTSIDE_GUEST_MODE;
> +	smp_wmb();
>  
> +/************* MMU Notifiers *************/
> +
> +int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
> +{
> +	/* Is this a guest page? */
> +	if (!hva_to_memslot(kvm, hva))
> +		return 0;
> +
> +	/*
> +	 * Flush all shadow tlb entries everywhere. This is slow, but
> +	 * we are 100% sure that we catch the to be unmapped page
> +	 */
> +	kvm_flush_remote_tlbs(kvm);

Wow.

> +
> +	return 0;
> +}
> +

Where do you drop the reference count when installing a page in a shadow
tlb entry?


-- 
error compiling committee.c: too many arguments to function

WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, KVM list <kvm@vger.kernel.org>,
	kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 6/8] KVM: PPC: E500: Implement MMU notifiers
Date: Tue, 07 Aug 2012 16:30:36 +0300	[thread overview]
Message-ID: <5021187C.50301@redhat.com> (raw)
In-Reply-To: <1344337036-22244-7-git-send-email-agraf@suse.de>

On 08/07/2012 01:57 PM, Alexander Graf wrote:
> The e500 target has lived without mmu notifiers ever since it got
> introduced, but fails for the user space check on them with hugetlbfs.
> 
> So in order to get that one working, implement mmu notifiers in a
> reasonably dumb fashion and be happy. On embedded hardware, we almost
> never end up with mmu notifier calls, since most people don't overcommit.
> 
>  
> +static void kvmppc_check_requests(struct kvm_vcpu *vcpu)
> +{
> +#if defined(CONFIG_KVM_E500V2) || defined(CONFIG_KVM_E500MC)
> +	if (vcpu->requests)
> +		if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
> +			kvmppc_core_flush_tlb(vcpu);
> +#endif
> +}
> +
>  /*
>   * Common checks before entering the guest world.  Call with interrupts
>   * disabled.
> @@ -485,12 +494,24 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
>  			break;
>  		}
>  
> +		smp_mb();
> +		kvmppc_check_requests(vcpu);
> +

On x86 we do the requests processing while in normal preemptible
context, then do an additional check for requests != 0 during guest
entry.  This allows us to do sleepy things in request processing, and
reduces the amount of work we do with interrupts disabled.

>  		if (kvmppc_core_prepare_to_enter(vcpu)) {
>  			/* interrupts got enabled in between, so we
>  			   are back at square 1 */
>  			continue;
>  		}
>  
> +		if (vcpu->mode == EXITING_GUEST_MODE) {
> +			r = 1;
> +			break;
> +		}
> +
> +		/* Going into guest context! Yay! */
> +		vcpu->mode = IN_GUEST_MODE;
> +		smp_wmb();
> +
>  		break;
>  	}
>  
> @@ -560,6 +581,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  #endif
>  
>  	kvm_guest_exit();
> +	vcpu->mode = OUTSIDE_GUEST_MODE;
> +	smp_wmb();
>  
> +/************* MMU Notifiers *************/
> +
> +int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
> +{
> +	/* Is this a guest page? */
> +	if (!hva_to_memslot(kvm, hva))
> +		return 0;
> +
> +	/*
> +	 * Flush all shadow tlb entries everywhere. This is slow, but
> +	 * we are 100% sure that we catch the to be unmapped page
> +	 */
> +	kvm_flush_remote_tlbs(kvm);

Wow.

> +
> +	return 0;
> +}
> +

Where do you drop the reference count when installing a page in a shadow
tlb entry?


-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-08-07 13:30 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07 10:57 [PATCH 0/8] KVM: PPC: E500: Implement MMU Notifiers Alexander Graf
2012-08-07 10:57 ` Alexander Graf
2012-08-07 10:57 ` [PATCH 1/8] KVM: PPC: BookE: Expose remote TLB flushes in debugfs Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 10:57 ` [PATCH 2/8] KVM: PPC: E500: Fix clear_tlb_refs Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 10:57 ` [PATCH 3/8] KVM: PPC: PR: Use generic tracepoint for guest exit Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 10:57 ` [PATCH 4/8] KVM: PPC: Expose SYNC cap based on mmu notifiers Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 10:57 ` [PATCH 5/8] KVM: Add hva_to_memslot Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-08  4:55   ` [kvmarm] " Christoffer Dall
2012-08-08  4:55     ` Christoffer Dall
2012-08-08 17:30     ` Alexander Graf
2012-08-08 17:30       ` Alexander Graf
2012-08-09 10:34   ` Takuya Yoshikawa
2012-08-09 10:34     ` Takuya Yoshikawa
2012-08-09 10:36     ` Avi Kivity
2012-08-09 10:36       ` Avi Kivity
2012-08-09 17:02       ` Alexander Graf
2012-08-09 17:02         ` Alexander Graf
2012-08-12  9:24         ` Avi Kivity
2012-08-12  9:24           ` Avi Kivity
2012-08-12 11:03           ` Alexander Graf
2012-08-12 11:03             ` Alexander Graf
2012-08-12 11:21             ` Avi Kivity
2012-08-12 11:21               ` Avi Kivity
2012-08-12 12:47               ` Alexander Graf
2012-08-12 12:47                 ` Alexander Graf
2012-08-07 10:57 ` [PATCH 6/8] KVM: PPC: E500: Implement MMU notifiers Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 13:30   ` Avi Kivity [this message]
2012-08-07 13:30     ` Avi Kivity
2012-08-07 13:52     ` Alexander Graf
2012-08-07 13:52       ` Alexander Graf
2012-08-07 14:14       ` Avi Kivity
2012-08-07 14:14         ` Avi Kivity
2012-08-07 14:24         ` Alexander Graf
2012-08-07 14:24           ` Alexander Graf
2012-08-08  3:31   ` Paul Mackerras
2012-08-08  3:31     ` Paul Mackerras
2012-08-08  8:03     ` Alexander Graf
2012-08-08  8:03       ` Alexander Graf
2012-08-07 10:57 ` [PATCH 7/8] KVM: Add page map arch callback Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 13:32   ` Avi Kivity
2012-08-07 13:32     ` Avi Kivity
2012-08-07 13:44     ` Alexander Graf
2012-08-07 13:44       ` Alexander Graf
2012-08-07 13:58       ` Avi Kivity
2012-08-07 13:58         ` Avi Kivity
2012-08-07 14:08         ` Alexander Graf
2012-08-07 14:08           ` Alexander Graf
2012-08-07 14:10           ` Avi Kivity
2012-08-07 14:10             ` Avi Kivity
2012-08-07 14:14             ` Alexander Graf
2012-08-07 14:14               ` Alexander Graf
2012-08-07 14:20               ` Avi Kivity
2012-08-07 14:20                 ` Avi Kivity
2012-08-07 14:24                 ` Alexander Graf
2012-08-07 14:24                   ` Alexander Graf
2012-08-07 14:31                   ` Avi Kivity
2012-08-07 14:31                     ` Avi Kivity
2012-08-07 10:57 ` [PATCH 8/8] KVM: PPC: Add cache flush on page map Alexander Graf
2012-08-07 10:57   ` Alexander Graf
2012-08-07 21:01   ` Scott Wood
2012-08-07 21:01     ` Scott Wood
2012-08-08  7:59     ` Alexander Graf
2012-08-08  7:59       ` Alexander Graf
2012-08-08 17:31 ` [PATCH 0/8] KVM: PPC: E500: Implement MMU Notifiers Alexander Graf
2012-08-08 17:31   ` Alexander Graf

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=5021187C.50301@redhat.com \
    --to=avi@redhat.com \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /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 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.