On Mon, Nov 23, 2020 at 8:07 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote: > > The problem is that PageWriteback is not accompanied by a page reference > (as the NOTE at the end of test_clear_page_writeback() acknowledges): as > soon as TestClearPageWriteback has been done, that page could be removed > from page cache, freed, and reused for something else by the time that > wake_up_page() is reached. Ugh. Would it be possible to instead just make PageWriteback take the ref? I don't hate your patch per se, but looking at that long explanation, and looking at the gyrations end_page_writeback() does, I go "why don't we do that?" IOW, why couldn't we just make the __test_set_page_writeback() increment the page count if the writeback flag wasn't already set, and then make the end_page_writeback() do a put_page() after it all? Linus