diff options
-rw-r--r-- | include/linux/mm.h | 13 | ||||
-rw-r--r-- | mm/util.c | 16 |
2 files changed, 17 insertions, 12 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 473abbda942e..1d4122bf6f27 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -809,18 +809,7 @@ void page_address_init(void); | |||
809 | #define PAGE_MAPPING_KSM 2 | 809 | #define PAGE_MAPPING_KSM 2 |
810 | #define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM) | 810 | #define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM) |
811 | 811 | ||
812 | extern struct address_space swapper_space; | 812 | extern struct address_space *page_mapping(struct page *page); |
813 | static inline struct address_space *page_mapping(struct page *page) | ||
814 | { | ||
815 | struct address_space *mapping = page->mapping; | ||
816 | |||
817 | VM_BUG_ON(PageSlab(page)); | ||
818 | if (unlikely(PageSwapCache(page))) | ||
819 | mapping = &swapper_space; | ||
820 | else if ((unsigned long)mapping & PAGE_MAPPING_ANON) | ||
821 | mapping = NULL; | ||
822 | return mapping; | ||
823 | } | ||
824 | 813 | ||
825 | /* Neutral page->mapping pointer to address_space or anon_vma or other */ | 814 | /* Neutral page->mapping pointer to address_space or anon_vma or other */ |
826 | static inline void *page_rmapping(struct page *page) | 815 | static inline void *page_rmapping(struct page *page) |
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/security.h> | 7 | #include <linux/security.h> |
8 | #include <linux/swap.h> | ||
8 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
9 | 10 | ||
10 | #include "internal.h" | 11 | #include "internal.h" |
@@ -382,6 +383,21 @@ unsigned long vm_mmap(struct file *file, unsigned long addr, | |||
382 | } | 383 | } |
383 | EXPORT_SYMBOL(vm_mmap); | 384 | EXPORT_SYMBOL(vm_mmap); |
384 | 385 | ||
386 | struct address_space *page_mapping(struct page *page) | ||
387 | { | ||
388 | struct address_space *mapping = page->mapping; | ||
389 | |||
390 | VM_BUG_ON(PageSlab(page)); | ||
391 | #ifdef CONFIG_SWAP | ||
392 | if (unlikely(PageSwapCache(page))) | ||
393 | mapping = &swapper_space; | ||
394 | else | ||
395 | #endif | ||
396 | if ((unsigned long)mapping & PAGE_MAPPING_ANON) | ||
397 | mapping = NULL; | ||
398 | return mapping; | ||
399 | } | ||
400 | |||
385 | /* Tracepoints definitions. */ | 401 | /* Tracepoints definitions. */ |
386 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); | 402 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); |
387 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); | 403 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); |