linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix can_share_swap_page() when !CONFIG_SWAP
@ 2006-05-08  1:17 Hua Zhong
  2006-05-08  5:18 ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Hua Zhong @ 2006-05-08  1:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, linux-mm

Hi,

can_share_swap_page() is used to check if the page has the last reference. This avoids allocating a new page for COW if it's the last page.

However, if CONFIG_SWAP is not set, can_share_swap_page() is defined as 0, thus always causes a copy for the last COW page. The below simple patch fixes it.

I'm not sure if it's the best fix. Maybe we should rename can_share_swap_page() and move it out of swapfile.c. Comments?

Signed-off-by: Hua Zhong <hzhong@gmail.com>

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 5b1fdf1..f03c247 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -296,7 +296,7 @@ #define swap_free(swp)				/*NOTHING*/
 #define read_swap_cache_async(swp,vma,addr)	NULL
 #define lookup_swap_cache(swp)			NULL
 #define valid_swaphandles(swp, off)		0
-#define can_share_swap_page(p)			0
+#define can_share_swap_page(p)			(page_mapcount(p) == 1)
 #define move_to_swap_cache(p, swp)		1
 #define move_from_swap_cache(p, i, m)		1
 #define __delete_from_swap_cache(p)		/*NOTHING*/

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-09 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-08  1:17 [PATCH] fix can_share_swap_page() when !CONFIG_SWAP Hua Zhong
2006-05-08  5:18 ` Nick Piggin
2006-05-08 12:45   ` Hugh Dickins
2006-05-09  1:59     ` Nick Piggin
2006-05-09 11:25       ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox