linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <weiyang@linux.vnet.ibm.com>
To: tj@kernel.org, cl@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: weiyang@linux.vnet.ibm.com
Subject: [PATCH 2/3] percpu: merge two loops when setting up group info
Date: Mon, 21 Oct 2013 16:58:12 +0800	[thread overview]
Message-ID: <1382345893-6644-2-git-send-email-weiyang@linux.vnet.ibm.com> (raw)
In-Reply-To: <1382345893-6644-1-git-send-email-weiyang@linux.vnet.ibm.com>

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-10-21  8:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21  8:58 [PATCH 1/3] percpu: stop the loop when a cpu belongs to a new group Wei Yang
2013-10-21  8:58 ` Wei Yang [this message]
2013-10-27 12:35   ` [PATCH 2/3] percpu: merge two loops when setting up group info Tejun Heo
2013-10-28  2:37     ` Wei Yang
2013-10-21  8:58 ` [PATCH 3/3] percpu: little optimization on calculating pcpu_unit_size Wei Yang
2013-10-27 12:36   ` Tejun Heo
2013-10-28  2:43     ` Wei Yang
2013-10-27 12:30 ` [PATCH 1/3] percpu: stop the loop when a cpu belongs to a new group Tejun Heo
2013-10-28  3:00   ` Wei Yang
2013-10-28 11:31     ` Tejun Heo
2013-10-28 15:17       ` Wei Yang
2013-11-20  3:00         ` Wei Yang
2013-11-20  5:51           ` Tejun Heo
2013-11-20  6:58             ` Wei Yang
2013-11-22 23:04             ` Tejun Heo
2013-11-24  1:48               ` Wei Yang

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=1382345893-6644-2-git-send-email-weiyang@linux.vnet.ibm.com \
    --to=weiyang@linux.vnet.ibm.com \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).