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
876 page[1].compound_dtor = compound_dtor;876 page[1].compound_dtor = compound_dtor;
877}877}
878 878
879static inline compound_page_dtor *get_compound_page_dtor(struct page *page)879static inline void destroy_compound_page(struct page *page)
880{880{
881 VM_BUG_ON_PAGE(page[1].compound_dtor >= NR_COMPOUND_DTORS, page);881 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);
883}883}
884 884
885static inline unsigned int compound_order(struct page *page)885static 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
102 102
103static void __put_compound_page(struct page *page)103static void __put_compound_page(struct page *page)
104{104{
105 compound_page_dtor *dtor;
106
107 /*105 /*
108 * __page_cache_release() is supposed to be called for thp, not for106 * __page_cache_release() is supposed to be called for thp, not for
109 * hugetlb. This is because hugetlb page does never have PageLRU set107 * 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
112 */110 */
113 if (!PageHuge(page))111 if (!PageHuge(page))
114 __page_cache_release(page);112 __page_cache_release(page);
115 dtor = get_compound_page_dtor(page);113 destroy_compound_page(page);
116 (*dtor)(page);
117}114}
118 115
119void __put_page(struct page *page)116void __put_page(struct page *page)
mm/vmscan.c+2−2
@@ -1438,7 +1438,7 @@ free_it: · 1437 unmodified lines
1438 * appear not as the counts should be low1438 * appear not as the counts should be low
1439 */1439 */
1440 if (unlikely(PageTransHuge(page)))1440 if (unlikely(PageTransHuge(page)))
1441 (*get_compound_page_dtor(page))(page);1441 destroy_compound_page(page);
1442 else1442 else
1443 list_add(&page->lru, &free_pages);1443 list_add(&page->lru, &free_pages);
1444 continue;1444 continue;
@@ -1859,7 +1859,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, · 414 unmodified lines
1859 1859
1860 if (unlikely(PageCompound(page))) {1860 if (unlikely(PageCompound(page))) {
1861 spin_unlock_irq(&pgdat->lru_lock);1861 spin_unlock_irq(&pgdat->lru_lock);
1862 (*get_compound_page_dtor(page))(page);1862 destroy_compound_page(page);
1863 spin_lock_irq(&pgdat->lru_lock);1863 spin_lock_irq(&pgdat->lru_lock);
1864 } else1864 } else
1865 list_add(&page->lru, &pages_to_free);1865 list_add(&page->lru, &pages_to_free);