History

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.

Matthew Wilcox (Oracle) committed 6 years ago

Commit ff45fc31 parent 5be99343 files · +5 −8Browse files

Unified · Split

3 files
  1. include/linux/mm.h +2 −2
  2. mm/swap.c +1 −4
  3. mm/vmscan.c +2 −2
include/linux/mm.h+2−2
@@ -876,10 +876,10 @@ static inline void set_compound_page_dtor(struct page *page, · 875 unmodified lines
876876 page[1].compound_dtor = compound_dtor;
877877 }
878878
879−static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
879+static inline void destroy_compound_page(struct page *page)
880880 {
881881 VM_BUG_ON_PAGE(page[1].compound_dtor >= NR_COMPOUND_DTORS, page);
882− return compound_page_dtors[page[1].compound_dtor];
882+ compound_page_dtors[page[1].compound_dtor](page);
883883 }
884884
885885 static inline unsigned int compound_order(struct page *page)
mm/swap.c+1−4
@@ -102,8 +102,6 @@ static void __put_single_page(struct page *page) · 101 unmodified lines
102102
103103 static void __put_compound_page(struct page *page)
104104 {
105− compound_page_dtor *dtor;
106−
107105 /*
108106 * __page_cache_release() is supposed to be called for thp, not for
109107 * hugetlb. This is because hugetlb page does never have PageLRU set
@@ -112,8 +110,7 @@ static void __put_compound_page(struct page *page) · 2 unmodified lines
112110 */
113111 if (!PageHuge(page))
114112 __page_cache_release(page);
115− dtor = get_compound_page_dtor(page);
116− (*dtor)(page);
113+ destroy_compound_page(page);
117114 }
118115
119116 void __put_page(struct page *page)
mm/vmscan.c+2−2
@@ -1438,7 +1438,7 @@ free_it: · 1437 unmodified lines
14381438 * appear not as the counts should be low
14391439 */
14401440 if (unlikely(PageTransHuge(page)))
1441− (*get_compound_page_dtor(page))(page);
1441+ destroy_compound_page(page);
14421442 else
14431443 list_add(&page->lru, &free_pages);
14441444 continue;
@@ -1859,7 +1859,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, · 414 unmodified lines
18591859
18601860 if (unlikely(PageCompound(page))) {
18611861 spin_unlock_irq(&pgdat->lru_lock);
1862− (*get_compound_page_dtor(page))(page);
1862+ destroy_compound_page(page);
18631863 spin_lock_irq(&pgdat->lru_lock);
18641864 } else
18651865 list_add(&page->lru, &pages_to_free);