From: "Jan Beulich" Subject: Re: [PATCH] EPT: Flush running cpus, add mask to flush when scheduled in Date: Tue, 22 Sep 2009 08:07:34 +0100 Message-ID: <4AB893D60200007800016283@vpn.id2.novell.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap Cc: Xiaohui Xin , Xin Li , Tim Deegan , Paul Durrant , Keir Fraser , Jun Nakajima , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org >--- a/xen/arch/x86/hvm/vmx/vmx.c Tue Sep 15 10:08:12 2009 +0100 >+++ b/xen/arch/x86/hvm/vmx/vmx.c Mon Sep 21 18:52:26 2009 +0100 >... >@@ -1219,7 +1226,11 @@ > if ( d->arch.hvm_domain.hap_enabled && d->vcpu && d->vcpu[0] ) > { > ASSERT(local_irq_is_enabled()); >- on_each_cpu(__ept_sync_domain, d, 1); >+ /* Mark cpus that may need flushing on next schedule */ >+ cpus_complement(d->arch.hvm_domain.vmx.ept_needs_flush, >+ d->domain_dirty_cpumask); >+ /* And flush on actively-running processors */ >+ on_selected_cpus(&d->domain_dirty_cpumask, __ept_sync_domain, d, = 1); > } > } >=20 Passing a pointer to the global cpu mask looks racy here: What if a CPU disappears from domain_dirty_cpumask under your feet? Also, merely using cpus_complement() here seem inefficient: It should be possible to accumulate the flush activity, and avoid re-flushing on a CPU which e.g. got flushed on the second from the last run through this code (and not dirtied afterwards). I.e. I'd think there should be cpus_andnot() here, and setting of the bits as CPUs get dirtied. Jan