summaryrefslogtreecommitdiffstats
path: root/mm/khugepaged.c
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2017-12-04 15:06:23 -0500
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:38 -0400
commit85b392dbace77bf91050e6e07f3dd0f262e4babf (patch)
tree3bd63328b8e6d495febe03dd73018fc156e8f0a0 /mm/khugepaged.c
parent77da9389b9d5f07d54fda092d1ab56002ec0019a (diff)
downloadlinux-85b392dbace77bf91050e6e07f3dd0f262e4babf.tar.bz2
mm: Convert khugepaged_scan_shmem to XArray
Slightly shorter and easier to read code. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'mm/khugepaged.c')
-rw-r--r--mm/khugepaged.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 9610e8cba545..c13625c1ad5e 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1542,8 +1542,7 @@ static void khugepaged_scan_shmem(struct mm_struct *mm,
pgoff_t start, struct page **hpage)
{
struct page *page = NULL;
- struct radix_tree_iter iter;
- void **slot;
+ XA_STATE(xas, &mapping->i_pages, start);
int present, swap;
int node = NUMA_NO_NODE;
int result = SCAN_SUCCEED;
@@ -1552,17 +1551,11 @@ static void khugepaged_scan_shmem(struct mm_struct *mm,
swap = 0;
memset(khugepaged_node_load, 0, sizeof(khugepaged_node_load));
rcu_read_lock();
- radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) {
- if (iter.index >= start + HPAGE_PMD_NR)
- break;
-
- page = radix_tree_deref_slot(slot);
- if (radix_tree_deref_retry(page)) {
- slot = radix_tree_iter_retry(&iter);
+ xas_for_each(&xas, page, start + HPAGE_PMD_NR - 1) {
+ if (xas_retry(&xas, page))
continue;
- }
- if (radix_tree_exception(page)) {
+ if (xa_is_value(page)) {
if (++swap > khugepaged_max_ptes_swap) {
result = SCAN_EXCEED_SWAP_PTE;
break;
@@ -1601,7 +1594,7 @@ static void khugepaged_scan_shmem(struct mm_struct *mm,
present++;
if (need_resched()) {
- slot = radix_tree_iter_resume(slot, &iter);
+ xas_pause(&xas);
cond_resched_rcu();
}
}