From: Tejun Heo <tj@kernel.org>
To: mingo@redhat.com, hpa@zytor.com, tglx@linutronix.de,
benh@kernel.crashing.org, yinghai@kernel.org,
davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
x86@kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 4/8] memblock: Improve generic memblock_nid_range() using for_each_mem_pfn_range()
Date: Tue, 12 Jul 2011 10:46:31 +0200 [thread overview]
Message-ID: <1310460395-30913-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1310460395-30913-1-git-send-email-tj@kernel.org>
Given an address range, memblock_nid_range() determines the node the
start of the range belongs to and upto where the range stays in the
same node.
It's implemented by calling get_pfn_range_for_nid(), which determines
min and max pfns for a given node, for each node and testing whether
start address falls in there. This is not only inefficient but also
incorrect when nodes interleave as min-max ranges for nodes overlap.
This patch reimplements memblock_nid_range() using
for_each_mem_pfn_range(). It's simpler, walks the mem ranges once and
can find the exact range the start address falls in.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
mm/memblock.c | 20 +++-----------------
1 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index 0f9626f..97f3486 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -511,28 +511,14 @@ phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align)
phys_addr_t __weak __init memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid)
{
#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
- /*
- * This code originates from sparc which really wants use to walk by addresses
- * and returns the nid. This is not very convenient for early_pfn_map[] users
- * as the map isn't sorted yet, and it really wants to be walked by nid.
- *
- * For now, I implement the inefficient method below which walks the early
- * map multiple times. Eventually we may want to use an ARCH config option
- * to implement a completely different method for both case.
- */
unsigned long start_pfn, end_pfn;
int i;
- for (i = 0; i < MAX_NUMNODES; i++) {
- get_pfn_range_for_nid(i, &start_pfn, &end_pfn);
- if (start < PFN_PHYS(start_pfn) || start >= PFN_PHYS(end_pfn))
- continue;
- *nid = i;
- return min(end, PFN_PHYS(end_pfn));
- }
+ for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, nid)
+ if (start >= PFN_PHYS(start_pfn) && start < PFN_PHYS(end_pfn))
+ return min(end, PFN_PHYS(end_pfn));
#endif
*nid = 0;
-
return end;
}
--
1.7.6
next prev parent reply other threads:[~2011-07-12 8:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-12 8:46 [PATCHSET x86/mm] memblock, x86: Implement for_each_mem_pfn_range() and use it to improve memblock allocator Tejun Heo
2011-07-12 8:46 ` [PATCH 1/8] bootmem: Replace work_with_active_regions() with for_each_mem_pfn_range() Tejun Heo
2011-07-14 2:11 ` H. Peter Anvin
2011-07-14 7:44 ` Tejun Heo
2011-07-14 7:46 ` [PATCH UPDATED " Tejun Heo
2011-07-14 21:27 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 2/8] bootmem: Reimplement __absent_pages_in_range() using for_each_mem_pfn_range() Tejun Heo
2011-07-14 21:28 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 3/8] bootmem: Use for_each_mem_pfn_range() in page_alloc.c Tejun Heo
2011-07-14 21:28 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` Tejun Heo [this message]
2011-07-14 21:29 ` [tip:x86/memblock] memblock: Improve generic memblock_nid_range() using for_each_mem_pfn_range() tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 5/8] memblock: Don't allow archs to override memblock_nid_range() Tejun Heo
2011-07-14 21:29 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 6/8] memblock: Make memblock_alloc_[try_]nid() top-down Tejun Heo
2011-07-14 21:30 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 7/8] memblock: Separate out memblock_find_in_range_node() Tejun Heo
2011-07-14 21:30 ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12 8:46 ` [PATCH 8/8] memblock, x86: Replace memblock_x86_find_in_range_node() with generic memblock calls Tejun Heo
2011-07-14 21:31 ` [tip:x86/memblock] " tip-bot for 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=1310460395-30913-5-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.