From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org,
"Michael Ellerman" <mpe@ellerman.id.au>,
linux-mm@kvack.org, "Joel Stanley" <joel@jms.id.au>,
"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Paul Mackerras" <paulus@samba.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Philippe Ombredanne" <pombredanne@nexb.com>,
"Kate Stewart" <kstewart@linuxfoundation.org>,
"Nathan Fontenot" <nfont@linux.vnet.ibm.com>,
"Michael Bringmann" <mwb@linux.vnet.ibm.com>,
"Thiago Jung Bauermann" <bauerman@linux.vnet.ibm.com>,
"Kees Cook" <keescook@chromium.org>
Subject: [PATCH 5/6] powerpc: Implement DISCONTIGMEM and allow selection on PPC32
Date: Tue, 20 Feb 2018 17:14:23 +0100 [thread overview]
Message-ID: <20180220161424.5421-6-j.neuschaefer@gmx.net> (raw)
In-Reply-To: <20180220161424.5421-1-j.neuschaefer@gmx.net>
The implementation of pfn_to_nid and pfn_valid in mmzone.h is based on
arch/metag's implementation.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
NOTE: Checking NODE_DATA(nid) in pfn_to_nid appears to be uncommon.
Running up to MAX_NUMNODES instead of checking NODE_DATA(nid) would
require the node_data array to be filled with valid pointers.
---
arch/powerpc/Kconfig | 5 ++++-
arch/powerpc/include/asm/mmzone.h | 21 +++++++++++++++++++++
arch/powerpc/mm/numa.c | 7 +++++++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 73ce5dd07642..c2633b7b8ed9 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -639,7 +639,6 @@ config HAVE_MEMORYLESS_NODES
config ARCH_SELECT_MEMORY_MODEL
def_bool y
- depends on PPC64
config ARCH_FLATMEM_ENABLE
def_bool y
@@ -654,6 +653,10 @@ config ARCH_SPARSEMEM_DEFAULT
def_bool y
depends on PPC_BOOK3S_64
+config ARCH_DISCONTIGMEM_ENABLE
+ def_bool y
+ depends on PPC32
+
config SYS_SUPPORTS_HUGETLBFS
bool
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
index 91c69ff53a8a..1684a5c98d23 100644
--- a/arch/powerpc/include/asm/mmzone.h
+++ b/arch/powerpc/include/asm/mmzone.h
@@ -26,6 +26,27 @@ extern struct pglist_data *node_data[];
*/
#define NODE_DATA(nid) (node_data[nid])
+static inline int pfn_to_nid(unsigned long pfn)
+{
+ int nid;
+
+ for (nid = 0; nid < MAX_NUMNODES && NODE_DATA(nid); nid++)
+ if (pfn >= node_start_pfn(nid) && pfn <= node_end_pfn(nid))
+ return nid;
+
+ return -1;
+}
+
+static inline int pfn_valid(int pfn)
+{
+ int nid = pfn_to_nid(pfn);
+
+ if (nid >= 0)
+ return pfn < node_end_pfn(nid);
+
+ return 0;
+}
+
/*
* Following are specific to this numa platform.
*/
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index dfe279529463..ec47f1081509 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -744,6 +744,13 @@ static void __init setup_nonnuma(void)
PFN_PHYS(end_pfn - start_pfn),
&memblock.memory, nid);
node_set_online(nid);
+
+ /*
+ * On DISCONTIGMEM systems, place different memory blocks into
+ * different nodes.
+ */
+ if (IS_ENABLED(CONFIG_DISCONTIGMEM) && nid < MAX_NUMNODES - 1)
+ nid++;
}
}
--
2.16.1
next prev parent reply other threads:[~2018-02-20 22:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 16:14 [PATCH 0/6] DISCONTIGMEM support for PPC32 Jonathan Neuschäfer
2018-02-20 16:14 ` [PATCH 1/6] powerpc/mm/32: Use pfn_valid to check if pointer is in RAM Jonathan Neuschäfer
2018-02-20 17:45 ` christophe leroy
2018-02-21 13:51 ` Jonathan Neuschäfer
2018-02-21 14:44 ` Jonathan Neuschäfer
2018-02-20 16:14 ` [PATCH 2/6] powerpc: numa: Fix overshift on PPC32 Jonathan Neuschäfer
2018-02-20 16:14 ` [PATCH 3/6] powerpc: numa: Use the right #ifdef guards around functions Jonathan Neuschäfer
2018-02-20 16:14 ` [PATCH 4/6] powerpc: numa: Restrict fake NUMA enulation to CONFIG_NUMA systems Jonathan Neuschäfer
2018-02-20 16:14 ` Jonathan Neuschäfer [this message]
2018-02-20 23:46 ` [PATCH 5/6] powerpc: Implement DISCONTIGMEM and allow selection on PPC32 kbuild test robot
2018-02-21 16:08 ` Jonathan Neuschäfer
2018-02-21 17:53 ` christophe leroy
2018-02-20 16:14 ` [PATCH 6/6] powerpc: wii: Don't rely on reserved memory hack if DISCONTIGMEM is set Jonathan Neuschäfer
2018-02-21 7:06 ` [PATCH 0/6] DISCONTIGMEM support for PPC32 Christophe LEROY
2018-02-21 14:42 ` Jonathan Neuschäfer
2018-02-21 15:02 ` Christophe LEROY
2018-02-21 16:52 ` Jonathan Neuschäfer
2018-02-21 23:31 ` Jonathan Neuschäfer
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=20180220161424.5421-6-j.neuschaefer@gmx.net \
--to=j.neuschaefer@gmx.net \
--cc=bauerman@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=gregkh@linuxfoundation.org \
--cc=joel@jms.id.au \
--cc=keescook@chromium.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=mwb@linux.vnet.ibm.com \
--cc=nfont@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=pombredanne@nexb.com \
--cc=tglx@linutronix.de \
/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).