[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Batch cr3 and ldt switches into a single mmuext_op hypercall. This will



ChangeSet 1.1423, 2005/04/01 15:41:16+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Batch cr3 and ldt switches into a single mmuext_op hypercall. This will
        also avoid one unnecessary TLB flush per context switch.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h          |   14 +++++--
 linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h |   19 
+++++++---
 2 files changed, 26 insertions(+), 7 deletions(-)


diff -Nru a/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h 
b/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h
--- a/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h     2005-04-01 
10:03:19 -05:00
+++ b/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h     2005-04-01 
10:03:19 -05:00
@@ -31,17 +31,25 @@
 
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
struct task_struct *tsk, unsigned cpu)
 {
+       struct mmuext_op _op[2], *op = _op;
        if (prev != next) {
                /* stop flush ipis for the previous mm */
                clear_bit(cpu, &prev->cpu_vm_mask);
                /* Re-load page tables */
                cur_pgd = next->pgd;
-               xen_pt_switch(__pa(cur_pgd));
+               op->cmd = MMUEXT_NEW_BASEPTR;
+               op->mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
+               op++;
                /* load_LDT, if either the previous or next thread
                 * has a non-default LDT.
                 */
-               if (next->context.size+prev->context.size)
-                       load_LDT(&next->context);
+               if (next->context.size+prev->context.size) {
+                       op->cmd = MMUEXT_SET_LDT;
+                       op->linear_addr = (unsigned long)next->context.ldt;
+                       op->nr_ents     = next->context.size;
+                       op++;
+               }
+               BUG_ON(HYPERVISOR_mmuext_op(_op, op-_op, NULL, DOMID_SELF));
        }
 }
 
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h    
2005-04-01 10:03:19 -05:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h    
2005-04-01 10:03:19 -05:00
@@ -46,6 +46,7 @@
                             struct task_struct *tsk)
 {
        int cpu = smp_processor_id();
+       struct mmuext_op _op[2], *op = _op;
 
        if (likely(prev != next)) {
                /* stop flush ipis for the previous mm */
@@ -56,14 +57,24 @@
 #endif
                cpu_set(cpu, next->cpu_vm_mask);
 
-               /* Re-load page tables */
-               load_cr3(next->pgd);
+               /* Re-load page tables: load_cr3(next->pgd) */
+               per_cpu(cur_pgd, cpu) = next->pgd;
+               op->cmd = MMUEXT_NEW_BASEPTR;
+               op->mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
+               op++;
 
                /*
                 * load the LDT, if the LDT is different:
                 */
-               if (unlikely(prev->context.ldt != next->context.ldt))
-                       load_LDT_nolock(&next->context, cpu);
+               if (unlikely(prev->context.ldt != next->context.ldt)) {
+                       /* load_LDT_nolock(&next->context, cpu) */
+                       op->cmd = MMUEXT_SET_LDT;
+                       op->linear_addr = (unsigned long)next->context.ldt;
+                       op->nr_ents     = next->context.size;
+                       op++;
+               }
+
+               BUG_ON(HYPERVISOR_mmuext_op(_op, op-_op, NULL, DOMID_SELF));
        }
 #if 0 /* XEN */
        else {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.