1 From b35a35b556f5e6b7993ad0baf20173e75c09ce8c Mon Sep 17 00:00:00 2001
2 From: Andrea Arcangeli <aarcange@redhat.com>
3 Date: Wed, 2 Nov 2011 13:37:36 -0700
4 Subject: thp: share get_huge_page_tail()
6 From: Andrea Arcangeli <aarcange@redhat.com>
8 commit b35a35b556f5e6b7993ad0baf20173e75c09ce8c upstream.
10 This avoids duplicating the function in every arch gup_fast.
12 Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
13 Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
14 Cc: Hugh Dickins <hughd@google.com>
15 Cc: Johannes Weiner <jweiner@redhat.com>
16 Cc: Rik van Riel <riel@redhat.com>
17 Cc: Mel Gorman <mgorman@suse.de>
18 Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
19 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
20 Cc: David Gibson <david@gibson.dropbear.id.au>
21 Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
22 Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
23 Cc: David Miller <davem@davemloft.net>
24 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
25 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
29 arch/powerpc/mm/hugetlbpage.c | 11 -----------
30 arch/s390/mm/gup.c | 11 -----------
31 arch/sparc/mm/gup.c | 11 -----------
32 arch/x86/mm/gup.c | 11 -----------
33 include/linux/mm.h | 11 +++++++++++
34 5 files changed, 11 insertions(+), 44 deletions(-)
36 --- a/arch/powerpc/mm/hugetlbpage.c
37 +++ b/arch/powerpc/mm/hugetlbpage.c
38 @@ -385,17 +385,6 @@ follow_huge_pmd(struct mm_struct *mm, un
42 -static inline void get_huge_page_tail(struct page *page)
45 - * __split_huge_page_refcount() cannot run
48 - VM_BUG_ON(page_mapcount(page) < 0);
49 - VM_BUG_ON(atomic_read(&page->_count) != 0);
50 - atomic_inc(&page->_mapcount);
53 static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
54 unsigned long end, int write, struct page **pages, int *nr)
56 --- a/arch/s390/mm/gup.c
57 +++ b/arch/s390/mm/gup.c
58 @@ -48,17 +48,6 @@ static inline int gup_pte_range(pmd_t *p
62 -static inline void get_huge_page_tail(struct page *page)
65 - * __split_huge_page_refcount() cannot run
68 - VM_BUG_ON(page_mapcount(page) < 0);
69 - VM_BUG_ON(atomic_read(&page->_count) != 0);
70 - atomic_inc(&page->_mapcount);
73 static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
74 unsigned long end, int write, struct page **pages, int *nr)
76 --- a/arch/sparc/mm/gup.c
77 +++ b/arch/sparc/mm/gup.c
79 #include <linux/rwsem.h>
80 #include <asm/pgtable.h>
82 -static inline void get_huge_page_tail(struct page *page)
85 - * __split_huge_page_refcount() cannot run
88 - VM_BUG_ON(page_mapcount(page) < 0);
89 - VM_BUG_ON(atomic_read(&page->_count) != 0);
90 - atomic_inc(&page->_mapcount);
94 * The performance critical leaf functions are made noinline otherwise gcc
95 * inlines everything into a single function which results in too much
96 --- a/arch/x86/mm/gup.c
97 +++ b/arch/x86/mm/gup.c
98 @@ -108,17 +108,6 @@ static inline void get_head_page_multipl
99 SetPageReferenced(page);
102 -static inline void get_huge_page_tail(struct page *page)
105 - * __split_huge_page_refcount() cannot run
108 - VM_BUG_ON(page_mapcount(page) < 0);
109 - VM_BUG_ON(atomic_read(&page->_count) != 0);
110 - atomic_inc(&page->_mapcount);
113 static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,
114 unsigned long end, int write, struct page **pages, int *nr)
116 --- a/include/linux/mm.h
117 +++ b/include/linux/mm.h
118 @@ -376,6 +376,17 @@ static inline int page_count(struct page
119 return atomic_read(&compound_head(page)->_count);
122 +static inline void get_huge_page_tail(struct page *page)
125 + * __split_huge_page_refcount() cannot run
128 + VM_BUG_ON(page_mapcount(page) < 0);
129 + VM_BUG_ON(atomic_read(&page->_count) != 0);
130 + atomic_inc(&page->_mapcount);
133 extern bool __get_page_tail(struct page *page);
135 static inline void get_page(struct page *page)