Re: [LKML] Re: Infinite loop on boot in free_early_partial due tostart==end on tip/master

From: Tejun Heo
Date: Sat Mar 20 2010 - 03:23:23 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/