Skip to content

Commit 96888e0

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm/shmem: use pagevec_lookup in shmem_unlock_mapping
The comment shows that the reason for using find_get_entries() is now stale; find_get_pages() will not return 0 if it hits a consecutive run of swap entries, and I don't believe it has since 2011. pagevec_lookup() is a simpler function to use than find_get_pages(), so use it instead. Link: https://lkml.kernel.org/r/20201112212641.27837-3-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Dave Chinner <dchinner@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Yang Shi <yang.shi@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c49f50d commit 96888e0

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

mm/shmem.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -842,24 +842,15 @@ unsigned long shmem_swap_usage(struct vm_area_struct *vma)
842842
void shmem_unlock_mapping(struct address_space *mapping)
843843
{
844844
struct pagevec pvec;
845-
pgoff_t indices[PAGEVEC_SIZE];
846845
pgoff_t index = 0;
847846

848847
pagevec_init(&pvec);
849848
/*
850849
* Minor point, but we might as well stop if someone else SHM_LOCKs it.
851850
*/
852851
while (!mapping_unevictable(mapping)) {
853-
/*
854-
* Avoid pagevec_lookup(): find_get_pages() returns 0 as if it
855-
* has finished, if it hits a row of PAGEVEC_SIZE swap entries.
856-
*/
857-
pvec.nr = find_get_entries(mapping, index,
858-
PAGEVEC_SIZE, pvec.pages, indices);
859-
if (!pvec.nr)
852+
if (!pagevec_lookup(&pvec, mapping, &index))
860853
break;
861-
index = indices[pvec.nr - 1] + 1;
862-
pagevec_remove_exceptionals(&pvec);
863854
check_move_unevictable_pages(&pvec);
864855
pagevec_release(&pvec);
865856
cond_resched();

0 commit comments

Comments
 (0)