ia64/xen-unstable

changeset 13398:648e58e31c26

linux/i386: allow CONFIG_HIGHPTE on i386

While, as discussed, the performance impact of this option is
certainly higher than on native Linux, the option should not be
entirely disallowed if people want to sacrifice performance for less
lowmem pressure.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Fri Jan 12 10:28:54 2007 +0000 (2007-01-12)
parents 7c5c72a0283f
children f328425d553e
files linux-2.6-xen-sparse/arch/i386/Kconfig linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgalloc.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/Kconfig	Fri Jan 12 10:22:36 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/Kconfig	Fri Jan 12 10:28:54 2007 +0000
     1.3 @@ -594,7 +594,7 @@ config HAVE_ARCH_EARLY_PFN_TO_NID
     1.4  
     1.5  config HIGHPTE
     1.6  	bool "Allocate 3rd-level pagetables from highmem"
     1.7 -	depends on (HIGHMEM4G || HIGHMEM64G) && !X86_XEN
     1.8 +	depends on HIGHMEM4G || HIGHMEM64G
     1.9  	help
    1.10  	  The VM uses one page table entry for each page of physical memory.
    1.11  	  For systems with a lot of RAM, this can be wasteful of precious
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c	Fri Jan 12 10:22:36 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c	Fri Jan 12 10:28:54 2007 +0000
     2.3 @@ -129,5 +129,6 @@ struct page *kmap_atomic_to_page(void *p
     2.4  EXPORT_SYMBOL(kmap);
     2.5  EXPORT_SYMBOL(kunmap);
     2.6  EXPORT_SYMBOL(kmap_atomic);
     2.7 +EXPORT_SYMBOL(kmap_atomic_pte);
     2.8  EXPORT_SYMBOL(kunmap_atomic);
     2.9  EXPORT_SYMBOL(kmap_atomic_to_page);
     3.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Fri Jan 12 10:22:36 2007 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Fri Jan 12 10:28:54 2007 +0000
     3.3 @@ -238,23 +238,41 @@ struct page *pte_alloc_one(struct mm_str
     3.4  
     3.5  #ifdef CONFIG_HIGHPTE
     3.6  	pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT|__GFP_ZERO, 0);
     3.7 +	if (pte && PageHighMem(pte)) {
     3.8 +		struct mmuext_op op;
     3.9 +
    3.10 +		kmap_flush_unused();
    3.11 +		op.cmd = MMUEXT_PIN_L1_TABLE;
    3.12 +		op.arg1.mfn = pfn_to_mfn(page_to_pfn(pte));
    3.13 +		BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
    3.14 +	}
    3.15  #else
    3.16  	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
    3.17 +#endif
    3.18  	if (pte) {
    3.19  		SetPageForeign(pte, pte_free);
    3.20  		set_page_count(pte, 1);
    3.21  	}
    3.22 -#endif
    3.23  	return pte;
    3.24  }
    3.25  
    3.26  void pte_free(struct page *pte)
    3.27  {
    3.28 -	unsigned long va = (unsigned long)__va(page_to_pfn(pte)<<PAGE_SHIFT);
    3.29 +	unsigned long pfn = page_to_pfn(pte);
    3.30 +
    3.31 +	if (!PageHighMem(pte)) {
    3.32 +		unsigned long va = (unsigned long)__va(pfn << PAGE_SHIFT);
    3.33  
    3.34 -	if (!pte_write(*virt_to_ptep(va)))
    3.35 -		BUG_ON(HYPERVISOR_update_va_mapping(
    3.36 -			va, pfn_pte(page_to_pfn(pte), PAGE_KERNEL), 0));
    3.37 +		if (!pte_write(*virt_to_ptep(va)))
    3.38 +			BUG_ON(HYPERVISOR_update_va_mapping(
    3.39 +			       va, pfn_pte(pfn, PAGE_KERNEL), 0));
    3.40 +	} else {
    3.41 +		struct mmuext_op op;
    3.42 +
    3.43 +		op.cmd = MMUEXT_UNPIN_TABLE;
    3.44 +		op.arg1.mfn = pfn_to_mfn(pfn);
    3.45 +		BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
    3.46 +	}
    3.47  
    3.48  	ClearPageForeign(pte);
    3.49  	set_page_count(pte, 1);
     4.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgalloc.h	Fri Jan 12 10:22:36 2007 +0000
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgalloc.h	Fri Jan 12 10:28:54 2007 +0000
     4.3 @@ -42,7 +42,7 @@ extern struct page *pte_alloc_one(struct
     4.4  static inline void pte_free_kernel(pte_t *pte)
     4.5  {
     4.6  	free_page((unsigned long)pte);
     4.7 -	make_page_writable(pte, XENFEAT_writable_page_tables);
     4.8 +	make_lowmem_page_writable(pte, XENFEAT_writable_page_tables);
     4.9  }
    4.10  
    4.11  extern void pte_free(struct page *pte);