public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFCv2 2/4] s390: mm: support removal of memory
       [not found] <20180523182404.11433-1-david@redhat.com>
@ 2018-05-23 18:24 ` David Hildenbrand
  2018-05-23 18:24 ` [PATCH RFCv2 3/4] s390: numa: implement memory_add_physaddr_to_nid() David Hildenbrand
  1 sibling, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2018-05-23 18:24 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, David Hildenbrand, Martin Schwidefsky,
	Heiko Carstens, Vlastimil Babka, Michal Hocko, Andrew Morton,
	Greg Kroah-Hartman, linux-s390

With virtio-mem, we actually want to remove memory again.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-s390@vger.kernel.org
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/mm/init.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 3fa3e5323612..7202344d0eae 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -242,12 +242,18 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
 #ifdef CONFIG_MEMORY_HOTREMOVE
 int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
-	/*
-	 * There is no hardware or firmware interface which could trigger a
-	 * hot memory remove on s390. So there is nothing that needs to be
-	 * implemented.
-	 */
-	return -EBUSY;
+	const unsigned long start_pfn = start >> PAGE_SHIFT;
+	const unsigned long nr_pages = size >> PAGE_SHIFT;
+	struct page *page = pfn_to_page(start_pfn);
+	struct zone *zone;
+	int ret;
+
+	zone = page_zone(page);
+	ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
+	WARN_ON_ONCE(ret);
+	vmem_remove_mapping(start, size);
+
+	return ret;
 }
 #endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH RFCv2 3/4] s390: numa: implement memory_add_physaddr_to_nid()
       [not found] <20180523182404.11433-1-david@redhat.com>
  2018-05-23 18:24 ` [PATCH RFCv2 2/4] s390: mm: support removal of memory David Hildenbrand
@ 2018-05-23 18:24 ` David Hildenbrand
  1 sibling, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2018-05-23 18:24 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, David Hildenbrand, Martin Schwidefsky,
	Heiko Carstens, Michal Hocko, Andrew Morton, Vlastimil Babka,
	Greg Kroah-Hartman, linux-s390

The common interface to be used with add_memory().

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-s390@vger.kernel.org
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/numa/numa.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/s390/numa/numa.c b/arch/s390/numa/numa.c
index 06a80434cfe6..8902652ab3e5 100644
--- a/arch/s390/numa/numa.c
+++ b/arch/s390/numa/numa.c
@@ -44,6 +44,18 @@ int numa_pfn_to_nid(unsigned long pfn)
 	return mode->__pfn_to_nid ? mode->__pfn_to_nid(pfn) : 0;
 }
 
+#ifdef CONFIG_MEMORY_HOTPLUG
+int memory_add_physaddr_to_nid(u64 addr)
+{
+	int nid = numa_pfn_to_nid(PFN_DOWN(addr));
+
+	if (nid < 0)
+		return 0;
+	return nid;
+}
+EXPORT_SYMBOL(memory_add_physaddr_to_nid);
+#endif
+
 void numa_update_cpu_topology(void)
 {
 	if (mode->update_cpu_topology)
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-23 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180523182404.11433-1-david@redhat.com>
2018-05-23 18:24 ` [PATCH RFCv2 2/4] s390: mm: support removal of memory David Hildenbrand
2018-05-23 18:24 ` [PATCH RFCv2 3/4] s390: numa: implement memory_add_physaddr_to_nid() David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox