On Mon, Jul 03, 2006 at 03:19:39PM +0200, Tristan Gingold wrote:
> Le Lundi 03 Juillet 2006 15:00, Isaku Yamahata a écrit :
> > On Mon, Jul 03, 2006 at 02:45:08PM +0200, Tristan Gingold wrote:
> > > Why not adding the 'int last_cpu' field in the struct arch_vcpu ?
> > > If two vcpus are running on the same cpu, the VHPT is always up to date.
> >
> > Since there is no gurantee that both two vcpu map
> > (rid, virtual address) to a same pseudo physical address,
> > VHPT and mTLB must be flushed everytime vcpu is switched.
> > If they aren't flushed, it is highly likey that the per cpu variable
> > area will be broken.
> You are correct about percpu area.

Probably now I understand whan you were seeing.
Please see the attached patch.

-- 
yamahata
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID a55e5195e5f7fc6a55a147ff3e8d1b94d4667c70
# Parent  f7132169c2bf453db85f40b4041380f387b74082
more tlb flush when vcpu migration between pcpu.
When vcpu is migrated to another pcpu and then it returns to the first
pcpu, VHPT and mTLB must also be flushed.
PATCHNAME: more_vcpu_migration

Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]>

diff -r f7132169c2bf -r a55e5195e5f7 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Mon Jul 03 09:11:49 2006 -0600
+++ b/xen/arch/ia64/xen/domain.c        Tue Jul 04 15:17:26 2006 +0900
@@ -94,25 +94,32 @@ DEFINE_PER_CPU(int *, current_psr_ic_add
 
 static void flush_vtlb_for_context_switch(struct vcpu* vcpu)
 {
-       int last_vcpu_id =
-               vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id;
-
-       if (is_idle_domain(vcpu->domain) || last_vcpu_id == vcpu->vcpu_id)
+       int cpu = smp_processor_id();
+       int last_vcpu_id = vcpu->domain->arch.last_vcpu[cpu].vcpu_id;
+       int last_processor = vcpu->arch.last_processor;
+
+       if (is_idle_domain(vcpu->domain))
                return;
-       vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id =
-               vcpu->vcpu_id;
-       if (last_vcpu_id == INVALID_VCPU_ID) 
-               return;
-
-       // if the vTLB implementation was changed,
-       // the followings must be updated either.
-       if (VMX_DOMAIN(vcpu)) {
-               // currently vTLB for vt-i domian is per vcpu.
-               // so any flushing isn't needed.
-       } else {
-               vhpt_flush();
-       }
-       local_flush_tlb_all();
+       
+       vcpu->domain->arch.last_vcpu[cpu].vcpu_id = vcpu->vcpu_id;
+       vcpu->arch.last_processor = cpu;
+
+       if ((last_vcpu_id != vcpu->vcpu_id &&
+            last_vcpu_id != INVALID_VCPU_ID) ||
+           (last_vcpu_id == vcpu->vcpu_id &&
+            last_processor != cpu &&
+            last_processor != INVALID_PROCESSOR)) {
+
+               // if the vTLB implementation was changed,
+               // the followings must be updated either.
+               if (VMX_DOMAIN(vcpu)) {
+                       // currently vTLB for vt-i domian is per vcpu.
+                       // so any flushing isn't needed.
+               } else {
+                       vhpt_flush();
+               }
+               local_flush_tlb_all();
+       }
 }
 
 void schedule_tail(struct vcpu *prev)
@@ -298,6 +305,7 @@ struct vcpu *alloc_vcpu_struct(struct do
            v->arch.starting_rid = d->arch.starting_rid;
            v->arch.ending_rid = d->arch.ending_rid;
            v->arch.breakimm = d->arch.breakimm;
+           v->arch.last_processor = INVALID_PROCESSOR;
        }
 
        return v;
diff -r f7132169c2bf -r a55e5195e5f7 xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Mon Jul 03 09:11:49 2006 -0600
+++ b/xen/include/asm-ia64/domain.h     Tue Jul 04 15:17:26 2006 +0900
@@ -156,6 +156,9 @@ struct arch_vcpu {
     int mode_flags;
     fpswa_ret_t fpswa_ret;     /* save return values of FPSWA emulation */
     struct arch_vmx_struct arch_vmx; /* Virtual Machine Extensions */
+
+#define INVALID_PROCESSOR       INT_MAX
+    int last_processor;
 };
 
 #include <asm/uaccess.h> /* for KERNEL_DS */
_______________________________________________
Xen-ia64-devel mailing list
[email protected]
http://lists.xensource.com/xen-ia64-devel

Reply via email to