aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mm.h13
-rw-r--r--mm/util.c16
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
812extern struct address_space swapper_space; 812extern struct address_space *page_mapping(struct page *page);
813static 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 */
826static inline void *page_rmapping(struct page *page) 815static inline void *page_rmapping(struct page *page)
diff --git a/mm/util.c b/mm/util.c
index 3704bf1bef94..16a73195a37b 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -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}
383EXPORT_SYMBOL(vm_mmap); 384EXPORT_SYMBOL(vm_mmap);
384 385
386struct 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. */
386EXPORT_TRACEPOINT_SYMBOL(kmalloc); 402EXPORT_TRACEPOINT_SYMBOL(kmalloc);
387EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); 403EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);