Skip to contentSkip to conversation

mm: Convert delete_from_page_cache_batch() to pagevec

PATCH In review Jan Kara 2 participants 2 messages Oct 18, 2017

Subsystems (3)
lore
Share & tools
lore

Jan Kara

author maintainer
#0 lore raw

PATCH 1/1 mm: Convert delete_from_page_cache_batch() to pagevec

---
 include/linux/pagemap.h |  6 ++++--
 mm/filemap.c            | 43 +++++++++++++++++++++----------------------
 mm/truncate.c           | 18 +++++++++---------
 3 files changed, 34 insertions(+), 33 deletions(-)

This is a patch to use pagevec instead of page array - to be folded into the last patch of my batched truncate series: "mm: Batch radix tree operations when truncating pages". Thanks!

include/linux/pagemap.h +4 -2
index e857c62aef06..280aabe3ab75 100644
@@ -616,6 +616,8 @@ static inline int fault_in_pages_readable(const char __user *uaddr, int size)
 	return 0;
 }
 
+struct pagevec;
+
 int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
 				pgoff_t index, gfp_t gfp_mask);
 int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
@@ -623,8 +625,8 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 extern void delete_from_page_cache(struct page *page);
 extern void __delete_from_page_cache(struct page *page, void *shadow);
 int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
-void delete_from_page_cache_batch(struct address_space *mapping, int count,
-				  struct page **pages);
+void delete_from_page_cache_batch(struct address_space *mapping,
+				  struct pagevec *pvec);
 
 /*
  * Like add_to_page_cache_locked, but used to add newly allocated pages:
mm/filemap.c +21 -22

84 lines not on this page · raw message

mm/truncate.c +9 -9
index 3dfa2d5e642e..4a39a3150ee2 100644
@@ -297,11 +297,11 @@ void truncate_inode_pages_range(struct address_space *mapping,
 		/*
 		 * Pagevec array has exceptional entries and we may also fail
 		 * to lock some pages. So we store pages that can be deleted
-		 * in an extra array.
+		 * in a new pagevec.
 		 */
-		struct page *pages[PAGEVEC_SIZE];
-		int batch_count = 0;
+		struct pagevec locked_pvec;
 
+		pagevec_init(&locked_pvec, 0);
 		for (i = 0; i < pagevec_count(&pvec); i++) {
 			struct page *page = pvec.pages[i];
 
@@ -327,13 +327,13 @@ void truncate_inode_pages_range(struct address_space *mapping,
 				unlock_page(page);
 				continue;
 			}
-			pages[batch_count++] = page;
+			pagevec_add(&locked_pvec, page);
 		}
-		for (i = 0; i < batch_count; i++)
-			truncate_cleanup_page(mapping, pages[i]);
-		delete_from_page_cache_batch(mapping, batch_count, pages);
-		for (i = 0; i < batch_count; i++)
-			unlock_page(pages[i]);
+		for (i = 0; i < pagevec_count(&locked_pvec); i++)
+			truncate_cleanup_page(mapping, locked_pvec.pages[i]);
+		delete_from_page_cache_batch(mapping, &locked_pvec);
+		for (i = 0; i < pagevec_count(&locked_pvec); i++)
+			unlock_page(locked_pvec.pages[i]);
 		pagevec_remove_exceptionals(&pvec);
 		pagevec_release(&pvec);
 		cond_resched();
Signature · 7 lines
2.12.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw
Quoted 3 lines · On Wed, 18 Oct 2017 13:16:48 +0200 Jan Kara <[email protected]> wrote:

This is a patch to use pagevec instead of page array - to be folded into the last patch of my batched truncate series: "mm: Batch radix tree operations when truncating pages". Thanks!

That shrinks .text by 112 bytes. Huh.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>