diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2012-12-12 16:52:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 20:38:35 -0500 |
commit | 816422ad76474fed8052b6f7b905a054d082e59a (patch) | |
tree | 9918f68e9c5f93be98940b4b7b478e1637547926 | |
parent | 56f2fb147659e05b1e87b99791bf44b988d38545 (diff) |
asm-generic, mm: pgtable: consolidate zero page helpers
We have two different implementation of is_zero_pfn() and my_zero_pfn()
helpers: for architectures with and without zero page coloring.
Let's consolidate them in <asm-generic/pgtable.h>.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/mips/include/asm/pgtable.h | 11 | ||||
-rw-r--r-- | arch/s390/include/asm/pgtable.h | 11 | ||||
-rw-r--r-- | include/asm-generic/pgtable.h | 26 | ||||
-rw-r--r-- | include/linux/mm.h | 8 | ||||
-rw-r--r-- | mm/memory.c | 7 |
5 files changed, 28 insertions, 35 deletions
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index c02158be836c..14490e9443af 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h | |||
@@ -76,16 +76,7 @@ extern unsigned long zero_page_mask; | |||
76 | 76 | ||
77 | #define ZERO_PAGE(vaddr) \ | 77 | #define ZERO_PAGE(vaddr) \ |
78 | (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) | 78 | (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) |
79 | 79 | #define __HAVE_COLOR_ZERO_PAGE | |
80 | #define is_zero_pfn is_zero_pfn | ||
81 | static inline int is_zero_pfn(unsigned long pfn) | ||
82 | { | ||
83 | extern unsigned long zero_pfn; | ||
84 | unsigned long offset_from_zero_pfn = pfn - zero_pfn; | ||
85 | return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT); | ||
86 | } | ||
87 | |||
88 | #define my_zero_pfn(addr) page_to_pfn(ZERO_PAGE(addr)) | ||
89 | 80 | ||
90 | extern void paging_init(void); | 81 | extern void paging_init(void); |
91 | 82 | ||
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 2d3b7cb26005..c814e6f5b57d 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h | |||
@@ -55,16 +55,7 @@ extern unsigned long zero_page_mask; | |||
55 | #define ZERO_PAGE(vaddr) \ | 55 | #define ZERO_PAGE(vaddr) \ |
56 | (virt_to_page((void *)(empty_zero_page + \ | 56 | (virt_to_page((void *)(empty_zero_page + \ |
57 | (((unsigned long)(vaddr)) &zero_page_mask)))) | 57 | (((unsigned long)(vaddr)) &zero_page_mask)))) |
58 | 58 | #define __HAVE_COLOR_ZERO_PAGE | |
59 | #define is_zero_pfn is_zero_pfn | ||
60 | static inline int is_zero_pfn(unsigned long pfn) | ||
61 | { | ||
62 | extern unsigned long zero_pfn; | ||
63 | unsigned long offset_from_zero_pfn = pfn - zero_pfn; | ||
64 | return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT); | ||
65 | } | ||
66 | |||
67 | #define my_zero_pfn(addr) page_to_pfn(ZERO_PAGE(addr)) | ||
68 | 59 | ||
69 | #endif /* !__ASSEMBLY__ */ | 60 | #endif /* !__ASSEMBLY__ */ |
70 | 61 | ||
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index b36ce40bd1c6..284e80831d2c 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
@@ -449,6 +449,32 @@ extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, | |||
449 | unsigned long size); | 449 | unsigned long size); |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | #ifdef __HAVE_COLOR_ZERO_PAGE | ||
453 | static inline int is_zero_pfn(unsigned long pfn) | ||
454 | { | ||
455 | extern unsigned long zero_pfn; | ||
456 | unsigned long offset_from_zero_pfn = pfn - zero_pfn; | ||
457 | return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT); | ||
458 | } | ||
459 | |||
460 | static inline unsigned long my_zero_pfn(unsigned long addr) | ||
461 | { | ||
462 | return page_to_pfn(ZERO_PAGE(addr)); | ||
463 | } | ||
464 | #else | ||
465 | static inline int is_zero_pfn(unsigned long pfn) | ||
466 | { | ||
467 | extern unsigned long zero_pfn; | ||
468 | return pfn == zero_pfn; | ||
469 | } | ||
470 | |||
471 | static inline unsigned long my_zero_pfn(unsigned long addr) | ||
472 | { | ||
473 | extern unsigned long zero_pfn; | ||
474 | return zero_pfn; | ||
475 | } | ||
476 | #endif | ||
477 | |||
452 | #ifdef CONFIG_MMU | 478 | #ifdef CONFIG_MMU |
453 | 479 | ||
454 | #ifndef CONFIG_TRANSPARENT_HUGEPAGE | 480 | #ifndef CONFIG_TRANSPARENT_HUGEPAGE |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 4b80bad4a367..4af4f0b1be4c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -516,14 +516,6 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) | |||
516 | } | 516 | } |
517 | #endif | 517 | #endif |
518 | 518 | ||
519 | #ifndef my_zero_pfn | ||
520 | static inline unsigned long my_zero_pfn(unsigned long addr) | ||
521 | { | ||
522 | extern unsigned long zero_pfn; | ||
523 | return zero_pfn; | ||
524 | } | ||
525 | #endif | ||
526 | |||
527 | /* | 519 | /* |
528 | * Multiple processes may "see" the same page. E.g. for untouched | 520 | * Multiple processes may "see" the same page. E.g. for untouched |
529 | * mappings of /dev/null, all processes see the same page full of | 521 | * mappings of /dev/null, all processes see the same page full of |
diff --git a/mm/memory.c b/mm/memory.c index f9a4b0cb8623..3f680e7c7645 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -717,13 +717,6 @@ static inline bool is_cow_mapping(vm_flags_t flags) | |||
717 | return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; | 717 | return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; |
718 | } | 718 | } |
719 | 719 | ||
720 | #ifndef is_zero_pfn | ||
721 | static inline int is_zero_pfn(unsigned long pfn) | ||
722 | { | ||
723 | return pfn == zero_pfn; | ||
724 | } | ||
725 | #endif | ||
726 | |||
727 | /* | 720 | /* |
728 | * vm_normal_page -- This function gets the "struct page" associated with a pte. | 721 | * vm_normal_page -- This function gets the "struct page" associated with a pte. |
729 | * | 722 | * |