Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1568731
| From | Jérôme Glisse <jglisse@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [HMM v17 04/14] mm/ZONE_DEVICE/x86: add support for un-addressable device memory |
| Date | 2017-01-27 23:00 +0100 |
| Message-ID | <t4mIP-15A-45@gated-at.bofh.it> (permalink) |
| References | <t4mIO-15A-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
It does not need much, just skip populating kernel linear mapping
for range of un-addressable device memory (it is pick so that there
is no physical memory resource overlapping it). All the logic is in
share mm code.
Only support x86-64 as this feature doesn't make much sense with
constrained virtual address space of 32bits architecture.
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/mm/init_64.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 442ac86..6e7f613 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -654,7 +654,8 @@ static void update_end_of_memory_vars(u64 start, u64 size)
int arch_add_memory(int nid, u64 start, u64 size, int flags)
{
const int supported_flags = MEMORY_DEVICE |
- MEMORY_DEVICE_ALLOW_MIGRATE;
+ MEMORY_DEVICE_ALLOW_MIGRATE |
+ MEMORY_DEVICE_UNADDRESSABLE;
struct pglist_data *pgdat = NODE_DATA(nid);
struct zone *zone = pgdat->node_zones +
zone_for_memory(nid, start, size, ZONE_NORMAL,
@@ -669,7 +670,17 @@ int arch_add_memory(int nid, u64 start, u64 size, int flags)
return -EINVAL;
}
- init_memory_mapping(start, start + size);
+ /*
+ * We get un-addressable memory when some one is adding a ZONE_DEVICE
+ * to have struct page for a device memory which is not accessible by
+ * the CPU so it is pointless to have a linear kernel mapping of such
+ * memory.
+ *
+ * Core mm should make sure it never set a pte pointing to such fake
+ * physical range.
+ */
+ if (!(flags & MEMORY_DEVICE_UNADDRESSABLE))
+ init_memory_mapping(start, start + size);
ret = __add_pages(nid, zone, start_pfn, nr_pages);
WARN_ON_ONCE(ret);
@@ -968,7 +979,8 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end)
int __ref arch_remove_memory(u64 start, u64 size, int flags)
{
const int supported_flags = MEMORY_DEVICE |
- MEMORY_DEVICE_ALLOW_MIGRATE;
+ MEMORY_DEVICE_ALLOW_MIGRATE |
+ MEMORY_DEVICE_UNADDRESSABLE;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
struct page *page = pfn_to_page(start_pfn);
@@ -989,7 +1001,9 @@ int __ref arch_remove_memory(u64 start, u64 size, int flags)
zone = page_zone(page);
ret = __remove_pages(zone, start_pfn, nr_pages);
WARN_ON_ONCE(ret);
- kernel_physical_mapping_remove(start, start + size);
+
+ if (!(flags & MEMORY_DEVICE_UNADDRESSABLE))
+ kernel_physical_mapping_remove(start, start + size);
return ret;
}
--
2.4.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[HMM v17 00/14] HMM (Heterogeneous Memory Management) v17 Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 13/14] mm/hmm/devmem: device memory hotplug using ZONE_DEVICE Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 12/14] mm/hmm/migrate: support un-addressable ZONE_DEVICE page in migration Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 04/14] mm/ZONE_DEVICE/x86: add support for un-addressable device memory Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 11/14] mm/hmm/mirror: device page fault handler Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 01/14] mm/memory/hotplug: convert device bool to int to allow for more flags v2 Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 02/14] mm/ZONE_DEVICE/free-page: callback when page is freed v2 Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 08/14] mm/hmm: heterogeneous memory management (HMM for short) Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 09/14] mm/hmm/mirror: mirror process address space on device with HMM helpers Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 07/14] mm/migrate: migrate_vma() unmap page from vma while collecting pages Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 06/14] mm/migrate: new memory migration helper for use with device memory v3 Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 [HMM v17 03/14] mm/ZONE_DEVICE/unaddressable: add support for un-addressable device memory v3 Jérôme Glisse <jglisse@redhat.com> - 2017-01-27 23:00 +0100 Re: [HMM v17 00/14] HMM (Heterogeneous Memory Management) v17 John Hubbard <jhubbard@nvidia.com> - 2017-01-28 06:40 +0100
csiph-web