mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 15:40:56 +07:00
mm: use radix_tree_iter_retry()
Instead of a 'goto restart', we can now use radix_tree_iter_retry() to restart from our current position. This will make a difference when there are more ways to happen across an indirect pointer. And it eliminates some confusing gotos. [vbabka@suse.cz: remove now-obsolete-and-misleading comment] Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Konstantin Khlebnikov <khlebnikov@openvz.org> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c28f242063
commit
2cf938aae1
53
mm/filemap.c
53
mm/filemap.c
@ -1255,7 +1255,6 @@ unsigned find_get_entries(struct address_space *mapping,
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
restart:
|
||||
radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) {
|
||||
struct page *page;
|
||||
repeat:
|
||||
@ -1263,8 +1262,10 @@ unsigned find_get_entries(struct address_space *mapping,
|
||||
if (unlikely(!page))
|
||||
continue;
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page))
|
||||
goto restart;
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* A shadow entry of a recently evicted page, a swap
|
||||
* entry from shmem/tmpfs or a DAX entry. Return it
|
||||
@ -1317,7 +1318,6 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
restart:
|
||||
radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) {
|
||||
struct page *page;
|
||||
repeat:
|
||||
@ -1327,13 +1327,8 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
|
||||
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
/*
|
||||
* Transient condition which can only trigger
|
||||
* when entry at index 0 moves out of or back
|
||||
* to root: none yet gotten, safe to restart.
|
||||
*/
|
||||
WARN_ON(iter.index);
|
||||
goto restart;
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* A shadow entry of a recently evicted page,
|
||||
@ -1384,7 +1379,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
restart:
|
||||
radix_tree_for_each_contig(slot, &mapping->page_tree, &iter, index) {
|
||||
struct page *page;
|
||||
repeat:
|
||||
@ -1395,12 +1389,8 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
|
||||
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
/*
|
||||
* Transient condition which can only trigger
|
||||
* when entry at index 0 moves out of or back
|
||||
* to root: none yet gotten, safe to restart.
|
||||
*/
|
||||
goto restart;
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* A shadow entry of a recently evicted page,
|
||||
@ -1460,7 +1450,6 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
restart:
|
||||
radix_tree_for_each_tagged(slot, &mapping->page_tree,
|
||||
&iter, *index, tag) {
|
||||
struct page *page;
|
||||
@ -1471,12 +1460,8 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
|
||||
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
/*
|
||||
* Transient condition which can only trigger
|
||||
* when entry at index 0 moves out of or back
|
||||
* to root: none yet gotten, safe to restart.
|
||||
*/
|
||||
goto restart;
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* A shadow entry of a recently evicted page.
|
||||
@ -1539,7 +1524,6 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
restart:
|
||||
radix_tree_for_each_tagged(slot, &mapping->page_tree,
|
||||
&iter, start, tag) {
|
||||
struct page *page;
|
||||
@ -1549,12 +1533,8 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
|
||||
continue;
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
/*
|
||||
* Transient condition which can only trigger
|
||||
* when entry at index 0 moves out of or back
|
||||
* to root: none yet gotten, safe to restart.
|
||||
*/
|
||||
goto restart;
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2171,10 +2151,11 @@ void filemap_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
if (unlikely(!page))
|
||||
goto next;
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page))
|
||||
break;
|
||||
else
|
||||
goto next;
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (!page_cache_get_speculative(page))
|
||||
|
23
mm/shmem.c
23
mm/shmem.c
@ -383,13 +383,10 @@ unsigned long shmem_partial_swap_usage(struct address_space *mapping,
|
||||
|
||||
page = radix_tree_deref_slot(slot);
|
||||
|
||||
/*
|
||||
* This should only be possible to happen at index 0, so we
|
||||
* don't need to reset the counter, nor do we risk infinite
|
||||
* restarts.
|
||||
*/
|
||||
if (radix_tree_deref_retry(page))
|
||||
goto restart;
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (radix_tree_exceptional_entry(page))
|
||||
swapped++;
|
||||
@ -1951,8 +1948,10 @@ static void shmem_tag_pins(struct address_space *mapping)
|
||||
radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) {
|
||||
page = radix_tree_deref_slot(slot);
|
||||
if (!page || radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page))
|
||||
goto restart;
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
} else if (page_count(page) - page_mapcount(page) > 1) {
|
||||
spin_lock_irq(&mapping->tree_lock);
|
||||
radix_tree_tag_set(&mapping->page_tree, iter.index,
|
||||
@ -2006,8 +2005,10 @@ static int shmem_wait_for_pins(struct address_space *mapping)
|
||||
|
||||
page = radix_tree_deref_slot(slot);
|
||||
if (radix_tree_exception(page)) {
|
||||
if (radix_tree_deref_retry(page))
|
||||
goto restart;
|
||||
if (radix_tree_deref_retry(page)) {
|
||||
slot = radix_tree_iter_retry(&iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
page = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user