* [PATCH] [percpu] Make the unit size of the first chunk the same as other chunks
@ 2014-10-25 15:05 Zhihui Zhang
2014-10-27 14:08 ` Tejun Heo
0 siblings, 1 reply; 5+ messages in thread
From: Zhihui Zhang @ 2014-10-25 15:05 UTC (permalink / raw)
To: tj, cl; +Cc: linux-kernel
Since we have already allocated the full unit size for the first chunk, we might as well use
it so that the unit size are the same for all chunks. The page first chunk allocator already
has this effect because it allocates one page at a time.
Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
---
mm/percpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index 014bab6..7242360 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1960,6 +1960,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
return PTR_ERR(ai);
size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
+ ai->dyn_size += ai->unit_size - size_sum;
areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *));
areas = memblock_virt_alloc_nopanic(areas_size, 0);
@@ -2006,9 +2007,8 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
free_fn(ptr, ai->unit_size);
continue;
}
- /* copy and return the unused part */
+ /* copy static data */
memcpy(ptr, __per_cpu_load, ai->static_size);
- free_fn(ptr + size_sum, ai->unit_size - size_sum);
}
}
@@ -2034,7 +2034,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
}
pr_info("PERCPU: Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
- PFN_DOWN(size_sum), base, ai->static_size, ai->reserved_size,
+ PFN_DOWN(ai->unit_size), base, ai->static_size, ai->reserved_size,
ai->dyn_size, ai->unit_size);
rc = pcpu_setup_first_chunk(ai, base);
--
1.8.1.2
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] [percpu] Make the unit size of the first chunk the same as other chunks
2014-10-25 15:05 [PATCH] [percpu] Make the unit size of the first chunk the same as other chunks Zhihui Zhang
@ 2014-10-27 14:08 ` Tejun Heo
2014-10-27 23:32 ` Zhihui Zhang
0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2014-10-27 14:08 UTC (permalink / raw)
To: Zhihui Zhang; +Cc: cl, linux-kernel
On Sat, Oct 25, 2014 at 11:05:58AM -0400, Zhihui Zhang wrote:
> Since we have already allocated the full unit size for the first chunk, we might as well use
> it so that the unit size are the same for all chunks. The page first chunk allocator already
> has this effect because it allocates one page at a time.
I'm not following. Where do we allocate the full unit size for the
first chunk?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [percpu] Make the unit size of the first chunk the same as other chunks
2014-10-27 14:08 ` Tejun Heo
@ 2014-10-27 23:32 ` Zhihui Zhang
2014-10-28 3:56 ` Tejun Heo
0 siblings, 1 reply; 5+ messages in thread
From: Zhihui Zhang @ 2014-10-27 23:32 UTC (permalink / raw)
To: Tejun Heo; +Cc: cl, linux-kernel
In pcpu_embed_first_chunk(), we allocate full unit size for each CPU
in the first chunk:
1981 /* allocate space for the whole group */
1982 ptr = alloc_fn(cpu, gi->nr_units * ai->unit_size,
atom_size);
1983 if (!ptr) {
1984 rc = -ENOMEM;
1985 goto out_free_areas;
1986 }
Later we freed unused part:
2009 /* copy and return the unused part */
2010 memcpy(ptr, __per_cpu_load, ai->static_size);
2011 free_fn(ptr + size_sum, ai->unit_size - size_sum);
I am trying to make each CPU to have a full unit size in the first
chunk, same as in all other chunks. Does this make sense?
-Zhihui
On Mon, Oct 27, 2014 at 10:08 AM, Tejun Heo <tj@kernel.org> wrote:
> On Sat, Oct 25, 2014 at 11:05:58AM -0400, Zhihui Zhang wrote:
>> Since we have already allocated the full unit size for the first chunk, we might as well use
>> it so that the unit size are the same for all chunks. The page first chunk allocator already
>> has this effect because it allocates one page at a time.
>
> I'm not following. Where do we allocate the full unit size for the
> first chunk?
>
> Thanks.
>
> --
> tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-30 0:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 15:05 [PATCH] [percpu] Make the unit size of the first chunk the same as other chunks Zhihui Zhang
2014-10-27 14:08 ` Tejun Heo
2014-10-27 23:32 ` Zhihui Zhang
2014-10-28 3:56 ` Tejun Heo
[not found] ` <CADFvMY+VUNaLhsJaPjH_DC91uJ8Hdgnaj9D44QEm0qV3Rr2-kA@mail.gmail.com>
[not found] ` <20141029041811.GA12382@htj.dyndns.org>
2014-10-30 0:07 ` Zhihui Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®