Commit 860f2759 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds
Browse files

mm: shmem: use new radix tree iterator

In shmem_find_get_pages_and_swap(), use the faster radix tree iterator
construct from commit 78c1d784

 ("radix-tree: introduce bit-optimized
iterator").
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarHugh Dickins <hughd@google.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ef4d43a8
...@@ -335,19 +335,19 @@ static unsigned shmem_find_get_pages_and_swap(struct address_space *mapping, ...@@ -335,19 +335,19 @@ static unsigned shmem_find_get_pages_and_swap(struct address_space *mapping,
pgoff_t start, unsigned int nr_pages, pgoff_t start, unsigned int nr_pages,
struct page **pages, pgoff_t *indices) struct page **pages, pgoff_t *indices)
{ {
unsigned int i; void **slot;
unsigned int ret; unsigned int ret = 0;
unsigned int nr_found; struct radix_tree_iter iter;
if (!nr_pages)
return 0;
rcu_read_lock(); rcu_read_lock();
restart: restart:
nr_found = radix_tree_gang_lookup_slot(&mapping->page_tree, radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) {
(void ***)pages, indices, start, nr_pages);
ret = 0;
for (i = 0; i < nr_found; i++) {
struct page *page; struct page *page;
repeat: repeat:
page = radix_tree_deref_slot((void **)pages[i]); page = radix_tree_deref_slot(slot);
if (unlikely(!page)) if (unlikely(!page))
continue; continue;
if (radix_tree_exception(page)) { if (radix_tree_exception(page)) {
...@@ -364,17 +364,16 @@ repeat: ...@@ -364,17 +364,16 @@ repeat:
goto repeat; goto repeat;
/* Has the page moved? */ /* Has the page moved? */
if (unlikely(page != *((void **)pages[i]))) { if (unlikely(page != *slot)) {
page_cache_release(page); page_cache_release(page);
goto repeat; goto repeat;
} }
export: export:
indices[ret] = indices[i]; indices[ret] = iter.index;
pages[ret] = page; pages[ret] = page;
ret++; if (++ret == nr_pages)
break;
} }
if (unlikely(!ret && nr_found))
goto restart;
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment