aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swap.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2014-04-03 17:47:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:00 -0400
commit0cd6144aadd2afd19d1aca880153530c52957604 (patch)
tree529df1dc75d6a58eff057dde5feb07cecf6ba527 /mm/swap.c
parente7b563bb2a6f4d974208da46200784b9c5b5a47e (diff)
mm + fs: prepare for non-page entries in page cache radix trees
shmem mappings already contain exceptional entries where swap slot information is remembered. To be able to store eviction information for regular page cache, prepare every site dealing with the radix trees directly to handle entries other than pages. The common lookup functions will filter out non-page entries and return NULL for page cache holes, just as before. But provide a raw version of the API which returns non-page entries as well, and switch shmem over to use it. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Rik van Riel <riel@redhat.com> Reviewed-by: Minchan Kim <minchan@kernel.org> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Bob Liu <bob.liu@oracle.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Dave Chinner <david@fromorbit.com> Cc: Greg Thelen <gthelen@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jan Kara <jack@suse.cz> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Luigi Semenzato <semenzato@google.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Metin Doslu <metin@citusdata.com> Cc: Michel Lespinasse <walken@google.com> Cc: Ozgun Erdogan <ozgun@citusdata.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Roman Gushchin <klamm@yandex-team.ru> Cc: Ryan Mallon <rmallon@gmail.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swap.c')
-rw-r--r--mm/swap.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/mm/swap.c b/mm/swap.c
index 0092097b3f4c..c8048d71c642 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -948,6 +948,57 @@ void __pagevec_lru_add(struct pagevec *pvec)
948EXPORT_SYMBOL(__pagevec_lru_add); 948EXPORT_SYMBOL(__pagevec_lru_add);
949 949
950/** 950/**
951 * pagevec_lookup_entries - gang pagecache lookup
952 * @pvec: Where the resulting entries are placed
953 * @mapping: The address_space to search
954 * @start: The starting entry index
955 * @nr_entries: The maximum number of entries
956 * @indices: The cache indices corresponding to the entries in @pvec
957 *
958 * pagevec_lookup_entries() will search for and return a group of up
959 * to @nr_entries pages and shadow entries in the mapping. All
960 * entries are placed in @pvec. pagevec_lookup_entries() takes a
961 * reference against actual pages in @pvec.
962 *
963 * The search returns a group of mapping-contiguous entries with
964 * ascending indexes. There may be holes in the indices due to
965 * not-present entries.
966 *
967 * pagevec_lookup_entries() returns the number of entries which were
968 * found.
969 */
970unsigned pagevec_lookup_entries(struct pagevec *pvec,
971 struct address_space *mapping,
972 pgoff_t start, unsigned nr_pages,
973 pgoff_t *indices)
974{
975 pvec->nr = find_get_entries(mapping, start, nr_pages,
976 pvec->pages, indices);
977 return pagevec_count(pvec);
978}
979
980/**
981 * pagevec_remove_exceptionals - pagevec exceptionals pruning
982 * @pvec: The pagevec to prune
983 *
984 * pagevec_lookup_entries() fills both pages and exceptional radix
985 * tree entries into the pagevec. This function prunes all
986 * exceptionals from @pvec without leaving holes, so that it can be
987 * passed on to page-only pagevec operations.
988 */
989void pagevec_remove_exceptionals(struct pagevec *pvec)
990{
991 int i, j;
992
993 for (i = 0, j = 0; i < pagevec_count(pvec); i++) {
994 struct page *page = pvec->pages[i];
995 if (!radix_tree_exceptional_entry(page))
996 pvec->pages[j++] = page;
997 }
998 pvec->nr = j;
999}
1000
1001/**
951 * pagevec_lookup - gang pagecache lookup 1002 * pagevec_lookup - gang pagecache lookup
952 * @pvec: Where the resulting pages are placed 1003 * @pvec: Where the resulting pages are placed
953 * @mapping: The address_space to search 1004 * @mapping: The address_space to search