Re: percpu allocator
From: Tejun Heo
Date: Fri Apr 27 2012 - 10:17:10 EST
Hello,
On Fri, Apr 27, 2012 at 01:58:26PM +0400, Pavel V. Panteleev wrote:
> I have the following problem with pcpu embed allocator in kernel
> 2.6.33.1. pcpu_embed_first_chunk() function allocate only size_sum =
> (ai->static_size + ai->reserved_size + ai->dyn_size) for an unit in
> the group. So, for 4 groups (1 unit in each) and with memory only on
> the first node I have the following:
>
> pcpu_embed_first_chunk(): ai->groups[0].base_offset=0x0
> pcpu_embed_first_chunk(): ai->groups[1].base_offset=0xa000
> pcpu_embed_first_chunk(): ai->groups[2].base_offset=0x14000
> pcpu_embed_first_chunk(): ai->groups[3].base_offset=0x1e000
>
> pcpu_embed_first_chunk(): ai->unit_size=0x10000
>
> It means, that for each group memory of size_sum=0xa000 is used
> only. So, in the case of memory only on the first node, memory for
> the following group will be allocated near the memory of the
> previous group. Even though memory of size_sum=0xa000 is used only,
> but ai->unit_size=0x10000.
>
> After filling group_offsets and group_sizes in
> pcpu_setup_first_chunk() function we have, that (group_offsets[i] +
> group_sizes[i]) can be larger than group_offsets[i+1]. But in
> pcpu_get_vm_areas() function there is checker, which tell us, that
> such situation is impossible:
>
> BUG_ON(start2 >= start && start2 < end);
>
> May be I should not use embed allocator in such situation?
Nice catch. pcpu_embed_first_chunk() allocates full unit and then
free whatever is unused (for alignment, IIRC) before proceeding to the
next group. What it should do is first allocate and prepare all
groups and then free whatever is unused. I'll write up a patch.
Thanks.
--
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/