* [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
* Re: [PATCH] fix can_share_swap_page() when !CONFIG_SWAP
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
0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2006-05-08 5:18 UTC (permalink / raw)
To: Hua Zhong; +Cc: linux-kernel, akpm, linux-mm, Hugh Dickins
Hua Zhong wrote:
>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?
>
Looks like a good patch, nice catch. You should run it past Hugh but tend to
agree it would be nice to reuse the out of line can_share_swap_page,
which would
fold beautifully with PageSwapCache a constant 0.
Nick
--
Send instant messages to your online friends http://au.messenger.yahoo.com
--
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
* Re: [PATCH] fix can_share_swap_page() when !CONFIG_SWAP
2006-05-08 5:18 ` Nick Piggin
@ 2006-05-08 12:45 ` Hugh Dickins
2006-05-09 1:59 ` Nick Piggin
0 siblings, 1 reply; 5+ messages in thread
From: Hugh Dickins @ 2006-05-08 12:45 UTC (permalink / raw)
To: Nick Piggin; +Cc: Hua Zhong, linux-kernel, akpm, linux-mm
On Mon, 8 May 2006, Nick Piggin wrote:
> Hua Zhong wrote:
> >
> >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?
>
> Looks like a good patch, nice catch. You should run it past Hugh but tend to
> agree it would be nice to reuse the out of line can_share_swap_page, which
> would fold beautifully with PageSwapCache a constant 0.
True; but I think Hua's patch is good as is for now, to fix
that inefficiency. I do agree (as you know) that there's scope for
cleanup there, and that that function is badly named; but I'm still
unprepared to embark on the cleanup, so let's just get the fix in.
Hugh
--
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
* Re: [PATCH] fix can_share_swap_page() when !CONFIG_SWAP
2006-05-08 12:45 ` Hugh Dickins
@ 2006-05-09 1:59 ` Nick Piggin
2006-05-09 11:25 ` Hugh Dickins
0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2006-05-09 1:59 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Hua Zhong, linux-kernel, akpm, linux-mm
Hugh Dickins wrote:
>On Mon, 8 May 2006, Nick Piggin wrote:
>
>>Looks like a good patch, nice catch. You should run it past Hugh but tend to
>>agree it would be nice to reuse the out of line can_share_swap_page, which
>>would fold beautifully with PageSwapCache a constant 0.
>>
>
>True; but I think Hua's patch is good as is for now, to fix
>that inefficiency. I do agree (as you know) that there's scope for
>cleanup there, and that that function is badly named; but I'm still
>unprepared to embark on the cleanup, so let's just get the fix in.
>
Sure. Queue it up for 2.6.18?
--
Send instant messages to your online friends http://au.messenger.yahoo.com
--
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
* Re: [PATCH] fix can_share_swap_page() when !CONFIG_SWAP
2006-05-09 1:59 ` Nick Piggin
@ 2006-05-09 11:25 ` Hugh Dickins
0 siblings, 0 replies; 5+ messages in thread
From: Hugh Dickins @ 2006-05-09 11:25 UTC (permalink / raw)
To: Nick Piggin; +Cc: Hua Zhong, linux-kernel, akpm, linux-mm
On Tue, 9 May 2006, Nick Piggin wrote:
> Hugh Dickins wrote:
> >
> >True; but I think Hua's patch is good as is for now, to fix
> >that inefficiency. I do agree (as you know) that there's scope for
> >cleanup there, and that that function is badly named; but I'm still
> >unprepared to embark on the cleanup, so let's just get the fix in.
>
> Sure. Queue it up for 2.6.18?
I'd be perfectly happy for Hua's one-liner to go into 2.6.17;
but that's up to Andrew.
Hugh
--
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