]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: uninline and cleanup page-mapping related helpers
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tue, 7 Apr 2015 23:44:36 +0000 (09:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 7 Apr 2015 23:44:36 +0000 (09:44 +1000)
Most-used page->mapping helper -- page_mapping() -- has already uninlined.
 Let's uninline also page_rmapping() and page_anon_vma().  It saves us
depending on configuration around 400 bytes in text:

   text    data     bss     dec     hex filename
 660318   99254  410000 1169572  11d8a4 mm/built-in.o-before
 659854   99254  410000 1169108  11d6d4 mm/built-in.o

I also tried to make code a bit more clean.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
include/linux/rmap.h
mm/util.c

index d584b95c91afae7907bebbfcbe6bcfbf90d941cf..def764e1796df84863dc0c79688bdbd4de5e6da6 100644 (file)
@@ -910,15 +910,10 @@ void page_address_init(void);
 #define page_address_init()  do { } while(0)
 #endif
 
+extern void *page_rmapping(struct page *page);
+extern struct anon_vma *page_anon_vma(struct page *page);
 extern struct address_space *page_mapping(struct page *page);
 
-/* Neutral page->mapping pointer to address_space or anon_vma or other */
-static inline void *page_rmapping(struct page *page)
-{
-       page = compound_head(page);
-       return (void *)((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
-}
-
 extern struct address_space *__page_file_mapping(struct page *);
 
 static inline
index 6e7b0443afb095da6e90a3b75a79bb6ccb8a05f9..c89c53a113a8d59c6a427139d220b9d75d6de7d7 100644 (file)
@@ -105,15 +105,6 @@ static inline void put_anon_vma(struct anon_vma *anon_vma)
                __put_anon_vma(anon_vma);
 }
 
-static inline struct anon_vma *page_anon_vma(struct page *page)
-{
-       page = compound_head(page);
-       if (((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) !=
-                                           PAGE_MAPPING_ANON)
-               return NULL;
-       return page_rmapping(page);
-}
-
 static inline void vma_lock_anon_vma(struct vm_area_struct *vma)
 {
        struct anon_vma *anon_vma = vma->anon_vma;
index e78968bd11e734184c2ac78ed32208124eefe725..aca58b81bcfaff7eaa65485ac68d9ef50025f779 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -325,12 +325,39 @@ void kvfree(const void *addr)
 }
 EXPORT_SYMBOL(kvfree);
 
+static inline void * __page_rmapping(struct page *page)
+{
+       unsigned long mapping;
+
+       mapping = (unsigned long)page->mapping;
+       mapping &= ~PAGE_MAPPING_FLAGS;
+
+       return (void *)mapping;
+}
+
+/* Neutral page->mapping pointer to address_space or anon_vma or other */
+void *page_rmapping(struct page *page)
+{
+       page = compound_head(page);
+       return __page_rmapping(page);
+}
+
+struct anon_vma *page_anon_vma(struct page *page)
+{
+       unsigned long mapping;
+
+       page = compound_head(page);
+       mapping = (unsigned long)page->mapping;
+       if ((mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON)
+               return NULL;
+       return __page_rmapping(page);
+}
+
 struct address_space *page_mapping(struct page *page)
 {
-       struct address_space *mapping;
+       unsigned long mapping;
 
        page = compound_head(page);
-       mapping = page->mapping;
 
        /* This happens if someone calls flush_dcache_page on slab page */
        if (unlikely(PageSlab(page)))
@@ -340,10 +367,13 @@ struct address_space *page_mapping(struct page *page)
                swp_entry_t entry;
 
                entry.val = page_private(page);
-               mapping = swap_address_space(entry);
-       } else if ((unsigned long)mapping & PAGE_MAPPING_ANON)
-               mapping = NULL;
-       return mapping;
+               return swap_address_space(entry);
+       }
+
+       mapping = (unsigned long)page->mapping;
+       if (mapping & PAGE_MAPPING_FLAGS)
+               return NULL;
+       return page->mapping;
 }
 
 int overcommit_ratio_handler(struct ctl_table *table, int write,