* [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM
@ 2007-12-25 13:21 Akinobu Mita
2007-12-26 3:47 ` Hugh Dickins
2008-01-07 8:59 ` Carsten Otte
0 siblings, 2 replies; 3+ messages in thread
From: Akinobu Mita @ 2007-12-25 13:21 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, linux-fsdevel, Carsten Otte
The use of get_zeroed_page() with __GFP_HIGHMEM is invalid.
Use alloc_page() with __GFP_ZERO instead of invalid get_zeroed_page().
(This patch is only compile tested)
Cc: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
mm/filemap_xip.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: 2.6-git/mm/filemap_xip.c
===================================================================
--- 2.6-git.orig/mm/filemap_xip.c
+++ 2.6-git/mm/filemap_xip.c
@@ -25,14 +25,15 @@ static struct page *__xip_sparse_page;
static struct page *xip_sparse_page(void)
{
if (!__xip_sparse_page) {
- unsigned long zeroes = get_zeroed_page(GFP_HIGHUSER);
- if (zeroes) {
+ struct page *page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
+
+ if (page) {
static DEFINE_SPINLOCK(xip_alloc_lock);
spin_lock(&xip_alloc_lock);
if (!__xip_sparse_page)
- __xip_sparse_page = virt_to_page(zeroes);
+ __xip_sparse_page = page;
else
- free_page(zeroes);
+ __free_page(page);
spin_unlock(&xip_alloc_lock);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM
2007-12-25 13:21 [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM Akinobu Mita
@ 2007-12-26 3:47 ` Hugh Dickins
2008-01-07 8:59 ` Carsten Otte
1 sibling, 0 replies; 3+ messages in thread
From: Hugh Dickins @ 2007-12-26 3:47 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, akpm, linux-fsdevel, Carsten Otte, Nick Piggin
On Tue, 25 Dec 2007, Akinobu Mita wrote:
> The use of get_zeroed_page() with __GFP_HIGHMEM is invalid.
> Use alloc_page() with __GFP_ZERO instead of invalid get_zeroed_page().
>
> (This patch is only compile tested)
>
> Cc: Carsten Otte <cotte@de.ibm.com>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Good find! You got me very worried, how this escaped testing before.
Presumed explanation: it hasn't been needed beyond s390, which has no
CONFIG_HIGHMEM; and it has never been tested with CONFIG_DEBUG_VM on.
Acked-by: Hugh Dickins <hugh@veritas.com>
But I haven't tested it either: let's wait for Carsten to report.
I believe Nick has changes on the way which will make it possible for
ordinary mortals to test XIP: here's a good argument to bring them on.
May I cross-reference my "prep_zero_page: remove bogus BUG_ON"
09f345da758fca1222b0971b65b2fddbdf78bb83 in 2.6.24-rc: that bogus
(actually VM_)BUG_ON would have stood in the way too, so there's
no point in backporting this without that. But if only non-HIGHMEM
architectures can have been using XIP, a backport is not essential.
Hugh
p.s. Nick's ZERO_PAGE changes, in 2.6.24-rc, actually cancel the need
for a special xip_sparse_page distinct from ZERO_PAGE. But let's not
become dependent on those: keep this doing it the way it does now.
>
> ---
> mm/filemap_xip.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> Index: 2.6-git/mm/filemap_xip.c
> ===================================================================
> --- 2.6-git.orig/mm/filemap_xip.c
> +++ 2.6-git/mm/filemap_xip.c
> @@ -25,14 +25,15 @@ static struct page *__xip_sparse_page;
> static struct page *xip_sparse_page(void)
> {
> if (!__xip_sparse_page) {
> - unsigned long zeroes = get_zeroed_page(GFP_HIGHUSER);
> - if (zeroes) {
> + struct page *page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
> +
> + if (page) {
> static DEFINE_SPINLOCK(xip_alloc_lock);
> spin_lock(&xip_alloc_lock);
> if (!__xip_sparse_page)
> - __xip_sparse_page = virt_to_page(zeroes);
> + __xip_sparse_page = page;
> else
> - free_page(zeroes);
> + __free_page(page);
> spin_unlock(&xip_alloc_lock);
> }
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM
2007-12-25 13:21 [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM Akinobu Mita
2007-12-26 3:47 ` Hugh Dickins
@ 2008-01-07 8:59 ` Carsten Otte
1 sibling, 0 replies; 3+ messages in thread
From: Carsten Otte @ 2008-01-07 8:59 UTC (permalink / raw)
To: Akinobu Mita, linux-kernel, akpm, linux-fsdevel, Carsten Otte
Akinobu Mita wrote:
> The use of get_zeroed_page() with __GFP_HIGHMEM is invalid.
> Use alloc_page() with __GFP_ZERO instead of invalid get_zeroed_page().
*Ouch*
Acked-by: Carsten Otte <cotte@de.ibm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-01-07 8:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-25 13:21 [PATCH] xip: fix get_zeroed_page with __GFP_HIGHMEM Akinobu Mita
2007-12-26 3:47 ` Hugh Dickins
2008-01-07 8:59 ` Carsten Otte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox