Transparent Hugepage Support #15
Subsystems (12)
PATCH 1/1 Transparent Hugepage Support #15
Hello,
this fixes a potential issue with regard to simultaneous 4k and 2M TLB entries in split_huge_page (at pratically zero cost, so I didn't need to add a fake feature flag and it's a lot safer to do it this way just in case). split_large_page in change_page_attr has the same issue too, but I've no idea how to fix it there because the pmd cannot be marked non present at any given time as change_page_attr may be running on ram below 640k and that is the same pmd where the kernel .text resides. However I doubt it'll ever be a practical problem. Other cpus also has a lot of warnings and risks in allowing simultaneous TLB entries of different size.
Johannes also sent a cute optimization to split split_huge_page_vma/mm he converted those in a single split_huge_page_pmd and in addition he also sent native support for hugepages in both mincore and mprotect. Which shows how deep he already understands the whole huge_memory.c and its usage in the callers. Seeing significant contributions like this I think further confirms this is the way to go. Thanks a lot Johannes.
The ability to bisect before the mincore and mprotect native implementations is one of the huge benefits of this approach. The hardest of all will be to add swap native support to 2M pages later (as it involves to make the swapcache 2M capable and that in turn means it expodes all over the pagecache code) but I think first we've other priorities:
1) merge memory compaction
2)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 fix bad_page to show the real reason the page is bad
From: Andrea Arcangeli <[email protected]>
page_count shows the count of the head page, but the actual check is done on the tail page, so show what is really being checked.
---
mm/page_alloc.c +1 -1
@@ -5291,7 +5291,7 @@ void dump_page(struct page *page) {printk (KERN_ALERT "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n" , - page,page_count (page),page_mapcount (page), + page,atomic_read (&page->_count),page_mapcount (page), page->mapping, page->index);dump_page_flags (page->flags); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 config_transparent_hugepage
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Add config option.
---
mm/Kconfig +14 -0
@@ -287,3 +287,17 @@ config NOMMU_INITIAL_TRIM_EXCESS of 1 says that all excess pages should be trimmed. See Documentation/nommu-mmap.txt for more information. + +config TRANSPARENT_HUGEPAGE + bool "Transparent Hugepage support" if EMBEDDED + depends on X86_64 + default y + help + Transparent Hugepages allows the kernel to use huge pages and + huge tlb transparently to the applications whenever possible. + This feature can improve computing performance to certain + applications by speeding up page faults during memory + allocation, by reducing the number of tlb misses and by speeding + up the pagetable walking. + + If memory constrained on embedded, you may want to say N.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 update futex compound knowledge
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Futex code is smarter than most other gup_fast O_DIRECT code and knows about the compound internals. However now doing a put_page(head_page) will not release the pin on the tail page taken by gup-fast, leading to all sort of refcounting bugchecks. Getting a stable head_page is a little tricky.
page_head = page is there because if this is not a tail page it's also the page_head. Only in case this is a tail page, compound_head is called, otherwise it's guaranteed unnecessary. And if it's a tail page compound_head has to run atomically inside irq disabled section __get_user_pages_fast before returning. Otherwise ->first_page won't be a stable pointer.
Disableing irq before __get_user_page_fast and releasing irq after running compound_head is needed because if __get_user_page_fast returns == 1, it means the huge pmd is established and cannot go away from under us. pmdp_splitting_flush_notify in __split_huge_page_splitting will have to wait for local_irq_enable before the IPI delivery can return. This means __split_huge_page_refcount can't be running from under us, and in turn when we run compound_head(page) we're not reading a dangling pointer from tailpage->first_page. Then after we get to stable head page, we are always safe to call compound_lock and after taking the compound lock on head page we can finally re-check if the page returned by gup-fast is still a tail page. in which case we're set and we didn't need to split the hugepage in order to take a futex on it.
---
kernel/futex.c +58 -9
@@ -218,7 +218,7 @@ get_futex_key(u32 __user *uaddr, int fsh {unsigned long address = (unsigned long )uaddr;struct mm_struct *mm = current->mm; -struct page *page; +struct page *page, *page_head;int err;/*
@@ -250,10 +250,53 @@ again:if (err <0 )return err; - page =compound_head (page); -lock_page (page); -if (!page->mapping) { -unlock_page (page); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + page_head = page; +if (unlikely (PageTail (page))) { +put_page (page); +/* serialize against __split_huge_page_splitting() */ +local_irq_disable (); +if (likely (__get_user_pages_fast (address,1 ,1 , &page) ==1 )) { + page_head =compound_head (page); +/* +* page_head is valid pointer but we must pin +* it before taking the PG_lock and/or +* PG_compound_lock. The moment we re-enable +* irqs __split_huge_page_splitting() can +* return and the head page can be freed from +* under us. We can't take the PG_lock and/or +* PG_compound_lock on a page that could be +* freed from under us. +*/ +if (page != page_head) +get_page (page_head); +local_irq_enable (); + }else { +local_irq_enable (); + goto again; + } + } +#else + page_head =compound_head (page); +if (page != page_head) +get_page (page_head); +#endif + +lock_page (page_head); +if (unlikely (page_head != page)) { +compound_lock (page_head); +if (unlikely (!PageTail (page))) { +compound_unlock (page_head); +unlock_page (page_head); +put_page (page_head); +put_page (page); + goto again; + } + } +if (!page_head->mapping) { +unlock_page (page_head); +if (page_head != page) +put_page (page_head);put_page (page); goto again; }
@@ -265,19 +308,25 @@ again:* it's a read-only handle, it's expected that futexes attach to * the object not the particular process. */ -if (PageAnon (page)) { +if (PageAnon (page_head)) { key->both.offset |=FUT_OFF_MMSHARED ;/* ref taken on mm */ key->private.mm = mm; key->private.address = address; }else { key->both.offset |=FUT_OFF_INODE ;/* inode-based key */ - key->shared.inode = page->mapping->host; - key->shared.pgoff = page->index; + key->shared.inode = page_head->mapping->host; + key->shared.pgoff = page_head->index; }get_futex_key_refs (key); -unlock_page (page); +unlock_page (page_head); +if (page != page_head) { +VM_BUG_ON (!PageTail (page)); +/* releasing compound_lock after page_lock won't matter */ +compound_unlock (page_head); +put_page (page_head); + }put_page (page);return 0 ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 alter compound get_page/put_page
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Alter compound get_page/put_page to keep references on subpages too, in order to allow __split_huge_page_refcount to split an hugepage even while subpages have been pinned by one of the get_user_pages() variants.
---
arch/powerpc/mm/gup.c +12 -0
@@ -16,6 +16,16 @@#ifdef __HAVE_ARCH_PTE_SPECIAL +static inline void pin_huge_page_tail (struct page *page) +{ +/* +* __split_huge_page_refcount() cannot run +* from under us. +*/ +VM_BUG_ON (atomic_read (&page->_count) <0 ); +atomic_inc (&page->_count); +} +/* * The performance critical leaf functions are made noinline otherwise gcc * inlines everything into a single function which results in too much
@@ -47,6 +57,8 @@ static noinline int gup_pte_range(pmd_tput_page (page);return 0 ; } +if (PageTail (page)) +pin_huge_page_tail (page); pages[*nr] = page; (*nr)++;
arch/x86/mm/gup.c +12 -0
@@ -105,6 +105,16 @@ static inline void get_head_page_multiplatomic_add (nr, &page->_count); } +static inline void pin_huge_page_tail (struct page *page) +{ +/* +* __split_huge_page_refcount() cannot run +* from under us. +*/ +VM_BUG_ON (atomic_read (&page->_count) <0 ); +atomic_inc (&page->_count); +} + static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,unsigned long end,int write,struct page **pages,int *nr) {
@@ -128,6 +138,8 @@ static noinline int gup_huge_pmd(pmd_t p do { VM_BUG_ON(compound_head(page) != head); pages[*nr] = page; + if (PageTail(page)) + pin_huge_page_tail(page); (*nr)++; page++; refs++;
include/linux/mm.h +10 -2
@@ -326,9 +326,17 @@ static inline int page_count(struct pagestatic inline void get_page (struct page *page) { - page =compound_head (page); -VM_BUG_ON (atomic_read (&page->_count) ==0 ); +VM_BUG_ON (atomic_read (&page->_count) < !PageTail (page));atomic_inc (&page->_count); +if (unlikely (PageTail (page))) { +/* +* This is safe only because +* __split_huge_page_refcount can't run under +* get_page(). +*/ +VM_BUG_ON (atomic_read (&page->first_page->_count) <=0 ); +atomic_inc (&page->first_page->_count); + } }static inline struct page *virt_to_head_page (const void *x)
mm/swap.c +72 -7
96 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 add pmd paravirt ops
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Paravirt ops pmd_update/pmd_update_defer/pmd_set_at. Not all might be necessary (vmware needs pmd_update, Xen needs set_pmd_at, nobody needs pmd_update_defer), but this is to keep full simmetry with pte paravirt ops, which looks cleaner and simpler from a common code POV.
---
arch/x86/include/asm/paravirt.h +23 -0
@@ -440,6 +440,11 @@ static inline void pte_update(struct mm_ {PVOP_VCALL3 (pv_mmu_ops.pte_update, mm, addr, ptep); } +static inline void pmd_update (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp) +{ +PVOP_VCALL3 (pv_mmu_ops.pmd_update, mm, addr, pmdp); +}static inline void pte_update_defer (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
@@ -447,6 +452,12 @@ static inline void pte_update_defer(struPVOP_VCALL3 (pv_mmu_ops.pte_update_defer, mm, addr, ptep); } +static inline void pmd_update_defer (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp) +{ +PVOP_VCALL3 (pv_mmu_ops.pmd_update_defer, mm, addr, pmdp); +} +static inline pte_t __pte (pteval_t val) {pteval_t ret;
@@ -548,6 +559,18 @@ static inline void set_pte_at(struct mm_PVOP_VCALL4 (pv_mmu_ops.set_pte_at, mm, addr, ptep, pte.pte); } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline void set_pmd_at (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,pmd_t pmd) +{ +if (sizeof (pmdval_t) >sizeof (long )) +/* 5 arg words */ + pv_mmu_ops.set_pmd_at (mm, addr, pmdp, pmd); +else +PVOP_VCALL4 (pv_mmu_ops.set_pmd_at, mm, addr, pmdp, pmd.pmd); +} +#endif +static inline void set_pmd (pmd_t *pmdp,pmd_t pmd) {pmdval_t val =native_pmd_val (pmd);
arch/x86/include/asm/paravirt_types.h +6 -0
@@ -266,10 +266,16 @@ struct pv_mmu_ops {void (*set_pte_at)(struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pteval);void (*set_pmd)(pmd_t *pmdp,pmd_t pmdval); +void (*set_pmd_at)(struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,pmd_t pmdval);void (*pte_update)(struct mm_struct *mm,unsigned long addr,pte_t *ptep);void (*pte_update_defer)(struct mm_struct *mm,unsigned long addr,pte_t *ptep); +void (*pmd_update)(struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp); +void (*pmd_update_defer)(struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp);pte_t (*ptep_modify_prot_start)(struct mm_struct *mm,unsigned long addr,pte_t *ptep);
arch/x86/kernel/paravirt.c +3 -0
@@ -422,8 +422,11 @@ struct pv_mmu_ops pv_mmu_ops = { .set_pte = native_set_pte, .set_pte_at = native_set_pte_at, .set_pmd = native_set_pmd, + .set_pmd_at = native_set_pmd_at, .pte_update = paravirt_nop, .pte_update_defer = paravirt_nop, + .pmd_update = paravirt_nop, + .pmd_update_defer = paravirt_nop, .ptep_modify_prot_start = __ptep_modify_prot_start, .ptep_modify_prot_commit = __ptep_modify_prot_commit,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 add native_set_pmd_at
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Used by paravirt and not paravirt set_pmd_at.
---
arch/x86/include/asm/pgtable.h +6 -0
@@ -528,6 +528,12 @@ static inline void native_set_pte_at(strnative_set_pte (ptep, pte); } +static inline void native_set_pmd_at (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp ,pmd_t pmd) +{ +native_set_pmd (pmdp, pmd); +} +#ifndef CONFIG_PARAVIRT /* * Rules for using pte_update - it must be called after any PTE update which
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 comment reminder in destroy_compound_page
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Warn destroy_compound_page that __split_huge_page_refcount is heavily dependent on its internal behavior.
---
mm/page_alloc.c +1 -0
@@ -334,6 +334,7 @@ void prep_compound_page(struct page *pag } } +/* update __split_huge_page_refcount if you change this function */ static int destroy_compound_page (struct page *page,unsigned long order) {int i;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 compound_lock
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Add a new compound_lock() needed to serialize put_page against __split_huge_page_refcount().
---
include/linux/mm.h +15 -0
@@ -13,6 +13,7 @@#include <linux/debug_locks.h> #include <linux/mm_types.h> #include <linux/range.h> +#include <linux/bit_spinlock.h> struct mempolicy ;struct anon_vma ;
@@ -297,6 +298,20 @@ static inline int is_vmalloc_or_module_a }#endif +static inline void compound_lock (struct page *page) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +bit_spin_lock (PG_compound_lock, &page->flags); +#endif +} + +static inline void compound_unlock (struct page *page) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +bit_spin_unlock (PG_compound_lock, &page->flags); +#endif +} +static inline struct page *compound_head (struct page *page) {if (unlikely (PageTail (page)))
include/linux/page-flags.h +11 -1
@@ -108,6 +108,9 @@ enum pageflags {#ifdef CONFIG_MEMORY_FAILURE PG_hwpoison, /* hardware poisoned page. Don't touch */#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + PG_compound_lock, +#endif __NR_PAGEFLAGS,/* Filesystems */
@@ -399,6 +402,12 @@ static inline void __ClearPageTail(struc#define __PG_MLOCKED 0#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define __PG_COMPOUND_LOCK (1 << PG_compound_lock) +#else +#define __PG_COMPOUND_LOCK 0 +#endif +/* * Flags checked when a page is freed. Pages being freed should not have * these flags set. It they are, there is a problem.
@@ -408,7 +417,8 @@ static inline void __ClearPageTail(struc1 << PG_private |1 << PG_private_2 | \1 << PG_buddy |1 << PG_writeback |1 << PG_reserved | \1 << PG_slab |1 << PG_swapcache |1 << PG_active | \ - 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON) +1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON | \ + __PG_COMPOUND_LOCK)/* * Flags checked when a page is prepped for return by the page allocator.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 clear compound mapping
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Clear compound mapping for anonymous compound pages like it already happens for regular anonymous pages.
---
mm/page_alloc.c +2 -0
@@ -629,6 +629,8 @@ static void __free_pages_ok(struct pagetrace_mm_page_free_direct (page, order);kmemcheck_free_shadow (page, order); +if (PageAnon (page)) + page->mapping =NULL ;for (i =0 ; i < (1 << order) ; ++i) bad +=free_pages_check (page + i);if (bad)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 export maybe_mkwrite
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
huge_memory.c needs it too when it fallbacks in copying hugepages into regular fragmented pages if hugepage allocation fails during COW.
---
include/linux/mm.h +13 -0
@@ -390,6 +390,19 @@ static inline void set_compound_order(st }/* +* Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when +* servicing faults for write access. In the normal case, do always want +* pte_mkwrite. But get_user_pages can cause write faults for mappings +* that do not have writing enabled, when used by access_process_vm. +*/ +static inline pte_t maybe_mkwrite (pte_t pte,struct vm_area_struct *vma) +{ +if (likely (vma->vm_flags &VM_WRITE )) + pte =pte_mkwrite (pte); +return pte; +} + +/* * Multiple processes may "see" the same page. E.g. for untouched * mappings of /dev/null, all processes see the same page full of * zeroes, and text pages of executables and shared libraries have
mm/memory.c +0 -13
@@ -2031,19 +2031,6 @@ static inline int pte_unmap_same(structreturn same; } -/* -* Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when -* servicing faults for write access. In the normal case, do always want -* pte_mkwrite. But get_user_pages can cause write faults for mappings -* that do not have writing enabled, when used by access_process_vm. -*/ -static inline pte_t maybe_mkwrite (pte_t pte,struct vm_area_struct *vma) -{ -if (likely (vma->vm_flags &VM_WRITE )) - pte =pte_mkwrite (pte); -return pte; -} -static inline void cow_user_page (struct page *dst,struct page *src,unsigned long va,struct vm_area_struct *vma) {/*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 define MADV_HUGEPAGE
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
Define MADV_HUGEPAGE.
---
arch/alpha/include/asm/mman.h +2 -0
@@ -53,6 +53,8 @@#define MADV_MERGEABLE 12/* KSM may merge identical pages */ #define MADV_UNMERGEABLE 13/* KSM may not merge identical pages */ +#define MADV_HUGEPAGE 14/* Worth backing with hugepages */ +/* compatibility flags */ #define MAP_FILE 0
arch/mips/include/asm/mman.h +2 -0
@@ -77,6 +77,8 @@#define MADV_UNMERGEABLE 13/* KSM may not merge identical pages */ #define MADV_HWPOISON 100/* poison a page for testing */ +#define MADV_HUGEPAGE 14/* Worth backing with hugepages */ +/* compatibility flags */ #define MAP_FILE 0
arch/parisc/include/asm/mman.h +2 -0
@@ -59,6 +59,8 @@#define MADV_MERGEABLE 65/* KSM may merge identical pages */ #define MADV_UNMERGEABLE 66/* KSM may not merge identical pages */ +#define MADV_HUGEPAGE 67/* Worth backing with hugepages */ +/* compatibility flags */ #define MAP_FILE 0#define MAP_VARIABLE 0
arch/xtensa/include/asm/mman.h +2 -0
@@ -83,6 +83,8 @@#define MADV_MERGEABLE 12/* KSM may merge identical pages */ #define MADV_UNMERGEABLE 13/* KSM may not merge identical pages */ +#define MADV_HUGEPAGE 14/* Worth backing with hugepages */ +/* compatibility flags */ #define MAP_FILE 0
include/asm-generic/mman-common.h +1 -1
@@ -45,7 +45,7 @@#define MADV_MERGEABLE 12/* KSM may merge identical pages */ #define MADV_UNMERGEABLE 13/* KSM may not merge identical pages */ -#define MADV_HUGEPAGE 15/* Worth backing with hugepages */ +#define MADV_HUGEPAGE 14/* Worth backing with hugepages */ /* compatibility flags */ #define MAP_FILE 0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 no paravirt version of pmd ops
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
No paravirt version of set_pmd_at/pmd_update/pmd_update_defer.
---
arch/x86/include/asm/pgtable.h +3 -0
@@ -33,6 +33,7 @@ extern struct list_head pgd_list;#else /* !CONFIG_PARAVIRT */ #define set_pte (ptep, pte) native_set_pte(ptep, pte)#define set_pte_at (mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) +#define set_pmd_at (mm, addr, pmdp, pmd) native_set_pmd_at(mm, addr, pmdp, pmd)#define set_pte_atomic (ptep, pte) \ native_set_pte_atomic(ptep, pte)
@@ -57,6 +58,8 @@ extern struct list_head pgd_list;#define pte_update (mm, addr, ptep) do { } while (0)#define pte_update_defer (mm, addr, ptep) do { } while (0) +#define pmd_update (mm, addr, ptep) do { } while (0) +#define pmd_update_defer (mm, addr, ptep) do { } while (0)#define pgd_val (x) native_pgd_val(x)#define __pgd (x) native_make_pgd(x)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 special pmd_trans_* functions
In reply to Andrea ArcangeliFrom: Andrea Arcangeli <[email protected]>
These returns 0 at compile time when the config option is disabled, to allow gcc to eliminate the transparent hugepage function calls at compile time without additional #ifdefs (only the export of those functions have to be visible to gcc but they won't be required at link time and huge_memory.o can be not built at all).
_PAGE_BIT_UNUSED1 is never used for pmd, only on pte.
---
arch/x86/include/asm/pgtable_64.h +13 -0
@@ -168,6 +168,19 @@ extern void cleanup_highmap(void);#define kc_offset_to_vaddr (o) ((o) | ~__VIRTUAL_MASK)#define __HAVE_ARCH_PTE_SAME + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline int pmd_trans_splitting (pmd_t pmd) +{ +return pmd_val (pmd) & _PAGE_SPLITTING; +} + +static inline int pmd_trans_huge (pmd_t pmd) +{ +return pmd_val (pmd) & _PAGE_PSE; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_PGTABLE_64_H */
arch/x86/include/asm/pgtable_types.h +2 -0
@@ -22,6 +22,7 @@#define _PAGE_BIT_PAT_LARGE 12/* On 2MB or 1GB pages */ #define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1/* only valid on a PSE pmd */ #define _PAGE_BIT_NX 63/* No execute: only valid after cpuid check */ /* If _PAGE_BIT_PRESENT is clear, we use these: */
@@ -45,6 +46,7 @@#define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)#define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL)#define _PAGE_CPA_TEST (_AT(pteval_t, 1) << _PAGE_BIT_CPA_TEST) +#define _PAGE_SPLITTING (_AT(pteval_t, 1) << _PAGE_BIT_SPLITTING)#define __HAVE_ARCH_PTE_SPECIAL#ifdef CONFIG_KMEMCHECK
include/asm-generic/pgtable.h +5 -0
@@ -344,6 +344,11 @@ extern void untrack_pfn_vma(struct vm_ar unsigned long size);#endif +#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#define pmd_trans_huge (pmd) 0 +#define pmd_trans_splitting (pmd) 0 +#endif +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_GENERIC_PGTABLE_H */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>