[PATCH] mm: swap: avoid to writepage when a page is !PageSwapCache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is race between do_swap_page() and swap_writepage(), if
do_swap_page() had deleted a page from swap cache, there is no need
to write it. So changing the ret of try_to_free_swap() to make
swap_writepage() aware of this scene.

Signed-off-by: Liu Ping Fan <pingfank@xxxxxxxxxxxxxxxxxx>
---
 mm/swapfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 4c524f7..9d80671 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -910,7 +910,7 @@ int try_to_free_swap(struct page *page)
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 
 	if (!PageSwapCache(page))
-		return 0;
+		return -1;
 	if (PageWriteback(page))
 		return 0;
 	if (page_swapcount(page))
-- 
1.8.1.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]