Wait, what? On Thu, Apr 29, 2021 at 10:55 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > > + if (!mapping_needs_writeback(mapping)) > + return false; > + if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && > + !mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) > + return false; > + if (end_byte < start_byte) > + return false; Ok, good, get rid of the trivial cases first. > + rcu_read_lock(); > + xas_for_each(&xas, page, max) { > + if (xas_retry(&xas, page)) > + continue; > + if (xa_is_value(page)) > + continue; > + if (PageDirty(page) || PageLocked(page) || PageWriteback(page)) > + break; > + } > + rcu_read_unlock(); Whee. This looks very very expensive indeed. Why is is going to each page, why does it care about locked when the simple early cases did not? Why isn't this just using xas_for_each_marked(), or maybe even just a single "xa_find()", since all it cares about is "is _any_ page.." Maybe I'm missing something, but this really does look potentially horrendously slow. Jens/Willy? Linus