diff options
author | Matthew Wilcox <willy@infradead.org> | 2017-12-04 11:28:00 +0300 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-10-21 17:46:40 +0300 |
commit | 7ae3424fb4b5587d9b2db12a4b1040c52073dd5c (patch) | |
tree | 0b827f9645b9aa2b1cd40dd3df28256038f3f8a4 | |
parent | c121d3bb717ee932caf031c6a7923547f7f83163 (diff) | |
download | linux-7ae3424fb4b5587d9b2db12a4b1040c52073dd5c.tar.xz |
shmem: Convert shmem_partial_swap_usage to XArray
Simpler code because the xarray takes care of things like the limit and
dereferencing the slot.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r-- | mm/shmem.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 8e9bbfb7ed15..5588205f4259 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -676,29 +676,19 @@ static int shmem_free_swap(struct address_space *mapping, unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end) { - struct radix_tree_iter iter; - void __rcu **slot; + XA_STATE(xas, &mapping->i_pages, start); struct page *page; unsigned long swapped = 0; rcu_read_lock(); - - radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { - if (iter.index >= end) - break; - - page = radix_tree_deref_slot(slot); - - if (radix_tree_deref_retry(page)) { - slot = radix_tree_iter_retry(&iter); + xas_for_each(&xas, page, end - 1) { + if (xas_retry(&xas, page)) continue; - } - if (xa_is_value(page)) swapped++; if (need_resched()) { - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } } |