ia64/xen-unstable
changeset 1373:b38d20334c58
bitkeeper revision 1.891.1.13 (40a24fd6V2eF76NjMSt5mccf1Jh1qQ)
Lazy page-table switching.
Lazy page-table switching.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Wed May 12 16:24:54 2004 +0000 (2004-05-12) |
parents | 5a6113c65ead |
children | 3018764ad110 |
files | xen/arch/i386/process.c xen/common/domain.c xen/common/memory.c |
line diff
1.1 --- a/xen/arch/i386/process.c Wed May 12 15:54:24 2004 +0000 1.2 +++ b/xen/arch/i386/process.c Wed May 12 16:24:54 2004 +0000 1.3 @@ -270,7 +270,7 @@ void switch_to(struct task_struct *prev_ 1.4 tss->ss1 = next->guestos_ss; 1.5 1.6 /* Maybe switch the debug registers. */ 1.7 - if ( next->debugreg[7] ) 1.8 + if ( unlikely(next->debugreg[7]) ) 1.9 { 1.10 loaddebug(next, 0); 1.11 loaddebug(next, 1); 1.12 @@ -280,10 +280,17 @@ void switch_to(struct task_struct *prev_ 1.13 loaddebug(next, 6); 1.14 loaddebug(next, 7); 1.15 } 1.16 + 1.17 + /* Switch page tables. */ 1.18 + write_ptbase(&next_p->mm); 1.19 + tlb_clocktick(); 1.20 } 1.21 1.22 - if ( ( prev_p->io_bitmap != NULL ) || ( next_p->io_bitmap != NULL ) ) { 1.23 - if ( next_p->io_bitmap != NULL ) { 1.24 + if ( unlikely(prev_p->io_bitmap != NULL) || 1.25 + unlikely(next_p->io_bitmap != NULL) ) 1.26 + { 1.27 + if ( next_p->io_bitmap != NULL ) 1.28 + { 1.29 /* Copy in the appropriate parts of the IO bitmap. We use the 1.30 * selector to copy only the interesting parts of the bitmap. */ 1.31 1.32 @@ -314,7 +321,9 @@ void switch_to(struct task_struct *prev_ 1.33 1.34 tss->bitmap = IO_BITMAP_OFFSET; 1.35 1.36 - } else { 1.37 + } 1.38 + else 1.39 + { 1.40 /* In this case, we're switching FROM a task with IO port access, 1.41 * to a task that doesn't use the IO bitmap. We set any TSS bits 1.42 * that might have been cleared, ready for future use. */ 1.43 @@ -332,11 +341,6 @@ void switch_to(struct task_struct *prev_ 1.44 tss->bitmap = INVALID_IO_BITMAP_OFFSET; 1.45 } 1.46 } 1.47 - 1.48 - 1.49 - /* Switch page tables. */ 1.50 - write_ptbase(&next_p->mm); 1.51 - tlb_clocktick(); 1.52 1.53 set_current(next_p); 1.54
2.1 --- a/xen/common/domain.c Wed May 12 15:54:24 2004 +0000 2.2 +++ b/xen/common/domain.c Wed May 12 16:24:54 2004 +0000 2.3 @@ -214,10 +214,6 @@ void __kill_domain(struct task_struct *p 2.4 *pp = p->next_hash; 2.5 write_unlock_irqrestore(&tasklist_lock, flags); 2.6 2.7 - if ( atomic_read(&p->refcnt) >2 ) 2.8 - DPRINTK("Domain refcnt>1 so kil deferred. Missing put_task? p=%p cur=%p cnt=%d\n",p,current,atomic_read(&p->refcnt)); 2.9 - 2.10 - 2.11 if ( p == current ) 2.12 { 2.13 __enter_scheduler(); 2.14 @@ -412,7 +408,16 @@ void free_all_dom_mem(struct task_struct 2.15 2.16 INIT_LIST_HEAD(&zombies); 2.17 2.18 - if ( p->mm.shadow_mode ) shadow_mode_disable(p); 2.19 + /* 2.20 + * If we're executing the idle task then we may still be running over the 2.21 + * dead domain's page tables. We'd better fix that before freeing them! 2.22 + */ 2.23 + if ( is_idle_task(current) ) 2.24 + write_ptbase(¤t->mm); 2.25 + 2.26 + /* Exit shadow mode before deconstructing final guest page table. */ 2.27 + if ( p->mm.shadow_mode ) 2.28 + shadow_mode_disable(p); 2.29 2.30 /* STEP 1. Drop the in-use reference to the page-table base. */ 2.31 put_page_and_type(&frame_table[pagetable_val(p->mm.pagetable) >> 2.32 @@ -1066,7 +1071,7 @@ int construct_dom0(struct task_struct *p 2.33 2.34 set_bit(PF_CONSTRUCTED, &p->flags); 2.35 2.36 -#if 0 // XXXXX DO NOT CHECK IN ENABLED !!! (but useful for testing so leave) 2.37 +#if 0 /* XXXXX DO NOT CHECK IN ENABLED !!! (but useful for testing so leave) */ 2.38 shadow_mode_enable(&p->mm, SHM_test); 2.39 #endif 2.40
3.1 --- a/xen/common/memory.c Wed May 12 15:54:24 2004 +0000 3.2 +++ b/xen/common/memory.c Wed May 12 16:24:54 2004 +0000 3.3 @@ -194,7 +194,6 @@ static struct { 3.4 */ 3.5 void __init init_frametable(unsigned long nr_pages) 3.6 { 3.7 - int i; 3.8 unsigned long mfn; 3.9 3.10 memset(percpu_info, 0, sizeof(percpu_info)); 3.11 @@ -209,15 +208,13 @@ void __init init_frametable(unsigned lon 3.12 INIT_LIST_HEAD(&free_list); 3.13 free_pfns = 0; 3.14 3.15 - /* so that we can map them latter, set the ownership of pages 3.16 - belonging to the machine_to_phys_mapping to CPU0 idle task */ 3.17 - 3.18 - mfn = virt_to_phys((void *)RDWR_MPT_VIRT_START)>>PAGE_SHIFT; 3.19 -// for(i=0;i<nr_pages;i+=1024,mfn++) 3.20 - for(i=0;i<1024*1024;i+=1024,mfn++) 3.21 + /* Pin the ownership of the MP table so that DOM0 can map it later. */ 3.22 + for ( mfn = virt_to_phys((void *)RDWR_MPT_VIRT_START)>>PAGE_SHIFT; 3.23 + mfn < virt_to_phys((void *)RDWR_MPT_VIRT_END)>>PAGE_SHIFT; 3.24 + mfn++ ) 3.25 { 3.26 frame_table[mfn].count_and_flags = 1 | PGC_allocated; 3.27 - frame_table[mfn].type_and_flags = 1 | PGT_gdt_page; // anything non RW 3.28 + frame_table[mfn].type_and_flags = 1 | PGT_gdt_page; /* non-RW type */ 3.29 frame_table[mfn].u.domain = &idle0_task; 3.30 } 3.31 }