* [PATCH] fix allocation done in get_free_all_memory_range()
@ 2010-03-26 16:41 Jan Beulich
2010-03-26 20:33 ` Yinghai Lu
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2010-03-26 16:41 UTC (permalink / raw)
To: yinghai, hpa; +Cc: linux-kernel
Even when get_max_mapped() returns a value beyond the DMA32 range,
this can't be taken to mean an alocation from that range will succeed.
Hence, the code should still fall back to an allocation starting at
the bottom of memory if the first one failed.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
---
kernel/early_res.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--- linux-2.6.34-rc2/kernel/early_res.c 2010-03-25 15:23:45.000000000 +0100
+++ 2.6.34-rc2-get_free_all_memory_range-retry-alloc/kernel/early_res.c 2010-03-26 14:49:41.000000000 +0100
@@ -387,9 +387,7 @@ static void __init subtract_early_res(st
int __init get_free_all_memory_range(struct range **rangep, int nodeid)
{
int i, count;
- u64 start = 0, end;
- u64 size;
- u64 mem;
+ u64 end, size, mem = -1ULL;
struct range *range;
int nr_range;
@@ -403,9 +401,11 @@ int __init get_free_all_memory_range(str
end = get_max_mapped();
#ifdef MAX_DMA32_PFN
if (end > (MAX_DMA32_PFN << PAGE_SHIFT))
- start = MAX_DMA32_PFN << PAGE_SHIFT;
+ mem = find_fw_memmap_area(MAX_DMA32_PFN << PAGE_SHIFT, end,
+ size, sizeof(struct range));
#endif
- mem = find_fw_memmap_area(start, end, size, sizeof(struct range));
+ if (mem == -1ULL)
+ mem = find_fw_memmap_area(0, end, size, sizeof(struct range));
if (mem == -1ULL)
panic("can not find more space for range free");
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fix allocation done in get_free_all_memory_range()
2010-03-26 16:41 [PATCH] fix allocation done in get_free_all_memory_range() Jan Beulich
@ 2010-03-26 20:33 ` Yinghai Lu
0 siblings, 0 replies; 2+ messages in thread
From: Yinghai Lu @ 2010-03-26 20:33 UTC (permalink / raw)
To: Jan Beulich; +Cc: hpa, linux-kernel
On 03/26/2010 09:41 AM, Jan Beulich wrote:
> Even when get_max_mapped() returns a value beyond the DMA32 range,
> this can't be taken to mean an alocation from that range will succeed.
> Hence, the code should still fall back to an allocation starting at
> the bottom of memory if the first one failed.
>
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
>
> ---
> kernel/early_res.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> --- linux-2.6.34-rc2/kernel/early_res.c 2010-03-25 15:23:45.000000000 +0100
> +++ 2.6.34-rc2-get_free_all_memory_range-retry-alloc/kernel/early_res.c 2010-03-26 14:49:41.000000000 +0100
> @@ -387,9 +387,7 @@ static void __init subtract_early_res(st
> int __init get_free_all_memory_range(struct range **rangep, int nodeid)
> {
> int i, count;
> - u64 start = 0, end;
> - u64 size;
> - u64 mem;
> + u64 end, size, mem = -1ULL;
> struct range *range;
> int nr_range;
>
> @@ -403,9 +401,11 @@ int __init get_free_all_memory_range(str
> end = get_max_mapped();
> #ifdef MAX_DMA32_PFN
> if (end > (MAX_DMA32_PFN << PAGE_SHIFT))
> - start = MAX_DMA32_PFN << PAGE_SHIFT;
> + mem = find_fw_memmap_area(MAX_DMA32_PFN << PAGE_SHIFT, end,
> + size, sizeof(struct range));
> #endif
> - mem = find_fw_memmap_area(start, end, size, sizeof(struct range));
> + if (mem == -1ULL)
> + mem = find_fw_memmap_area(0, end, size, sizeof(struct range));
> if (mem == -1ULL)
> panic("can not find more space for range free");
Acked-by: Yinghai Lu <yinghai@kernel.org>
Thanks for catching it.
Yinghai
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-03-26 20:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-26 16:41 [PATCH] fix allocation done in get_free_all_memory_range() Jan Beulich
2010-03-26 20:33 ` Yinghai Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).