Commit ff45fc3c authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

mm: simplify calling a compound page destructor

None of the three callers of get_compound_page_dtor() want to know the
value; they just want to call the function.  Replace it with
destroy_compound_page() which calls the dtor for them.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: http://lkml.kernel.org/r/20200517105051.9352-1-willy@infradead.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5be99343
...@@ -876,10 +876,10 @@ static inline void set_compound_page_dtor(struct page *page, ...@@ -876,10 +876,10 @@ static inline void set_compound_page_dtor(struct page *page,
page[1].compound_dtor = compound_dtor; page[1].compound_dtor = compound_dtor;
} }
static inline compound_page_dtor *get_compound_page_dtor(struct page *page) static inline void destroy_compound_page(struct page *page)
{ {
VM_BUG_ON_PAGE(page[1].compound_dtor >= NR_COMPOUND_DTORS, page); VM_BUG_ON_PAGE(page[1].compound_dtor >= NR_COMPOUND_DTORS, page);
return compound_page_dtors[page[1].compound_dtor]; compound_page_dtors[page[1].compound_dtor](page);
} }
static inline unsigned int compound_order(struct page *page) static inline unsigned int compound_order(struct page *page)
......
...@@ -102,8 +102,6 @@ static void __put_single_page(struct page *page) ...@@ -102,8 +102,6 @@ static void __put_single_page(struct page *page)
static void __put_compound_page(struct page *page) static void __put_compound_page(struct page *page)
{ {
compound_page_dtor *dtor;
/* /*
* __page_cache_release() is supposed to be called for thp, not for * __page_cache_release() is supposed to be called for thp, not for
* hugetlb. This is because hugetlb page does never have PageLRU set * hugetlb. This is because hugetlb page does never have PageLRU set
...@@ -112,8 +110,7 @@ static void __put_compound_page(struct page *page) ...@@ -112,8 +110,7 @@ static void __put_compound_page(struct page *page)
*/ */
if (!PageHuge(page)) if (!PageHuge(page))
__page_cache_release(page); __page_cache_release(page);
dtor = get_compound_page_dtor(page); destroy_compound_page(page);
(*dtor)(page);
} }
void __put_page(struct page *page) void __put_page(struct page *page)
......
...@@ -1438,7 +1438,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, ...@@ -1438,7 +1438,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
* appear not as the counts should be low * appear not as the counts should be low
*/ */
if (unlikely(PageTransHuge(page))) if (unlikely(PageTransHuge(page)))
(*get_compound_page_dtor(page))(page); destroy_compound_page(page);
else else
list_add(&page->lru, &free_pages); list_add(&page->lru, &free_pages);
continue; continue;
...@@ -1859,7 +1859,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, ...@@ -1859,7 +1859,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec,
if (unlikely(PageCompound(page))) { if (unlikely(PageCompound(page))) {
spin_unlock_irq(&pgdat->lru_lock); spin_unlock_irq(&pgdat->lru_lock);
(*get_compound_page_dtor(page))(page); destroy_compound_page(page);
spin_lock_irq(&pgdat->lru_lock); spin_lock_irq(&pgdat->lru_lock);
} else } else
list_add(&page->lru, &pages_to_free); list_add(&page->lru, &pages_to_free);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment