Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
mm/khugepaged: remove reuse_swap_page() usage
reuse_swap_page() currently indicates if we can write to an anon page without COW. A COW is required if the page is shared by multiple processes (either already mapped or via swap entries) or if there is concurrent writeback that cannot tolerate concurrent page modifications. reuse_swap_page() doesn't check for pending references from other processes that already unmapped the page, however, is_refcount_suitable() essentially does the same thing. kuhgepaged is the last remaining reuse_swap_page() user. In the context of khugepaged, we are not actually going to write to the page and we don't really care about other processes mapping the page: for example, without swap, we don't check for multiple users. Having to guess due to lack of comments, the current logics really only wants to make sure that the page isn't in the swapcache and that it cannot be re-added to the swapcache by another process mapping the page until we're done. Instead of relying on reuse_swap_page(), let's unconditionally try_to_free_swap(), special casing PageKSM() just like reuse_swap_page() would have done. Maybe the PageKSM() isn't required, but that better be done separately. try_to_free_swap() will fail if there are still swap entries targeting the page or if the page is under writeback. We're keeping all pages locked and removed from the LRU until we actually perform the copy. So once we succeeded removing a page from the swapcache, it cannot be re-added until we're done copying. Add a comment stating that. Signed-off-by: David Hildenbrand <david@redhat.com>
- Loading branch information