From: Tejun Heo <tj@kernel.org>
To: "Pavel V. Panteleev" <pp_84@mail.ru>
Cc: linux-mm <linux-mm@kvak.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
andi <andi@firstfloor.org>
Subject: Re: percpu allocator
Date: Fri, 27 Apr 2012 07:17:04 -0700 [thread overview]
Message-ID: <20120427141704.GH27486@google.com> (raw)
In-Reply-To: <E1SNhwY-0007ui-V7.pp_84-mail-ru@f220.mail.ru>
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
next parent reply other threads:[~2012-04-27 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1SNhwY-0007ui-V7.pp_84-mail-ru@f220.mail.ru>
2012-04-27 14:17 ` Tejun Heo [this message]
2012-04-27 15:42 ` [PATCH] percpu: pcpu_embed_first_chunk() should free unused parts after all allocs are complete Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120427141704.GH27486@google.com \
--to=tj@kernel.org \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvak.org \
--cc=pp_84@mail.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox