login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
November
»
22
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_page path
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Marcelo Tosatti
Subject:
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_page path
Date: Monday, November 22, 2010 - 2:46 pm
On Mon, Nov 22, 2010 at 12:19:25PM -0200, Marcelo Tosatti wrote:
quoted text
> On Mon, Nov 22, 2010 at 11:45:18AM +0800, Xiao Guangrong wrote: > > On 11/20/2010 12:11 AM, Marcelo Tosatti wrote: > > > > >> void kvm_flush_remote_tlbs(struct kvm *kvm) > > >> { > > >> + int dirty_count = atomic_read(&kvm->tlbs_dirty); > > >> + > > >> + smp_mb(); > > >> if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) > > >> ++kvm->stat.remote_tlb_flush; > > >> + atomic_sub(dirty_count, &kvm->tlbs_dirty); > > >> } > > > > > > This is racy because kvm_flush_remote_tlbs might be called without > > > mmu_lock protection. > > > > Sorry for my carelessness, it should be 'cmpxchg' here. > > > > > You could decrease the counter on > > > invalidate_page/invalidate_range_start only, > > > > I want to avoid a unnecessary tlbs flush, if tlbs have been flushed > > after sync_page, then we don't need flush tlbs on invalidate_page/ > > invalidate_range_start path. > > > > > these are not fast paths > > > anyway. > > > > > > > How about below patch? it just needs one atomic operation. > > > > --- > > arch/x86/kvm/paging_tmpl.h | 4 ++-- > > include/linux/kvm_host.h | 2 ++ > > virt/kvm/kvm_main.c | 7 ++++++- > > 3 files changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h > > index dfb906f..e64192f 100644 > > --- a/arch/x86/kvm/paging_tmpl.h > > +++ b/arch/x86/kvm/paging_tmpl.h > > @@ -781,14 +781,14 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) > > gfn = gpte_to_gfn(gpte); > > > > if (FNAME(map_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) { > > - kvm_flush_remote_tlbs(vcpu->kvm); > > + vcpu->kvm->tlbs_dirty++; > > continue; > > } > > > > if (gfn != sp->gfns[i]) { > > drop_spte(vcpu->kvm, &sp->spt[i], > > shadow_trap_nonpresent_pte); > > - kvm_flush_remote_tlbs(vcpu->kvm); > > + vcpu->kvm->tlbs_dirty++; > > continue; > > } > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 4bd663d..dafd90e 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -249,6 +249,7 @@ struct kvm { > > struct mmu_notifier mmu_notifier; > > unsigned long mmu_notifier_seq; > > long mmu_notifier_count; > > + long tlbs_dirty; > > #endif > > }; > > > > @@ -377,6 +378,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); > > void kvm_resched(struct kvm_vcpu *vcpu); > > void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); > > void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); > > + > > void kvm_flush_remote_tlbs(struct kvm *kvm); > > void kvm_reload_remote_mmus(struct kvm *kvm); > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index fb93ff9..fe0a1a7 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -168,8 +168,12 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) > > > > void kvm_flush_remote_tlbs(struct kvm *kvm) > > { > > + long dirty_count = kvm->tlbs_dirty; > > + > > + smp_mb(); > > if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) > > ++kvm->stat.remote_tlb_flush; > > <--- > > > + cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); > > } > > > Still problematic, if tlbs_dirty is set in the point indicated above. > > Invalidate page should be quite rare, so checking for tlb_dirty only > there is OK. >
My bad, the patch is fine. --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH v3 1/6] KVM: MMU: fix forgot flush tlbs on sync_pag ...
, Xiao Guangrong
, (Fri Nov 19, 2:01 am)
[PATCH v3 2/6] KVM: MMU: don't drop spte if overwrite it f ...
, Xiao Guangrong
, (Fri Nov 19, 2:02 am)
[PATCH v3 3/6] KVM: MMU: rename 'reset_host_protection' to ...
, Xiao Guangrong
, (Fri Nov 19, 2:03 am)
[PATCH v3 4/6] KVM: MMU: remove 'clear_unsync' parameter
, Xiao Guangrong
, (Fri Nov 19, 2:04 am)
[PATCH v3 5/6] KVM: MMU: abstract invalid guest pte mapping
, Xiao Guangrong
, (Fri Nov 19, 2:04 am)
[PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_page ...
, Xiao Guangrong
, (Fri Nov 19, 2:05 am)
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_ ...
, Marcelo Tosatti
, (Fri Nov 19, 9:11 am)
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_ ...
, Xiao Guangrong
, (Sun Nov 21, 8:45 pm)
Re: [PATCH v3 5/6] KVM: MMU: abstract invalid guest pte ma ...
, Avi Kivity
, (Mon Nov 22, 2:28 am)
Re: [PATCH v3 5/6] KVM: MMU: abstract invalid guest pte ma ...
, Avi Kivity
, (Mon Nov 22, 3:17 am)
Re: [PATCH v3 5/6] KVM: MMU: abstract invalid guest pte ma ...
, Xiao Guangrong
, (Mon Nov 22, 3:18 am)
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_ ...
, Marcelo Tosatti
, (Mon Nov 22, 7:19 am)
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_ ...
, Marcelo Tosatti
, (Mon Nov 22, 2:46 pm)
Re: [PATCH v3 5/6] KVM: MMU: abstract invalid guest pte ma ...
, Xiao Guangrong
, (Mon Nov 22, 8:08 pm)
Re: [PATCH v3 6/6] KVM: MMU: delay flush all tlbs on sync_ ...
, Xiao Guangrong
, (Mon Nov 22, 8:13 pm)
Re: [PATCH v3 1/6] KVM: MMU: fix forgot flush tlbs on sync ...
, Xiao Guangrong
, (Thu Nov 25, 6:37 pm)
Re: [PATCH v3 1/6] KVM: MMU: fix forgot flush tlbs on sync ...
, Marcelo Tosatti
, (Fri Nov 26, 7:29 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg KH
Og dreams of kernels
Jens Axboe
[PATCH 31/33] Fusion: sg chaining support
Arnd Bergmann
Re: finding your own dead "CONFIG_" variables
Mark Brown
[PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset
Tony Breeds
[LGUEST] Look in object dir for .config
git
:
Brian Downing
Re: Git in a Nutshell guide
John Benes
Re: master has some toys
Matthias Lederhofer
[PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree
Alexander Sulfrian
[RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set
Junio C Hamano
Re: Rss produced by git is not valid xml?
git-commits-head
:
Linux Kernel Mailing List
iSeries: fix section mismatch in iseries_veth
Linux Kernel Mailing List
ixbge: remove TX lock and redo TX accounting.
Linux Kernel Mailing List
ixgbe: fix several counter register errata
Linux Kernel Mailing List
b43: fix build with CONFIG_SSB_PCIHOST=n
Linux Kernel Mailing List
9p: block-based virtio client
linux-netdev
:
Michael Breuer
Re: [PATCH] af_packet: Don't use skb after dev_queue_xmit()
Michael Breuer
Re: [PATCH] af_packet: Don't use skb after dev_queue_xmit()
David Daney
[PATCH 5/7] Staging: Octeon Ethernet: Convert to NAPI.
Wolfgang Grandegger
[PATCH net-next v4 1/3] can: mscan: fix improper return if dlc < 8 in start_xmi...
Amit Kumar Salecha
[PATCHv3 NEXT 2/2] NET: Add Qlogic ethernet driver for CNA devices
openbsd-misc
:
Theo de Raadt
Re: Old IPSEC bug
Tomáš Bodžár
Problem with vpnc connection - check group password !
Insan Praja SW
Mandoc Compiling Error
Carl Roberso
Re: Cannot change MTU of carp interface?
Richard Daemon
Re: booting openbsd on eee without cd-rom
Colocation donated by:
Syndicate