From: Andy Whitcroft <apw@shadowen.org>
To: Andy Whitcroft <apw@shadowen.org>
Cc: Michael Ellerman <michael@ellerman.id.au>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, haveblue@us.ibm.com,
kravetz@us.ibm.com
Subject: Re: [PATCH] SPARSEMEM + NUMA can't handle unaligned memory regions?
Date: Tue, 09 May 2006 15:28:03 +0100 [thread overview]
Message-ID: <4460A6F3.5060303@shadowen.org> (raw)
In-Reply-To: <44609A7B.7010103@shadowen.org>
[-- Attachment #1: Type: text/plain, Size: 935 bytes --]
Andy Whitcroft wrote:
> We see to have a few options:
>
> 1) default the nid to something -- right now most of the non powerpc
> architectures return 0 when the nid cannot be found thus avoiding this
> panic.
>
> 2) nid search -- we can do pretty much what is in this patch probabally
> with some optimisations like trying the first and last pfn in the
> section first.
>
> 3) record the nid -- when we record the memory present in the system we
> are passed the nid.
>
> Somehow the last of these seems the most logical given we have the
> correct information at the time we record that we need to instantiate
> the section. So I had a quick go at something which seems to have come
> out pretty clean. Attached is a completly untested patch to show what I
> am proposing.
Ok. Attached is a version which builds and boots. The patch looks
pretty simple. Michael could you give it a spin on the broken machine
for me.
-apw
[-- Attachment #2: sparsemem-record-nid-during-memory-present --]
[-- Type: text/plain, Size: 2002 bytes --]
sparsemem record nid during memory present
Record the node id as we mark sections for instantiation. Use this
nid during instantiation to direct allocations.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
sparse.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff -upN reference/mm/sparse.c current/mm/sparse.c
--- reference/mm/sparse.c
+++ current/mm/sparse.c
@@ -102,6 +102,22 @@ int __section_nr(struct mem_section* ms)
return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
}
+/*
+ * During early boot we need to record the nid from which we will
+ * later allocate the section mem_map. Encode this into the section
+ * pointer. Overload the section_mem_map with this information.
+ */
+static inline unsigned long sparse_encode_early_nid(int nid)
+{
+ return (nid << SECTION_MAP_LAST_BIT);
+}
+
+static inline int sparse_early_nid(struct mem_section *section)
+{
+ unsigned long nid = section->section_mem_map;
+ return (nid >> SECTION_MAP_LAST_BIT);
+}
+
/* Record a memory area against a node. */
void memory_present(int nid, unsigned long start, unsigned long end)
{
@@ -116,7 +132,8 @@ void memory_present(int nid, unsigned lo
ms = __nr_to_section(section);
if (!ms->section_mem_map)
- ms->section_mem_map = SECTION_MARKED_PRESENT;
+ ms->section_mem_map = sparse_encode_early_nid(nid) |
+ SECTION_MARKED_PRESENT;
}
}
@@ -167,6 +184,7 @@ static int sparse_init_one_section(struc
if (!valid_section(ms))
return -EINVAL;
+ ms->section_mem_map &= ~SECTION_MAP_MASK;
ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum);
return 1;
@@ -175,8 +193,8 @@ static int sparse_init_one_section(struc
static struct page *sparse_early_mem_map_alloc(unsigned long pnum)
{
struct page *map;
- int nid = early_pfn_to_nid(section_nr_to_pfn(pnum));
struct mem_section *ms = __nr_to_section(pnum);
+ int nid = sparse_early_nid(ms);
map = alloc_remap(nid, sizeof(struct page) * PAGES_PER_SECTION);
if (map)
next prev parent reply other threads:[~2006-05-09 14:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-09 7:03 Michael Ellerman
2006-05-09 8:32 ` Andy Whitcroft
2006-05-09 9:11 ` Michael Ellerman
2006-05-09 10:24 ` Andy Whitcroft
2006-05-09 13:34 ` Andy Whitcroft
2006-05-09 14:28 ` Andy Whitcroft [this message]
2006-05-09 16:26 ` Dave Hansen
2006-05-09 16:31 ` Andy Whitcroft
2006-05-10 6:06 ` Michael Ellerman
2006-05-10 10:51 ` [PATCH] sparsemem record nid during memory present Andy Whitcroft
2006-05-09 16:05 ` [PATCH] SPARSEMEM + NUMA can't handle unaligned memory regions? mike kravetz
2006-05-09 16:14 ` Andy Whitcroft
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=4460A6F3.5060303@shadowen.org \
--to=apw@shadowen.org \
--cc=akpm@osdl.org \
--cc=haveblue@us.ibm.com \
--cc=kravetz@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@ellerman.id.au \
/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
Powered by JetHome