All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: Simplify calling a compound page destructor
@ 2020-05-17 10:50 Matthew Wilcox
  2020-05-18  2:28 ` Anshuman Khandual
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-05-17 10:50 UTC (permalink / raw)
  To: linux-mm, Kirill A . Shutemov, Andrew Morton; +Cc: Matthew Wilcox (Oracle)

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

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: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/mm.h | 4 ++--
 mm/swap.c          | 5 +----
 mm/vmscan.c        | 4 ++--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 31ec312e8903..688558c57751 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -865,10 +865,10 @@ static inline void set_compound_page_dtor(struct page *page,
 	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);
-	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)
diff --git a/mm/swap.c b/mm/swap.c
index a37bd7b202ac..416fb89c86c1 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -83,8 +83,6 @@ static void __put_single_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
 	 * hugetlb. This is because hugetlb page does never have PageLRU set
@@ -93,8 +91,7 @@ static void __put_compound_page(struct page *page)
 	 */
 	if (!PageHuge(page))
 		__page_cache_release(page);
-	dtor = get_compound_page_dtor(page);
-	(*dtor)(page);
+	destroy_compound_page(page);
 }
 
 void __put_page(struct page *page)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index cc555903a332..d96e18726751 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1442,7 +1442,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 		 * appear not as the counts should be low
 		 */
 		if (unlikely(PageTransHuge(page)))
-			(*get_compound_page_dtor(page))(page);
+			destroy_compound_page(page);
 		else
 			list_add(&page->lru, &free_pages);
 		continue;
@@ -1870,7 +1870,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec,
 
 			if (unlikely(PageCompound(page))) {
 				spin_unlock_irq(&pgdat->lru_lock);
-				(*get_compound_page_dtor(page))(page);
+				destroy_compound_page(page);
 				spin_lock_irq(&pgdat->lru_lock);
 			} else
 				list_add(&page->lru, &pages_to_free);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Simplify calling a compound page destructor
  2020-05-17 10:50 [PATCH] mm: Simplify calling a compound page destructor Matthew Wilcox
@ 2020-05-18  2:28 ` Anshuman Khandual
  2020-05-18 10:00 ` Kirill A. Shutemov
  2020-05-18 10:06 ` David Hildenbrand
  2 siblings, 0 replies; 4+ messages in thread
From: Anshuman Khandual @ 2020-05-18  2:28 UTC (permalink / raw)
  To: Matthew Wilcox, linux-mm, Kirill A . Shutemov, Andrew Morton



On 05/17/2020 04:20 PM, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> 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: Matthew Wilcox (Oracle) <willy@infradead.org>

Makes it simple and clean.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Simplify calling a compound page destructor
  2020-05-17 10:50 [PATCH] mm: Simplify calling a compound page destructor Matthew Wilcox
  2020-05-18  2:28 ` Anshuman Khandual
@ 2020-05-18 10:00 ` Kirill A. Shutemov
  2020-05-18 10:06 ` David Hildenbrand
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2020-05-18 10:00 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-mm, Kirill A . Shutemov, Andrew Morton

On Sun, May 17, 2020 at 03:50:51AM -0700, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> 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: Matthew Wilcox (Oracle) <willy@infradead.org>

Ackedy-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: Simplify calling a compound page destructor
  2020-05-17 10:50 [PATCH] mm: Simplify calling a compound page destructor Matthew Wilcox
  2020-05-18  2:28 ` Anshuman Khandual
  2020-05-18 10:00 ` Kirill A. Shutemov
@ 2020-05-18 10:06 ` David Hildenbrand
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2020-05-18 10:06 UTC (permalink / raw)
  To: Matthew Wilcox, linux-mm, Kirill A . Shutemov, Andrew Morton

On 17.05.20 12:50, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> 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: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  include/linux/mm.h | 4 ++--
>  mm/swap.c          | 5 +----
>  mm/vmscan.c        | 4 ++--
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 31ec312e8903..688558c57751 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -865,10 +865,10 @@ static inline void set_compound_page_dtor(struct page *page,
>  	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);
> -	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)
> diff --git a/mm/swap.c b/mm/swap.c
> index a37bd7b202ac..416fb89c86c1 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -83,8 +83,6 @@ static void __put_single_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
>  	 * hugetlb. This is because hugetlb page does never have PageLRU set
> @@ -93,8 +91,7 @@ static void __put_compound_page(struct page *page)
>  	 */
>  	if (!PageHuge(page))
>  		__page_cache_release(page);
> -	dtor = get_compound_page_dtor(page);
> -	(*dtor)(page);
> +	destroy_compound_page(page);
>  }
>  
>  void __put_page(struct page *page)
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index cc555903a332..d96e18726751 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1442,7 +1442,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
>  		 * appear not as the counts should be low
>  		 */
>  		if (unlikely(PageTransHuge(page)))
> -			(*get_compound_page_dtor(page))(page);
> +			destroy_compound_page(page);
>  		else
>  			list_add(&page->lru, &free_pages);
>  		continue;
> @@ -1870,7 +1870,7 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec,
>  
>  			if (unlikely(PageCompound(page))) {
>  				spin_unlock_irq(&pgdat->lru_lock);
> -				(*get_compound_page_dtor(page))(page);
> +				destroy_compound_page(page);
>  				spin_lock_irq(&pgdat->lru_lock);
>  			} else
>  				list_add(&page->lru, &pages_to_free);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-18 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 10:50 [PATCH] mm: Simplify calling a compound page destructor Matthew Wilcox
2020-05-18  2:28 ` Anshuman Khandual
2020-05-18 10:00 ` Kirill A. Shutemov
2020-05-18 10:06 ` David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.