mm: debug fing_get_pages speculative restart From: Konstantin Khlebnikov Signed-off-by: Konstantin Khlebnikov --- mm/filemap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index b3a698e..5e3b3c2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -816,6 +816,7 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start, struct radix_tree_iter iter; void **slot; unsigned ret = 0; + int nr_found = 0; if (unlikely(!nr_pages)) return 0; @@ -847,6 +848,7 @@ repeat: continue; } + nr_found++; if (!page_cache_get_speculative(page)) goto repeat; @@ -862,6 +864,7 @@ repeat: } rcu_read_unlock(); + WARN_ON(!ret && nr_found); return ret; } @@ -883,6 +886,7 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, struct radix_tree_iter iter; void **slot; unsigned int ret = 0; + int nr_found = 0; if (unlikely(!nr_pages)) return 0; @@ -914,6 +918,7 @@ repeat: break; } + nr_found++; if (!page_cache_get_speculative(page)) goto repeat; @@ -939,6 +944,7 @@ repeat: break; } rcu_read_unlock(); + WARN_ON(!ret && nr_found); return ret; } EXPORT_SYMBOL(find_get_pages_contig); @@ -960,6 +966,7 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, struct radix_tree_iter iter; void **slot; unsigned ret = 0; + int nr_found = 0; if (unlikely(!nr_pages)) return 0; @@ -990,6 +997,7 @@ repeat: BUG(); } + nr_found++; if (!page_cache_get_speculative(page)) goto repeat; @@ -1009,6 +1017,7 @@ repeat: if (ret) *index = pages[ret - 1]->index + 1; + WARN_ON(!ret && nr_found); return ret; } EXPORT_SYMBOL(find_get_pages_tag);