lkml.org 
[lkml]   [2010]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [LKML] Re: Infinite loop on boot in free_early_partial due to start==end on tip/master
Hello,

On 03/20/2010 06:17 AM, Yinghai Lu wrote:
>> #ifdef CONFIG_NO_BOOTMEM
>> u64 start = __pa(ptr);
>> u64 end = start + size;
>> - free_early_partial(start, end);
>> + if (start< end)
>> + free_early_partial(start, end);
>
> it seems we could remove this line
>
> Tejun, how this could happen? free zero range ?

Well, the generic code assumes that the arch free callback can handle
zero length free, so on rare cases where the amount of used percpu
area in the first chunk equals the unit size, it happily call
free_fn() with zero length expecting the free function to ignore it.
Hmmm... well, given that it's a arch dependent callback and occurrence
of zero length free would be fairly rare, I think it would be better
to make the generic code avoid calling free with zero length.

Does the following patch fix the problem?

diff --git a/mm/percpu.c b/mm/percpu.c
index 768419d..d8d3f70 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1929,7 +1929,9 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, ssize_t dyn_size,
}
/* copy and return the unused part */
memcpy(ptr, __per_cpu_load, ai->static_size);
- free_fn(ptr + size_sum, ai->unit_size - size_sum);
+ if (ai->unit_size > size_sum)
+ free_fn(ptr + size_sum,
+ ai->unit_size - size_sum);
}
}

--
tejun

\
 
 \ /
  Last update: 2010-03-20 08:25    [from the cache]
©2003-2011 Jasper Spaans