diff options
-rw-r--r-- | arch/arc/mm/cache.c | 4 | ||||
-rw-r--r-- | arch/arm/mm/flush.c | 2 | ||||
-rw-r--r-- | arch/mips/mm/c-r4k.c | 3 | ||||
-rw-r--r-- | arch/mips/mm/cache.c | 2 | ||||
-rw-r--r-- | arch/mips/mm/init.c | 6 | ||||
-rw-r--r-- | arch/sh/mm/cache-sh4.c | 2 | ||||
-rw-r--r-- | arch/sh/mm/cache.c | 8 | ||||
-rw-r--r-- | arch/xtensa/mm/tlb.c | 2 | ||||
-rw-r--r-- | fs/proc/page.c | 4 | ||||
-rw-r--r-- | include/linux/mm.h | 15 | ||||
-rw-r--r-- | mm/filemap.c | 2 |
11 files changed, 31 insertions, 19 deletions
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index ff7ff6cbb811..b65f797e9ad6 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c | |||
@@ -617,7 +617,7 @@ void flush_dcache_page(struct page *page) | |||
617 | */ | 617 | */ |
618 | if (!mapping_mapped(mapping)) { | 618 | if (!mapping_mapped(mapping)) { |
619 | clear_bit(PG_dc_clean, &page->flags); | 619 | clear_bit(PG_dc_clean, &page->flags); |
620 | } else if (page_mapped(page)) { | 620 | } else if (page_mapcount(page)) { |
621 | 621 | ||
622 | /* kernel reading from page with U-mapping */ | 622 | /* kernel reading from page with U-mapping */ |
623 | phys_addr_t paddr = (unsigned long)page_address(page); | 623 | phys_addr_t paddr = (unsigned long)page_address(page); |
@@ -857,7 +857,7 @@ void copy_user_highpage(struct page *to, struct page *from, | |||
857 | * For !VIPT cache, all of this gets compiled out as | 857 | * For !VIPT cache, all of this gets compiled out as |
858 | * addr_not_cache_congruent() is 0 | 858 | * addr_not_cache_congruent() is 0 |
859 | */ | 859 | */ |
860 | if (page_mapped(from) && addr_not_cache_congruent(kfrom, u_vaddr)) { | 860 | if (page_mapcount(from) && addr_not_cache_congruent(kfrom, u_vaddr)) { |
861 | __flush_dcache_page((unsigned long)kfrom, u_vaddr); | 861 | __flush_dcache_page((unsigned long)kfrom, u_vaddr); |
862 | clean_src_k_mappings = 1; | 862 | clean_src_k_mappings = 1; |
863 | } | 863 | } |
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c index c2acebb7eedc..d0ba3551d49a 100644 --- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c | |||
@@ -330,7 +330,7 @@ void flush_dcache_page(struct page *page) | |||
330 | mapping = page_mapping(page); | 330 | mapping = page_mapping(page); |
331 | 331 | ||
332 | if (!cache_ops_need_broadcast() && | 332 | if (!cache_ops_need_broadcast() && |
333 | mapping && !page_mapped(page)) | 333 | mapping && !page_mapcount(page)) |
334 | clear_bit(PG_dcache_clean, &page->flags); | 334 | clear_bit(PG_dcache_clean, &page->flags); |
335 | else { | 335 | else { |
336 | __flush_dcache_page(mapping, page); | 336 | __flush_dcache_page(mapping, page); |
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 5d3a25e1cfae..caac3d747a90 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -587,7 +587,8 @@ static inline void local_r4k_flush_cache_page(void *args) | |||
587 | * another ASID than the current one. | 587 | * another ASID than the current one. |
588 | */ | 588 | */ |
589 | map_coherent = (cpu_has_dc_aliases && | 589 | map_coherent = (cpu_has_dc_aliases && |
590 | page_mapped(page) && !Page_dcache_dirty(page)); | 590 | page_mapcount(page) && |
591 | !Page_dcache_dirty(page)); | ||
591 | if (map_coherent) | 592 | if (map_coherent) |
592 | vaddr = kmap_coherent(page, addr); | 593 | vaddr = kmap_coherent(page, addr); |
593 | else | 594 | else |
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index aab218c36e0d..3f159caf6dbc 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c | |||
@@ -106,7 +106,7 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr) | |||
106 | unsigned long addr = (unsigned long) page_address(page); | 106 | unsigned long addr = (unsigned long) page_address(page); |
107 | 107 | ||
108 | if (pages_do_alias(addr, vmaddr)) { | 108 | if (pages_do_alias(addr, vmaddr)) { |
109 | if (page_mapped(page) && !Page_dcache_dirty(page)) { | 109 | if (page_mapcount(page) && !Page_dcache_dirty(page)) { |
110 | void *kaddr; | 110 | void *kaddr; |
111 | 111 | ||
112 | kaddr = kmap_coherent(page, vmaddr); | 112 | kaddr = kmap_coherent(page, vmaddr); |
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 8770e619185e..7e5fa0938c21 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -165,7 +165,7 @@ void copy_user_highpage(struct page *to, struct page *from, | |||
165 | 165 | ||
166 | vto = kmap_atomic(to); | 166 | vto = kmap_atomic(to); |
167 | if (cpu_has_dc_aliases && | 167 | if (cpu_has_dc_aliases && |
168 | page_mapped(from) && !Page_dcache_dirty(from)) { | 168 | page_mapcount(from) && !Page_dcache_dirty(from)) { |
169 | vfrom = kmap_coherent(from, vaddr); | 169 | vfrom = kmap_coherent(from, vaddr); |
170 | copy_page(vto, vfrom); | 170 | copy_page(vto, vfrom); |
171 | kunmap_coherent(); | 171 | kunmap_coherent(); |
@@ -187,7 +187,7 @@ void copy_to_user_page(struct vm_area_struct *vma, | |||
187 | unsigned long len) | 187 | unsigned long len) |
188 | { | 188 | { |
189 | if (cpu_has_dc_aliases && | 189 | if (cpu_has_dc_aliases && |
190 | page_mapped(page) && !Page_dcache_dirty(page)) { | 190 | page_mapcount(page) && !Page_dcache_dirty(page)) { |
191 | void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); | 191 | void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); |
192 | memcpy(vto, src, len); | 192 | memcpy(vto, src, len); |
193 | kunmap_coherent(); | 193 | kunmap_coherent(); |
@@ -205,7 +205,7 @@ void copy_from_user_page(struct vm_area_struct *vma, | |||
205 | unsigned long len) | 205 | unsigned long len) |
206 | { | 206 | { |
207 | if (cpu_has_dc_aliases && | 207 | if (cpu_has_dc_aliases && |
208 | page_mapped(page) && !Page_dcache_dirty(page)) { | 208 | page_mapcount(page) && !Page_dcache_dirty(page)) { |
209 | void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); | 209 | void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); |
210 | memcpy(dst, vfrom, len); | 210 | memcpy(dst, vfrom, len); |
211 | kunmap_coherent(); | 211 | kunmap_coherent(); |
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c index 51d8f7f31d1d..58aaa4f33b81 100644 --- a/arch/sh/mm/cache-sh4.c +++ b/arch/sh/mm/cache-sh4.c | |||
@@ -241,7 +241,7 @@ static void sh4_flush_cache_page(void *args) | |||
241 | */ | 241 | */ |
242 | map_coherent = (current_cpu_data.dcache.n_aliases && | 242 | map_coherent = (current_cpu_data.dcache.n_aliases && |
243 | test_bit(PG_dcache_clean, &page->flags) && | 243 | test_bit(PG_dcache_clean, &page->flags) && |
244 | page_mapped(page)); | 244 | page_mapcount(page)); |
245 | if (map_coherent) | 245 | if (map_coherent) |
246 | vaddr = kmap_coherent(page, address); | 246 | vaddr = kmap_coherent(page, address); |
247 | else | 247 | else |
diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c index f770e3992620..e58cfbf45150 100644 --- a/arch/sh/mm/cache.c +++ b/arch/sh/mm/cache.c | |||
@@ -59,7 +59,7 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page, | |||
59 | unsigned long vaddr, void *dst, const void *src, | 59 | unsigned long vaddr, void *dst, const void *src, |
60 | unsigned long len) | 60 | unsigned long len) |
61 | { | 61 | { |
62 | if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && | 62 | if (boot_cpu_data.dcache.n_aliases && page_mapcount(page) && |
63 | test_bit(PG_dcache_clean, &page->flags)) { | 63 | test_bit(PG_dcache_clean, &page->flags)) { |
64 | void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); | 64 | void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); |
65 | memcpy(vto, src, len); | 65 | memcpy(vto, src, len); |
@@ -78,7 +78,7 @@ void copy_from_user_page(struct vm_area_struct *vma, struct page *page, | |||
78 | unsigned long vaddr, void *dst, const void *src, | 78 | unsigned long vaddr, void *dst, const void *src, |
79 | unsigned long len) | 79 | unsigned long len) |
80 | { | 80 | { |
81 | if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && | 81 | if (boot_cpu_data.dcache.n_aliases && page_mapcount(page) && |
82 | test_bit(PG_dcache_clean, &page->flags)) { | 82 | test_bit(PG_dcache_clean, &page->flags)) { |
83 | void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); | 83 | void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); |
84 | memcpy(dst, vfrom, len); | 84 | memcpy(dst, vfrom, len); |
@@ -97,7 +97,7 @@ void copy_user_highpage(struct page *to, struct page *from, | |||
97 | 97 | ||
98 | vto = kmap_atomic(to); | 98 | vto = kmap_atomic(to); |
99 | 99 | ||
100 | if (boot_cpu_data.dcache.n_aliases && page_mapped(from) && | 100 | if (boot_cpu_data.dcache.n_aliases && page_mapcount(from) && |
101 | test_bit(PG_dcache_clean, &from->flags)) { | 101 | test_bit(PG_dcache_clean, &from->flags)) { |
102 | vfrom = kmap_coherent(from, vaddr); | 102 | vfrom = kmap_coherent(from, vaddr); |
103 | copy_page(vto, vfrom); | 103 | copy_page(vto, vfrom); |
@@ -153,7 +153,7 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr) | |||
153 | unsigned long addr = (unsigned long) page_address(page); | 153 | unsigned long addr = (unsigned long) page_address(page); |
154 | 154 | ||
155 | if (pages_do_alias(addr, vmaddr)) { | 155 | if (pages_do_alias(addr, vmaddr)) { |
156 | if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && | 156 | if (boot_cpu_data.dcache.n_aliases && page_mapcount(page) && |
157 | test_bit(PG_dcache_clean, &page->flags)) { | 157 | test_bit(PG_dcache_clean, &page->flags)) { |
158 | void *kaddr; | 158 | void *kaddr; |
159 | 159 | ||
diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index 5ece856c5725..35c822286bbe 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c | |||
@@ -245,7 +245,7 @@ static int check_tlb_entry(unsigned w, unsigned e, bool dtlb) | |||
245 | page_mapcount(p)); | 245 | page_mapcount(p)); |
246 | if (!page_count(p)) | 246 | if (!page_count(p)) |
247 | rc |= TLB_INSANE; | 247 | rc |= TLB_INSANE; |
248 | else if (page_mapped(p)) | 248 | else if (page_mapcount(p)) |
249 | rc |= TLB_SUSPICIOUS; | 249 | rc |= TLB_SUSPICIOUS; |
250 | } else { | 250 | } else { |
251 | rc |= TLB_INSANE; | 251 | rc |= TLB_INSANE; |
diff --git a/fs/proc/page.c b/fs/proc/page.c index 93484034a03d..b2855eea5405 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c | |||
@@ -103,9 +103,9 @@ u64 stable_page_flags(struct page *page) | |||
103 | * pseudo flags for the well known (anonymous) memory mapped pages | 103 | * pseudo flags for the well known (anonymous) memory mapped pages |
104 | * | 104 | * |
105 | * Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the | 105 | * Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the |
106 | * simple test in page_mapped() is not enough. | 106 | * simple test in page_mapcount() is not enough. |
107 | */ | 107 | */ |
108 | if (!PageSlab(page) && page_mapped(page)) | 108 | if (!PageSlab(page) && page_mapcount(page)) |
109 | u |= 1 << KPF_MMAP; | 109 | u |= 1 << KPF_MMAP; |
110 | if (PageAnon(page)) | 110 | if (PageAnon(page)) |
111 | u |= 1 << KPF_ANON; | 111 | u |= 1 << KPF_ANON; |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 67e0fab225e8..6b56cfd9fd09 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -953,10 +953,21 @@ static inline pgoff_t page_file_index(struct page *page) | |||
953 | 953 | ||
954 | /* | 954 | /* |
955 | * Return true if this page is mapped into pagetables. | 955 | * Return true if this page is mapped into pagetables. |
956 | * For compound page it returns true if any subpage of compound page is mapped. | ||
956 | */ | 957 | */ |
957 | static inline int page_mapped(struct page *page) | 958 | static inline bool page_mapped(struct page *page) |
958 | { | 959 | { |
959 | return atomic_read(&(page)->_mapcount) + compound_mapcount(page) >= 0; | 960 | int i; |
961 | if (likely(!PageCompound(page))) | ||
962 | return atomic_read(&page->_mapcount) >= 0; | ||
963 | page = compound_head(page); | ||
964 | if (atomic_read(compound_mapcount_ptr(page)) >= 0) | ||
965 | return true; | ||
966 | for (i = 0; i < hpage_nr_pages(page); i++) { | ||
967 | if (atomic_read(&page[i]._mapcount) >= 0) | ||
968 | return true; | ||
969 | } | ||
970 | return false; | ||
960 | } | 971 | } |
961 | 972 | ||
962 | /* | 973 | /* |
diff --git a/mm/filemap.c b/mm/filemap.c index a729345ed6ec..847ee43c2806 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -204,7 +204,7 @@ void __delete_from_page_cache(struct page *page, void *shadow, | |||
204 | __dec_zone_page_state(page, NR_FILE_PAGES); | 204 | __dec_zone_page_state(page, NR_FILE_PAGES); |
205 | if (PageSwapBacked(page)) | 205 | if (PageSwapBacked(page)) |
206 | __dec_zone_page_state(page, NR_SHMEM); | 206 | __dec_zone_page_state(page, NR_SHMEM); |
207 | BUG_ON(page_mapped(page)); | 207 | VM_BUG_ON_PAGE(page_mapped(page), page); |
208 | 208 | ||
209 | /* | 209 | /* |
210 | * At this point page must be either written or cleaned by truncate. | 210 | * At this point page must be either written or cleaned by truncate. |