ia64/xen-unstable
changeset 2506:37953cf6f0dd
bitkeeper revision 1.1159.79.9 (41502711eWB9F0WFdYcRG8bIE9B5Fw)
Ensure we flush the TLB when removing page mappings.
Ensure we flush the TLB when removing page mappings.
author | kaf24@freefall.cl.cam.ac.uk |
---|---|
date | Tue Sep 21 13:05:21 2004 +0000 (2004-09-21) |
parents | 27a319ede628 |
children | 359b48f3b4f8 |
files | linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/pci-dma.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/hypervisor.c |
line diff
1.1 --- a/linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c Tue Sep 21 09:46:52 2004 +0000 1.2 +++ b/linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c Tue Sep 21 13:05:21 2004 +0000 1.3 @@ -81,8 +81,8 @@ static unsigned long inflate_balloon(uns 1.4 1.5 for ( i = 0; i < num_pages; i++, currp++ ) 1.6 { 1.7 - struct page *page = alloc_page(GFP_HIGHUSER); 1.8 - unsigned long pfn = page - mem_map; 1.9 + struct page *page = alloc_page(GFP_HIGHUSER); 1.10 + unsigned long pfn = page - mem_map; 1.11 1.12 /* If allocation fails then free all reserved pages. */ 1.13 if ( page == NULL ) 1.14 @@ -92,7 +92,7 @@ static unsigned long inflate_balloon(uns 1.15 currp = parray; 1.16 for ( j = 0; j < i; j++, currp++ ) 1.17 __free_page((struct page *) (mem_map + *currp)); 1.18 - ret = -EFAULT; 1.19 + ret = -EFAULT; 1.20 goto cleanup; 1.21 } 1.22 1.23 @@ -102,10 +102,10 @@ static unsigned long inflate_balloon(uns 1.24 1.25 for ( i = 0, currp = parray; i < num_pages; i++, currp++ ) 1.26 { 1.27 - unsigned long mfn = phys_to_machine_mapping[*currp]; 1.28 + unsigned long mfn = phys_to_machine_mapping[*currp]; 1.29 curraddr = (unsigned long)page_address(mem_map + *currp); 1.30 /* Blow away page contents for security, and also p.t. ref if any. */ 1.31 - if ( curraddr != 0 ) 1.32 + if ( curraddr != 0 ) 1.33 { 1.34 scrub_pages(curraddr, 1); 1.35 queue_l1_entry_update(get_ptep(curraddr), 0); 1.36 @@ -122,7 +122,8 @@ static unsigned long inflate_balloon(uns 1.37 *currp = mfn; 1.38 } 1.39 1.40 - XEN_flush_page_update_queue(); 1.41 + /* Flush updates through and flush the TLB. */ 1.42 + xen_tlb_flush(); 1.43 1.44 ret = HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 1.45 parray, num_pages, 0); 1.46 @@ -168,7 +169,7 @@ static unsigned long process_returned_pa 1.47 { 1.48 phys_to_machine_mapping[i] = *curr; 1.49 queue_machphys_update(*curr, i); 1.50 - if (i<max_low_pfn) 1.51 + if (i<max_low_pfn) 1.52 queue_l1_entry_update( 1.53 get_ptep((unsigned long)__va(i << PAGE_SHIFT)), 1.54 ((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL)); 1.55 @@ -191,7 +192,7 @@ unsigned long deflate_balloon(unsigned l 1.56 if ( num_pages > credit ) 1.57 { 1.58 printk(KERN_ERR "deflate_balloon: %lu pages > %lu credit.\n", 1.59 - num_pages, credit); 1.60 + num_pages, credit); 1.61 return -EAGAIN; 1.62 } 1.63 1.64 @@ -202,21 +203,19 @@ unsigned long deflate_balloon(unsigned l 1.65 return 0; 1.66 } 1.67 1.68 - XEN_flush_page_update_queue(); 1.69 - 1.70 ret = HYPERVISOR_dom_mem_op(MEMOP_increase_reservation, 1.71 parray, num_pages, 0); 1.72 if ( unlikely(ret != num_pages) ) 1.73 { 1.74 printk(KERN_ERR "deflate_balloon: xen increase_reservation err %lx\n", 1.75 - ret); 1.76 + ret); 1.77 goto cleanup; 1.78 } 1.79 1.80 if ( (ret = process_returned_pages(parray, num_pages)) < num_pages ) 1.81 { 1.82 printk(KERN_WARNING 1.83 - "deflate_balloon: restored only %lx of %lx pages.\n", 1.84 + "deflate_balloon: restored only %lx of %lx pages.\n", 1.85 ret, num_pages); 1.86 goto cleanup; 1.87 } 1.88 @@ -323,7 +322,6 @@ claim_new_pages(unsigned long num_pages) 1.89 return 0; 1.90 } 1.91 1.92 - XEN_flush_page_update_queue(); 1.93 new_page_cnt = HYPERVISOR_dom_mem_op(MEMOP_increase_reservation, 1.94 parray, num_pages, 0); 1.95 if ( new_page_cnt != num_pages ) 1.96 @@ -332,48 +330,50 @@ claim_new_pages(unsigned long num_pages) 1.97 "claim_new_pages: xen granted only %lu of %lu requested pages\n", 1.98 new_page_cnt, num_pages); 1.99 1.100 - /* 1.101 - * Avoid xen lockup when user forgot to setdomainmaxmem. Xen 1.102 - * usually can dribble out a few pages and then hangs. 1.103 - */ 1.104 - if ( new_page_cnt < 1000 ) 1.105 + /* 1.106 + * Avoid xen lockup when user forgot to setdomainmaxmem. Xen 1.107 + * usually can dribble out a few pages and then hangs. 1.108 + */ 1.109 + if ( new_page_cnt < 1000 ) 1.110 { 1.111 printk(KERN_WARNING "Remember to use setdomainmaxmem\n"); 1.112 - HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 1.113 + HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 1.114 parray, new_page_cnt, 0); 1.115 return -EFAULT; 1.116 - } 1.117 + } 1.118 } 1.119 memcpy(phys_to_machine_mapping+most_seen_pages, parray, 1.120 new_page_cnt * sizeof(unsigned long)); 1.121 1.122 pagetable_extend(most_seen_pages,new_page_cnt); 1.123 1.124 - for (pfn = most_seen_pages, curr = parray; 1.125 - pfn < most_seen_pages+new_page_cnt; 1.126 - pfn++, curr++ ) 1.127 + for ( pfn = most_seen_pages, curr = parray; 1.128 + pfn < most_seen_pages+new_page_cnt; 1.129 + pfn++, curr++ ) 1.130 { 1.131 struct page *page = mem_map + pfn; 1.132 1.133 #ifndef CONFIG_HIGHMEM 1.134 - if (pfn>=max_low_pfn) { 1.135 + if ( pfn>=max_low_pfn ) 1.136 + { 1.137 printk(KERN_WARNING "Warning only %ldMB will be used.\n", 1.138 pfn>>PAGE_TO_MB_SHIFT); 1.139 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n"); 1.140 - break; 1.141 - } 1.142 + break; 1.143 + } 1.144 #endif 1.145 - queue_machphys_update(*curr, pfn); 1.146 - XEN_flush_page_update_queue(); 1.147 - if (pfn<max_low_pfn) { 1.148 - queue_l1_entry_update(get_ptep((unsigned long)__va(pfn << PAGE_SHIFT)), 1.149 - ((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL)); 1.150 - XEN_flush_page_update_queue(); 1.151 - } 1.152 - 1.153 + queue_machphys_update(*curr, pfn); 1.154 + if ( pfn < max_low_pfn ) 1.155 + queue_l1_entry_update( 1.156 + get_ptep((unsigned long)__va(pfn << PAGE_SHIFT)), 1.157 + ((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL)); 1.158 + 1.159 + XEN_flush_page_update_queue(); 1.160 + 1.161 /* this next bit mimics arch/xen/mm/init.c:one_highpage_init() */ 1.162 ClearPageReserved(page); 1.163 - if (pfn>=max_low_pfn) set_bit(PG_highmem, &page->flags); 1.164 + if ( pfn >= max_low_pfn ) 1.165 + set_bit(PG_highmem, &page->flags); 1.166 set_page_count(page, 1); 1.167 __free_page(page); 1.168 } 1.169 @@ -395,9 +395,8 @@ static int balloon_write(struct file *fi 1.170 if ( !capable(CAP_SYS_ADMIN) ) 1.171 return -EPERM; 1.172 1.173 - if (count>sizeof memstring) { 1.174 + if ( count > sizeof(memstring) ) 1.175 return -EFBIG; 1.176 - } 1.177 1.178 len = strnlen_user(buffer, count); 1.179 if ( len == 0 ) return -EBADMSG; 1.180 @@ -406,39 +405,47 @@ static int balloon_write(struct file *fi 1.181 return -EFAULT; 1.182 1.183 endchar = memstring; 1.184 - for(i=0; i<len; ++i,++endchar) { 1.185 - if ('0'>memstring[i] || memstring[i]>'9') break; 1.186 - } 1.187 - if (i==0) return -EBADMSG; 1.188 + for ( i = 0; i < len; ++i, ++endchar ) 1.189 + if ( (memstring[i] < '0') || (memstring[i] > '9') ) 1.190 + break; 1.191 + if ( i == 0 ) 1.192 + return -EBADMSG; 1.193 1.194 targetbytes = memparse(memstring,&endchar); 1.195 target = targetbytes >> PAGE_SHIFT; 1.196 1.197 - if (target < current_pages) { 1.198 + if ( target < current_pages ) 1.199 + { 1.200 int change = inflate_balloon(current_pages-target); 1.201 - if (change<=0) return change; 1.202 + if ( change <= 0 ) 1.203 + return change; 1.204 1.205 current_pages -= change; 1.206 printk(KERN_INFO "Relinquish %dMB to xen. Domain now has %luMB\n", 1.207 change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT); 1.208 } 1.209 - else if (target > current_pages) { 1.210 + else if ( target > current_pages ) 1.211 + { 1.212 int change, reclaim = min(target,most_seen_pages) - current_pages; 1.213 1.214 - if (reclaim) { 1.215 + if ( reclaim ) 1.216 + { 1.217 change = deflate_balloon( reclaim); 1.218 - if (change<=0) return change; 1.219 + if ( change <= 0 ) 1.220 + return change; 1.221 current_pages += change; 1.222 printk(KERN_INFO "Reclaim %dMB from xen. Domain now has %luMB\n", 1.223 change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT); 1.224 } 1.225 1.226 - if (most_seen_pages<target) { 1.227 + if ( most_seen_pages < target ) 1.228 + { 1.229 int growth = claim_new_pages(target-most_seen_pages); 1.230 - if (growth<=0) return growth; 1.231 + if ( growth <= 0 ) 1.232 + return growth; 1.233 most_seen_pages += growth; 1.234 current_pages += growth; 1.235 - printk(KERN_INFO "Granted %dMB new mem by xen. Domain now has %luMB\n", 1.236 + printk(KERN_INFO "Granted %dMB new mem. Dom now has %luMB\n", 1.237 growth>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT); 1.238 } 1.239 }
2.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Sep 21 09:46:52 2004 +0000 2.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Sep 21 13:05:21 2004 +0000 2.3 @@ -84,7 +84,8 @@ void *dma_alloc_coherent(struct device * 2.4 phys_to_machine_mapping[(__pa(ret)>>PAGE_SHIFT)+i] = 2.5 pfn+i; 2.6 } 2.7 - flush_page_update_queue(); 2.8 + /* Flush updates through and flush the TLB. */ 2.9 + xen_tlb_flush(); 2.10 } 2.11 2.12 memset(ret, 0, size);
3.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Sep 21 09:46:52 2004 +0000 3.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Sep 21 13:05:21 2004 +0000 3.3 @@ -430,7 +430,8 @@ unsigned long allocate_empty_lowmem_regi 3.4 phys_to_machine_mapping[__pa(vstart)>>PAGE_SHIFT] = INVALID_P2M_ENTRY; 3.5 } 3.6 3.7 - flush_page_update_queue(); 3.8 + /* Flush updates through and flush the TLB. */ 3.9 + xen_tlb_flush(); 3.10 3.11 ret = HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 3.12 pfn_array, 1<<order, 0);