mm: implement find_get_pages_range()
Subsystems (2)
[email protected]
maintainerPATCH 50/119 mm: implement find_get_pages_range()
From: Jan Kara <[email protected]>
Subject: mm: implement find_get_pages_range()
Implement a variant of find_get_pages() that stops iterating at given index. This may be substantial performance gain if the mapping is sparse. See following commit for details. Furthermore lots of users of this function (through pagevec_lookup()) actually want a range lookup and all of them are currently open-coding this.
Also create corresponding pagevec_lookup_range() function.
Signed-off-by Jan Kara <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/pagemap.h | 12 +++++++++- include/linux/pagevec.h | 13 +++++++++-- mm/filemap.c | 42 +++++++++++++++++++++++++++----------- mm/swap.c | 22 ++++++++++++------- 4 files changed, 65 insertions(+), 24 deletions(-)
include/linux/pagemap.h renamed from include/linux/pagemap.h~mm-implement-find_get_pages_range +10 -2
@@ -353,8 +353,16 @@ struct page *find_lock_entry(struct addrunsigned find_get_entries (struct address_space *mapping,pgoff_t start,unsigned int nr_entries,struct page **entries,pgoff_t *indices); -unsigned find_get_pages (struct address_space *mapping,pgoff_t *start, -unsigned int nr_pages,struct page **pages); +unsigned find_get_pages_range (struct address_space *mapping,pgoff_t *start, +pgoff_t end,unsigned int nr_pages, +struct page **pages); +static inline unsigned find_get_pages (struct address_space *mapping, +pgoff_t *start,unsigned int nr_pages, +struct page **pages) +{ +return find_get_pages_range (mapping, start, (pgoff_t)-1 , nr_pages, + pages); +}unsigned find_get_pages_contig (struct address_space *mapping,pgoff_t start,unsigned int nr_pages,struct page **pages); unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
include/linux/pagevec.h renamed from include/linux/pagevec.h~mm-implement-find_get_pages_range +11 -2
@@ -27,8 +27,17 @@ unsigned pagevec_lookup_entries(struct p pgoff_t start, unsigned nr_entries, pgoff_t *indices);void pagevec_remove_exceptionals (struct pagevec *pvec); -unsigned pagevec_lookup (struct pagevec *pvec,struct address_space *mapping, -pgoff_t *start,unsigned nr_pages); +unsigned pagevec_lookup_range (struct pagevec *pvec, +struct address_space *mapping, +pgoff_t *start,pgoff_t end,unsigned nr_pages); +static inline unsigned pagevec_lookup (struct pagevec *pvec, +struct address_space *mapping, +pgoff_t *start,unsigned nr_pages) +{ +return pagevec_lookup_range (pvec, mapping, start, (pgoff_t)-1 , + nr_pages); +} +unsigned pagevec_lookup_tag (struct pagevec *pvec,struct address_space *mapping,pgoff_t *index,int tag,unsigned nr_pages);
mm/filemap.c renamed from mm/filemap.c~mm-implement-find_get_pages_range +30 -12
75 lines not on this page · raw message
mm/swap.c renamed from mm/swap.c~mm-implement-find_get_pages_range +14 -8
@@ -946,29 +946,35 @@ void pagevec_remove_exceptionals(struct }/** -* pagevec_lookup - gang pagecache lookup +* pagevec_lookup_range - gang pagecache lookup * @pvec: Where the resulting pages are placed * @mapping: The address_space to search * @start: The starting page index +* @end: The final page index * @nr_pages: The maximum number of pages * -* pagevec_lookup() will search for and return a group of up to @nr_pages pages -* in the mapping. The pages are placed in @pvec. pagevec_lookup() takes a +* pagevec_lookup_range() will search for and return a group of up to @nr_pages +* pages in the mapping starting from index @start and upto index @end +* (inclusive). The pages are placed in @pvec. pagevec_lookup() takes a * reference against the pages in @pvec. * * The search returns a group of mapping-contiguous pages with ascending * indexes. There may be holes in the indices due to not-present pages. We * also update @start to index the next page for the traversal. * -* pagevec_lookup() returns the number of pages which were found. +* pagevec_lookup_range() returns the number of pages which were found. If this +* number is smaller than @nr_pages, the end of specified range has been +* reached. */ -unsigned pagevec_lookup (struct pagevec *pvec,struct address_space *mapping, -pgoff_t *start,unsigned nr_pages) +unsigned pagevec_lookup_range (struct pagevec *pvec, +struct address_space *mapping,pgoff_t *start,pgoff_t end, +unsigned nr_pages) { - pvec->nr =find_get_pages (mapping, start, nr_pages, pvec->pages); + pvec->nr =find_get_pages_range (mapping, start, end, nr_pages, + pvec->pages);return pagevec_count (pvec); } -EXPORT_SYMBOL (pagevec_lookup); +EXPORT_SYMBOL (pagevec_lookup_range);unsigned pagevec_lookup_tag (struct pagevec *pvec,struct address_space *mapping,pgoff_t *index,int tag,unsigned nr_pages)
_