Messages in this thread Patch in this message | | | From | Wei Yang <> | Subject | [PATCH 2/3] percpu: merge two loops when setting up group info | Date | Mon, 21 Oct 2013 16:58:12 +0800 |
| |
There are two loops setting up the group info of pcpu_alloc_info. They share the same logic, so merge them could be time efficient when there are many groups.
This patch merge these two loops into one.
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com> --- mm/percpu.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c index 536ca4f..4f710a4f 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1542,11 +1542,6 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info( return ERR_PTR(-ENOMEM); cpu_map = ai->groups[0].cpu_map; - for (group = 0; group < nr_groups; group++) { - ai->groups[group].cpu_map = cpu_map; - cpu_map += roundup(group_cnt[group], upa); - } - ai->static_size = static_size; ai->reserved_size = reserved_size; ai->dyn_size = dyn_size; @@ -1557,6 +1552,8 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info( for (group = 0, unit = 0; group_cnt[group]; group++) { struct pcpu_group_info *gi = &ai->groups[group]; + gi->cpu_map = cpu_map; + /* * Initialize base_offset as if all groups are located * back-to-back. The caller should update this to @@ -1568,6 +1565,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info( if (group_map[cpu] == group) gi->cpu_map[gi->nr_units++] = cpu; gi->nr_units = roundup(gi->nr_units, upa); + cpu_map += gi->nr_units; unit += gi->nr_units; } BUG_ON(unit != nr_units); -- 1.7.5.4
| |