From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
linuxppc-dev@lists.ozlabs.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 6/8] Update the powerpc arch specific memory add/remove handlers
Date: Wed, 24 Jul 2013 13:44:19 -0500 [thread overview]
Message-ID: <51F02083.7040700@linux.vnet.ibm.com> (raw)
In-Reply-To: <51F01E06.6090800@linux.vnet.ibm.com>
In order to properly hot add and remove memory for powerpc the arch
specific callouts need to now complete all of the required work to
fully add or remove the memory.
With this update we can also remove the handler for memory node add
because the powerpc arch specific memory add handler will do all the
work needed. We do still need the memory node remove handler because
systems with memory specified in the memory@XXX nodes in the device tree
we have to use the removal of the node to trigger memory hot remove.
For systems on newer firmware with memory specified in the
ibm,dynamic-reconfiguration-memory node of the device tree this is not an
issue.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
arch/powerpc/mm/mem.c | 33 +++++++++++++++++++---
arch/powerpc/platforms/pseries/hotplug-memory.c | 35 ------------------------
2 files changed, 29 insertions(+), 39 deletions(-)
Index: linux/arch/powerpc/mm/mem.c
===================================================================
--- linux.orig/arch/powerpc/mm/mem.c
+++ linux/arch/powerpc/mm/mem.c
@@ -35,6 +35,7 @@
#include <linux/memblock.h>
#include <linux/hugetlb.h>
#include <linux/slab.h>
+#include <linux/vmalloc.h>
#include <asm/pgalloc.h>
#include <asm/prom.h>
@@ -120,17 +121,24 @@ int arch_add_memory(int nid, u64 start,
struct zone *zone;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
+ u64 va_start;
+ int ret;
pgdata = NODE_DATA(nid);
- start = (unsigned long)__va(start);
- if (create_section_mapping(start, start + size))
+ va_start = (unsigned long)__va(start);
+ if (create_section_mapping(va_start, va_start + size))
return -EINVAL;
/* this should work for most non-highmem platforms */
zone = pgdata->node_zones;
- return __add_pages(nid, zone, start_pfn, nr_pages);
+ ret = __add_pages(nid, zone, start_pfn, nr_pages);
+ if (ret)
+ return ret;
+
+ ret = memblock_add(start, size);
+ return ret;
}
#ifdef CONFIG_MEMORY_HOTREMOVE
@@ -138,10 +146,27 @@ int arch_remove_memory(u64 start, u64 si
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
+ unsigned long va_addr;
struct zone *zone;
+ int ret;
zone = page_zone(pfn_to_page(start_pfn));
- return __remove_pages(zone, start_pfn, nr_pages);
+ ret = __remove_pages(zone, start_pfn, nr_pages);
+ if (ret)
+ return ret;
+
+ memblock_remove(start, size);
+
+ /* remove htab bolted mappings */
+ va_addr = (unsigned long)__va(start);
+ ret = remove_section_mapping(va_addr, va_addr + size);
+
+ /* Ensure all vmalloc mappings are flushed in case they also
+ * hit that section of memory.
+ */
+ vm_unmap_aliases();
+
+ return ret;
}
#endif
#endif /* CONFIG_MEMORY_HOTPLUG */
Index: linux/arch/powerpc/platforms/pseries/hotplug-memory.c
===================================================================
--- linux.orig/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ linux/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -166,38 +166,6 @@ static inline int pseries_remove_memory(
}
#endif /* CONFIG_MEMORY_HOTREMOVE */
-static int pseries_add_memory(struct device_node *np)
-{
- const char *type;
- const unsigned int *regs;
- unsigned long base;
- unsigned int lmb_size;
- int ret = -EINVAL;
-
- /*
- * Check to see if we are actually adding memory
- */
- type = of_get_property(np, "device_type", NULL);
- if (type == NULL || strcmp(type, "memory") != 0)
- return 0;
-
- /*
- * Find the base and size of the memblock
- */
- regs = of_get_property(np, "reg", NULL);
- if (!regs)
- return ret;
-
- base = *(unsigned long *)regs;
- lmb_size = regs[3];
-
- /*
- * Update memory region to represent the memory add
- */
- ret = memblock_add(base, lmb_size);
- return (ret < 0) ? -EINVAL : 0;
-}
-
static int pseries_update_drconf_memory(struct of_prop_reconfig *pr)
{
struct of_drconf_cell *new_drmem, *old_drmem;
@@ -251,9 +219,6 @@ static int pseries_memory_notifier(struc
int err = 0;
switch (action) {
- case OF_RECONFIG_ATTACH_NODE:
- err = pseries_add_memory(node);
- break;
case OF_RECONFIG_DETACH_NODE:
err = pseries_remove_memory(node);
break;
--
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>
next prev parent reply other threads:[~2013-07-24 18:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 18:33 [PATCH 0/8] Correct memory hot add/remove for powerpc Nathan Fontenot
2013-07-24 18:35 ` [PATCH 1/8] register bootmem pages for powerpc when sparse vmemmap is not defined Nathan Fontenot
2013-08-02 2:27 ` Michael Ellerman
2013-08-02 19:04 ` Nathan Fontenot
2013-07-24 18:36 ` [PATCH 2/8] Mark powerpc memory resources as busy Nathan Fontenot
2013-08-02 2:28 ` Michael Ellerman
2013-08-02 19:05 ` Nathan Fontenot
2013-08-05 3:11 ` Michael Ellerman
2013-07-24 18:37 ` [PATCH 3/8] Add all memory via sysfs probe interface at once Nathan Fontenot
2013-08-02 2:32 ` Michael Ellerman
2013-08-02 19:13 ` Nathan Fontenot
2013-08-05 3:13 ` Michael Ellerman
2013-08-06 20:44 ` Nathan Fontenot
2013-08-09 7:16 ` Benjamin Herrenschmidt
2013-07-24 18:39 ` [PATCH 4/8] Create a sysfs release file for hot removing memory Nathan Fontenot
2013-07-24 18:41 ` [PATCH 5/8] Add notifiers for memory hot add/remove Nathan Fontenot
2013-07-24 18:44 ` Nathan Fontenot [this message]
2013-07-24 18:45 ` [PATCH 7/8] Add memory hot add/remove notifier handlers for pwoerpc Nathan Fontenot
2013-07-24 18:47 ` [PATCH 8/8] Remove no longer needed powerpc memory node update handler Nathan Fontenot
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=51F02083.7040700@linux.vnet.ibm.com \
--to=nfont@linux.vnet.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.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).