On Fri, Dec 17, 2021 at 6:42 PM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > IOW, I think that this stupid (AND UNTESTED) patch should likely just > fix David's test-case with the hugepage and splice thing.. Looking at that patch, the page lock is entirely pointless. It existed because of that broken reuse_swap_page() that tried to count page mappings etc, but once you get rid of that - like we got rid of it for the regular pages - it's not even needed. So as we hold the page table lock, and see a page_count() of 1, we could be done without any page lock at all. So that whole trylock/unlock is actually unnecessary. That said, it's possibly woth re-using any swap cache pages at this point, and that would want the page lock. So some complexity in this area is likely worth it. Similar to how we did it in commit f4c4a3f48480 ("mm: free idle swap cache page after COW") for regular pages. So that patch is not great, but I think it works as a guiding one. And notice how *simple* it is. It doesn't require careful counting of swap entries that depend on page locking. Linus