diff mbox series

[07/10] mm/truncate: Convert __invalidate_mapping_pages() to use a folio

Message ID 20220214200017.3150590-8-willy@infradead.org (mailing list archive)
State New
Headers show
Series Various fixes around invalidate_page() | expand

Commit Message

Matthew Wilcox Feb. 14, 2022, 8 p.m. UTC
Now we can call mapping_shrink_folio() instead of invalidate_inode_page()
and save a few calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/truncate.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Christoph Hellwig Feb. 15, 2022, 7:24 a.m. UTC | #1
On Mon, Feb 14, 2022 at 08:00:14PM +0000, Matthew Wilcox (Oracle) wrote:
> Now we can call mapping_shrink_folio() instead of invalidate_inode_page()
> and save a few calls to compound_head().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Miaohe Lin Feb. 15, 2022, 9:37 a.m. UTC | #2
On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote:
> Now we can call mapping_shrink_folio() instead of invalidate_inode_page()
> and save a few calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

LGTM. Thanks.

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

> ---
>  mm/truncate.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/mm/truncate.c b/mm/truncate.c
> index b1bdc61198f6..567557c36d45 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -505,27 +505,27 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
>  	folio_batch_init(&fbatch);
>  	while (find_lock_entries(mapping, index, end, &fbatch, indices)) {
>  		for (i = 0; i < folio_batch_count(&fbatch); i++) {
> -			struct page *page = &fbatch.folios[i]->page;
> +			struct folio *folio = fbatch.folios[i];
>  
> -			/* We rely upon deletion not changing page->index */
> +			/* We rely upon deletion not changing folio->index */
>  			index = indices[i];
>  
> -			if (xa_is_value(page)) {
> +			if (xa_is_value(folio)) {
>  				count += invalidate_exceptional_entry(mapping,
>  								      index,
> -								      page);
> +								      folio);
>  				continue;
>  			}
> -			index += thp_nr_pages(page) - 1;
> +			index += folio_nr_pages(folio) - 1;
>  
> -			ret = invalidate_inode_page(page);
> -			unlock_page(page);
> +			ret = mapping_shrink_folio(mapping, folio);
> +			folio_unlock(folio);
>  			/*
> -			 * Invalidation is a hint that the page is no longer
> +			 * Invalidation is a hint that the folio is no longer
>  			 * of interest and try to speed up its reclaim.
>  			 */
>  			if (!ret) {
> -				deactivate_file_page(page);
> +				deactivate_file_page(&folio->page);
>  				/* It is likely on the pagevec of a remote CPU */
>  				if (nr_pagevec)
>  					(*nr_pagevec)++;
>
diff mbox series

Patch

diff --git a/mm/truncate.c b/mm/truncate.c
index b1bdc61198f6..567557c36d45 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -505,27 +505,27 @@  static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
 	folio_batch_init(&fbatch);
 	while (find_lock_entries(mapping, index, end, &fbatch, indices)) {
 		for (i = 0; i < folio_batch_count(&fbatch); i++) {
-			struct page *page = &fbatch.folios[i]->page;
+			struct folio *folio = fbatch.folios[i];
 
-			/* We rely upon deletion not changing page->index */
+			/* We rely upon deletion not changing folio->index */
 			index = indices[i];
 
-			if (xa_is_value(page)) {
+			if (xa_is_value(folio)) {
 				count += invalidate_exceptional_entry(mapping,
 								      index,
-								      page);
+								      folio);
 				continue;
 			}
-			index += thp_nr_pages(page) - 1;
+			index += folio_nr_pages(folio) - 1;
 
-			ret = invalidate_inode_page(page);
-			unlock_page(page);
+			ret = mapping_shrink_folio(mapping, folio);
+			folio_unlock(folio);
 			/*
-			 * Invalidation is a hint that the page is no longer
+			 * Invalidation is a hint that the folio is no longer
 			 * of interest and try to speed up its reclaim.
 			 */
 			if (!ret) {
-				deactivate_file_page(page);
+				deactivate_file_page(&folio->page);
 				/* It is likely on the pagevec of a remote CPU */
 				if (nr_pagevec)
 					(*nr_pagevec)++;