* [PATCH] Fix memory hotplug and bouncing in block layer
@ 2008-03-06 20:41 Andi Kleen
2008-03-08 5:33 ` Yasunori Goto
0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2008-03-06 20:41 UTC (permalink / raw)
To: axboe, linux-kernel
Fix memory hotplug and bouncing in block layer
Only noticed this while hacking something else, no test case.
blk_max_low_pfn is initialized once at bootup by the block layer
from max_low_pfn. But max_low_pfn is not necessarily constant
over the runtime of the system when you consider memory hotplug.
What could happen if that someone adds memory later the block
layer wouldn't get updated and then start bouncing memory unnecessarily.
Also on 64bit blk_max_low_pfn actually isn't needed because
it just disables bouncing essentially and there is no highmem.
And nobody can pass pfns > max_low_pfn to the block layer,
because those wouldn't have a struct page and I suspect
block layer wouldn't be very happy without that.
So set BLK_BOUNCE_HIGH to infinity (-1ULL) on 64bit. That
avoids the problem of having to update it on memory hotadd.
On 32bit I kept the same behaviour because at least on i386
memory hotadd only adds HIGHMEM, never lowmem.
BLK_BOUNCE_ANY is always set to infinity on both 32 and 64bit.
Signed-off-by: Andi Kleen <ak@suse.de>
---
include/linux/blkdev.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Index: linux/include/linux/blkdev.h
===================================================================
--- linux.orig/include/linux/blkdev.h
+++ linux/include/linux/blkdev.h
@@ -532,8 +532,13 @@ extern unsigned long blk_max_low_pfn, bl
* BLK_BOUNCE_ANY : don't bounce anything
* BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary
*/
+
+#if BITS_PER_LONG == 32
#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
-#define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT)
+#else
+#define BLK_BOUNCE_HIGH -1ULL
+#endif
+#define BLK_BOUNCE_ANY (-1ULL)
#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
/*
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix memory hotplug and bouncing in block layer
2008-03-06 20:41 [PATCH] Fix memory hotplug and bouncing in block layer Andi Kleen
@ 2008-03-08 5:33 ` Yasunori Goto
0 siblings, 0 replies; 2+ messages in thread
From: Yasunori Goto @ 2008-03-08 5:33 UTC (permalink / raw)
To: Andi Kleen; +Cc: axboe, linux-kernel
Oh, thanks for your fixing.
Acked-by: Yasunori Goto <y-goto@jp.fujitsu.com>
> Fix memory hotplug and bouncing in block layer
>
> Only noticed this while hacking something else, no test case.
>
> blk_max_low_pfn is initialized once at bootup by the block layer
> from max_low_pfn. But max_low_pfn is not necessarily constant
> over the runtime of the system when you consider memory hotplug.
> What could happen if that someone adds memory later the block
> layer wouldn't get updated and then start bouncing memory unnecessarily.
>
> Also on 64bit blk_max_low_pfn actually isn't needed because
> it just disables bouncing essentially and there is no highmem.
> And nobody can pass pfns > max_low_pfn to the block layer,
> because those wouldn't have a struct page and I suspect
> block layer wouldn't be very happy without that.
>
> So set BLK_BOUNCE_HIGH to infinity (-1ULL) on 64bit. That
> avoids the problem of having to update it on memory hotadd.
>
> On 32bit I kept the same behaviour because at least on i386
> memory hotadd only adds HIGHMEM, never lowmem.
>
> BLK_BOUNCE_ANY is always set to infinity on both 32 and 64bit.
>
> Signed-off-by: Andi Kleen <ak@suse.de>
>
> ---
> include/linux/blkdev.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> Index: linux/include/linux/blkdev.h
> ===================================================================
> --- linux.orig/include/linux/blkdev.h
> +++ linux/include/linux/blkdev.h
> @@ -532,8 +532,13 @@ extern unsigned long blk_max_low_pfn, bl
> * BLK_BOUNCE_ANY : don't bounce anything
> * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary
> */
> +
> +#if BITS_PER_LONG == 32
> #define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
> -#define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT)
> +#else
> +#define BLK_BOUNCE_HIGH -1ULL
> +#endif
> +#define BLK_BOUNCE_ANY (-1ULL)
> #define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
--
Yasunori Goto
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-08 5:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-06 20:41 [PATCH] Fix memory hotplug and bouncing in block layer Andi Kleen
2008-03-08 5:33 ` Yasunori Goto
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.