diff for duplicates of <20170601223808.GC2780@redhat.com> diff --git a/a/1.txt b/N1/1.txt index 7c02a0b..d4ba542 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,7 +1,7 @@ On Thu, Jun 01, 2017 at 12:04:02PM +1000, Balbir Singh wrote: > On Thu, May 25, 2017 at 3:53 AM, Jerome Glisse <jglisse@redhat.com> wrote: > > On Wed, May 24, 2017 at 11:55:12AM +1000, Balbir Singh wrote: -> >> On Tue, May 23, 2017 at 2:51 AM, Jerome Glisse <jglisse@redhat.com> wrote: +> >> On Tue, May 23, 2017 at 2:51 AM, Jérôme Glisse <jglisse@redhat.com> wrote: > >> > Patchset is on top of mmotm mmotm-2017-05-18, git branch: > >> > > >> > https://cgit.freedesktop.org/~glisse/linux/log/?h=hmm-v22 @@ -53,4 +53,4 @@ to pack stuff. Attach is first step of CDM on top of lastest HMM. I hope to have more time tomorrow or next week to finish rebasing patches and to run some test with stolen ram as CDM memory. -Jerome +Jérôme diff --git a/a/2.txt b/N1/2.txt index 8b13789..6d5f497 100644 --- a/a/2.txt +++ b/N1/2.txt @@ -1 +1,192 @@ +>From 0ca0ebe4aecedfe69ae029c529045d609352b921 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com> +Date: Thu, 1 Jun 2017 11:25:59 -0400 +Subject: [PATCH] mm/device-public-memory: device memory cache coherent with + CPU +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Platform with advance system bus (like CAPI or CCIX) allow device +memory to be accessible from CPU in a cache coherent fashion. Add +a new type of ZONE_DEVICE to represent such memory. The use case +are the same as for the un-addressable device memory but without +all the corners cases. + +Signed-off-by: Jérôme Glisse <jglisse@redhat.com> +--- + include/linux/ioport.h | 1 + + include/linux/memremap.h | 21 +++++++++++++++++++++ + mm/Kconfig | 13 +++++++++++++ + mm/memory.c | 13 +++++++++++++ + mm/migrate.c | 23 ++++++++++++++--------- + 5 files changed, 62 insertions(+), 9 deletions(-) + +diff --git a/include/linux/ioport.h b/include/linux/ioport.h +index 3a4f691..f5cf32e 100644 +--- a/include/linux/ioport.h ++++ b/include/linux/ioport.h +@@ -131,6 +131,7 @@ enum { + IORES_DESC_PERSISTENT_MEMORY = 4, + IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, + IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, ++ IORES_DESC_DEVICE_PUBLIC_MEMORY = 7, + }; + + /* helpers to define resources */ +diff --git a/include/linux/memremap.h b/include/linux/memremap.h +index 0e0d2e6..b9f460a 100644 +--- a/include/linux/memremap.h ++++ b/include/linux/memremap.h +@@ -56,10 +56,18 @@ static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start) + * page must be treated as an opaque object, rather than a "normal" struct page. + * A more complete discussion of unaddressable memory may be found in + * include/linux/hmm.h and Documentation/vm/hmm.txt. ++ * ++ * MEMORY_DEVICE_PUBLIC: ++ * Device memory that is cache coherent from device and CPU point of view. This ++ * is use on platform that have an advance system bus (like CAPI or CCIX). A ++ * driver can hotplug the device memory using ZONE_DEVICE and with that memory ++ * type. Any page of a process can be migrated to such memory. However no one ++ * should be allow to pin such memory so that it can always be evicted. + */ + enum memory_type { + MEMORY_DEVICE_PUBLIC = 0, + MEMORY_DEVICE_PRIVATE, ++ MEMORY_DEVICE_PUBLIC, + }; + + /* +@@ -91,6 +99,8 @@ enum memory_type { + * The page_free() callback is called once the page refcount reaches 1 + * (ZONE_DEVICE pages never reach 0 refcount unless there is a refcount bug. + * This allows the device driver to implement its own memory management.) ++ * ++ * For MEMORY_DEVICE_CACHE_COHERENT only the page_free() callback matter. + */ + typedef int (*dev_page_fault_t)(struct vm_area_struct *vma, + unsigned long addr, +@@ -133,6 +143,12 @@ static inline bool is_device_private_page(const struct page *page) + return is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PRIVATE; + } ++ ++static inline bool is_device_public_page(const struct page *page) ++{ ++ return is_zone_device_page(page) && ++ page->pgmap->type == MEMORY_DEVICE_PUBLIC; ++} + #else + static inline void *devm_memremap_pages(struct device *dev, + struct resource *res, struct percpu_ref *ref, +@@ -156,6 +172,11 @@ static inline bool is_device_private_page(const struct page *page) + { + return false; + } ++ ++static inline bool is_device_public_page(const struct page *page) ++{ ++ return false; ++} + #endif + + /** +diff --git a/mm/Kconfig b/mm/Kconfig +index 46296d5d7..bacb193 100644 +--- a/mm/Kconfig ++++ b/mm/Kconfig +@@ -758,6 +758,19 @@ config DEVICE_PRIVATE + memory; i.e., memory that is only accessible from the device (or + group of devices). + ++config DEVICE_PUBLIC ++ bool "Unaddressable device memory (GPU memory, ...)" ++ depends on X86_64 ++ depends on ZONE_DEVICE ++ depends on MEMORY_HOTPLUG ++ depends on MEMORY_HOTREMOVE ++ depends on SPARSEMEM_VMEMMAP ++ ++ help ++ Allows creation of struct pages to represent addressable device ++ memory; i.e., memory that is accessible from both the device and ++ the CPU ++ + config FRAME_VECTOR + bool + +diff --git a/mm/memory.c b/mm/memory.c +index eba61dd..d192f3d 100644 +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -983,6 +983,19 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, + get_page(page); + page_dup_rmap(page, false); + rss[mm_counter(page)]++; ++ } else if (pte_devmap(pte)) { ++ page = pte_page(pte); ++ ++ /* ++ * Cache coherent device memory behave like regular page and ++ * not like persistent memory page. For more informations see ++ * MEMORY_DEVICE_CACHE_COHERENT in memory_hotplug.h ++ */ ++ if (is_device_public_page(page)) { ++ get_page(page); ++ page_dup_rmap(page, false); ++ rss[mm_counter(page)]++; ++ } + } + + out_set_pte: +diff --git a/mm/migrate.c b/mm/migrate.c +index d7c4db6..a0115b8 100644 +--- a/mm/migrate.c ++++ b/mm/migrate.c +@@ -229,12 +229,16 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, + if (is_write_migration_entry(entry)) + pte = maybe_mkwrite(pte, vma); + +- if (unlikely(is_zone_device_page(new)) && +- is_device_private_page(new)) { +- entry = make_device_private_entry(new, pte_write(pte)); +- pte = swp_entry_to_pte(entry); +- if (pte_swp_soft_dirty(*pvmw.pte)) +- pte = pte_mksoft_dirty(pte); ++ if (unlikely(is_zone_device_page(new))) { ++ if (is_device_private_page(new)) { ++ entry = make_device_private_entry(new, pte_write(pte)); ++ pte = swp_entry_to_pte(entry); ++ if (pte_swp_soft_dirty(*pvmw.pte)) ++ pte = pte_mksoft_dirty(pte); ++ } else if (is_device_public_page(new)) { ++ pte = pte_mkdevmap(pte); ++ flush_dcache_page(new); ++ } + } else + flush_dcache_page(new); + +@@ -2300,9 +2304,10 @@ static bool migrate_vma_check_page(struct page *page) + + /* Page from ZONE_DEVICE have one extra reference */ + if (is_zone_device_page(page)) { +- if (is_device_private_page(page)) { ++ if (is_device_private_page(page) || ++ is_device_public_page) + extra++; +- } else ++ else + /* Other ZONE_DEVICE memory type are not supported */ + return false; + } +@@ -2621,7 +2626,7 @@ static void migrate_vma_pages(struct migrate_vma *migrate) + migrate->src[i] &= ~MIGRATE_PFN_MIGRATE; + continue; + } +- } else { ++ } else if (!is_device_public_page(newpage)) { + /* + * Other types of ZONE_DEVICE page are not + * supported. +-- +2.4.11 diff --git a/a/content_digest b/N1/content_digest index d5eba7f..fc87b4c 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -16,7 +16,7 @@ "On Thu, Jun 01, 2017 at 12:04:02PM +1000, Balbir Singh wrote:\n" "> On Thu, May 25, 2017 at 3:53 AM, Jerome Glisse <jglisse@redhat.com> wrote:\n" "> > On Wed, May 24, 2017 at 11:55:12AM +1000, Balbir Singh wrote:\n" - "> >> On Tue, May 23, 2017 at 2:51 AM, Jerome Glisse <jglisse@redhat.com> wrote:\n" + "> >> On Tue, May 23, 2017 at 2:51 AM, J\303\251r\303\264me Glisse <jglisse@redhat.com> wrote:\n" "> >> > Patchset is on top of mmotm mmotm-2017-05-18, git branch:\n" "> >> >\n" "> >> > https://cgit.freedesktop.org/~glisse/linux/log/?h=hmm-v22\n" @@ -68,9 +68,201 @@ "to have more time tomorrow or next week to finish rebasing patches and to\n" "run some test with stolen ram as CDM memory.\n" "\n" - Jerome + "J\303\251r\303\264me" "\01:2\0" "fn\00001-mm-device-public-memory-device-memory-cache-coherent.patch\0" "b\0" + ">From 0ca0ebe4aecedfe69ae029c529045d609352b921 Mon Sep 17 00:00:00 2001\n" + "From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com>\n" + "Date: Thu, 1 Jun 2017 11:25:59 -0400\n" + "Subject: [PATCH] mm/device-public-memory: device memory cache coherent with\n" + " CPU\n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "\n" + "Platform with advance system bus (like CAPI or CCIX) allow device\n" + "memory to be accessible from CPU in a cache coherent fashion. Add\n" + "a new type of ZONE_DEVICE to represent such memory. The use case\n" + "are the same as for the un-addressable device memory but without\n" + "all the corners cases.\n" + "\n" + "Signed-off-by: J\303\251r\303\264me Glisse <jglisse@redhat.com>\n" + "---\n" + " include/linux/ioport.h | 1 +\n" + " include/linux/memremap.h | 21 +++++++++++++++++++++\n" + " mm/Kconfig | 13 +++++++++++++\n" + " mm/memory.c | 13 +++++++++++++\n" + " mm/migrate.c | 23 ++++++++++++++---------\n" + " 5 files changed, 62 insertions(+), 9 deletions(-)\n" + "\n" + "diff --git a/include/linux/ioport.h b/include/linux/ioport.h\n" + "index 3a4f691..f5cf32e 100644\n" + "--- a/include/linux/ioport.h\n" + "+++ b/include/linux/ioport.h\n" + "@@ -131,6 +131,7 @@ enum {\n" + " \tIORES_DESC_PERSISTENT_MEMORY\t\t= 4,\n" + " \tIORES_DESC_PERSISTENT_MEMORY_LEGACY\t= 5,\n" + " \tIORES_DESC_DEVICE_PRIVATE_MEMORY\t= 6,\n" + "+\tIORES_DESC_DEVICE_PUBLIC_MEMORY\t\t= 7,\n" + " };\n" + " \n" + " /* helpers to define resources */\n" + "diff --git a/include/linux/memremap.h b/include/linux/memremap.h\n" + "index 0e0d2e6..b9f460a 100644\n" + "--- a/include/linux/memremap.h\n" + "+++ b/include/linux/memremap.h\n" + "@@ -56,10 +56,18 @@ static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)\n" + " * page must be treated as an opaque object, rather than a \"normal\" struct page.\n" + " * A more complete discussion of unaddressable memory may be found in\n" + " * include/linux/hmm.h and Documentation/vm/hmm.txt.\n" + "+ *\n" + "+ * MEMORY_DEVICE_PUBLIC:\n" + "+ * Device memory that is cache coherent from device and CPU point of view. This\n" + "+ * is use on platform that have an advance system bus (like CAPI or CCIX). A\n" + "+ * driver can hotplug the device memory using ZONE_DEVICE and with that memory\n" + "+ * type. Any page of a process can be migrated to such memory. However no one\n" + "+ * should be allow to pin such memory so that it can always be evicted.\n" + " */\n" + " enum memory_type {\n" + " \tMEMORY_DEVICE_PUBLIC = 0,\n" + " \tMEMORY_DEVICE_PRIVATE,\n" + "+\tMEMORY_DEVICE_PUBLIC,\n" + " };\n" + " \n" + " /*\n" + "@@ -91,6 +99,8 @@ enum memory_type {\n" + " * The page_free() callback is called once the page refcount reaches 1\n" + " * (ZONE_DEVICE pages never reach 0 refcount unless there is a refcount bug.\n" + " * This allows the device driver to implement its own memory management.)\n" + "+ *\n" + "+ * For MEMORY_DEVICE_CACHE_COHERENT only the page_free() callback matter.\n" + " */\n" + " typedef int (*dev_page_fault_t)(struct vm_area_struct *vma,\n" + " \t\t\t\tunsigned long addr,\n" + "@@ -133,6 +143,12 @@ static inline bool is_device_private_page(const struct page *page)\n" + " \treturn is_zone_device_page(page) &&\n" + " \t\tpage->pgmap->type == MEMORY_DEVICE_PRIVATE;\n" + " }\n" + "+\n" + "+static inline bool is_device_public_page(const struct page *page)\n" + "+{\n" + "+\treturn is_zone_device_page(page) &&\n" + "+\t\tpage->pgmap->type == MEMORY_DEVICE_PUBLIC;\n" + "+}\n" + " #else\n" + " static inline void *devm_memremap_pages(struct device *dev,\n" + " \t\tstruct resource *res, struct percpu_ref *ref,\n" + "@@ -156,6 +172,11 @@ static inline bool is_device_private_page(const struct page *page)\n" + " {\n" + " \treturn false;\n" + " }\n" + "+\n" + "+static inline bool is_device_public_page(const struct page *page)\n" + "+{\n" + "+\treturn false;\n" + "+}\n" + " #endif\n" + " \n" + " /**\n" + "diff --git a/mm/Kconfig b/mm/Kconfig\n" + "index 46296d5d7..bacb193 100644\n" + "--- a/mm/Kconfig\n" + "+++ b/mm/Kconfig\n" + "@@ -758,6 +758,19 @@ config DEVICE_PRIVATE\n" + " \t memory; i.e., memory that is only accessible from the device (or\n" + " \t group of devices).\n" + " \n" + "+config DEVICE_PUBLIC\n" + "+\tbool \"Unaddressable device memory (GPU memory, ...)\"\n" + "+\tdepends on X86_64\n" + "+\tdepends on ZONE_DEVICE\n" + "+\tdepends on MEMORY_HOTPLUG\n" + "+\tdepends on MEMORY_HOTREMOVE\n" + "+\tdepends on SPARSEMEM_VMEMMAP\n" + "+\n" + "+\thelp\n" + "+\t Allows creation of struct pages to represent addressable device\n" + "+\t memory; i.e., memory that is accessible from both the device and\n" + "+\t the CPU\n" + "+\n" + " config FRAME_VECTOR\n" + " \tbool\n" + " \n" + "diff --git a/mm/memory.c b/mm/memory.c\n" + "index eba61dd..d192f3d 100644\n" + "--- a/mm/memory.c\n" + "+++ b/mm/memory.c\n" + "@@ -983,6 +983,19 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,\n" + " \t\tget_page(page);\n" + " \t\tpage_dup_rmap(page, false);\n" + " \t\trss[mm_counter(page)]++;\n" + "+\t} else if (pte_devmap(pte)) {\n" + "+\t\tpage = pte_page(pte);\n" + "+\n" + "+\t\t/*\n" + "+\t\t * Cache coherent device memory behave like regular page and\n" + "+\t\t * not like persistent memory page. For more informations see\n" + "+\t\t * MEMORY_DEVICE_CACHE_COHERENT in memory_hotplug.h\n" + "+\t\t */\n" + "+\t\tif (is_device_public_page(page)) {\n" + "+\t\t\tget_page(page);\n" + "+\t\t\tpage_dup_rmap(page, false);\n" + "+\t\t\trss[mm_counter(page)]++;\n" + "+\t\t}\n" + " \t}\n" + " \n" + " out_set_pte:\n" + "diff --git a/mm/migrate.c b/mm/migrate.c\n" + "index d7c4db6..a0115b8 100644\n" + "--- a/mm/migrate.c\n" + "+++ b/mm/migrate.c\n" + "@@ -229,12 +229,16 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,\n" + " \t\tif (is_write_migration_entry(entry))\n" + " \t\t\tpte = maybe_mkwrite(pte, vma);\n" + " \n" + "-\t\tif (unlikely(is_zone_device_page(new)) &&\n" + "-\t\t is_device_private_page(new)) {\n" + "-\t\t\tentry = make_device_private_entry(new, pte_write(pte));\n" + "-\t\t\tpte = swp_entry_to_pte(entry);\n" + "-\t\t\tif (pte_swp_soft_dirty(*pvmw.pte))\n" + "-\t\t\t\tpte = pte_mksoft_dirty(pte);\n" + "+\t\tif (unlikely(is_zone_device_page(new))) {\n" + "+\t\t\tif (is_device_private_page(new)) {\n" + "+\t\t\t\tentry = make_device_private_entry(new, pte_write(pte));\n" + "+\t\t\t\tpte = swp_entry_to_pte(entry);\n" + "+\t\t\t\tif (pte_swp_soft_dirty(*pvmw.pte))\n" + "+\t\t\t\t\tpte = pte_mksoft_dirty(pte);\n" + "+\t\t\t} else if (is_device_public_page(new)) {\n" + "+\t\t\t\tpte = pte_mkdevmap(pte);\n" + "+\t\t\t\tflush_dcache_page(new);\n" + "+\t\t\t}\n" + " \t\t} else\n" + " \t\t\tflush_dcache_page(new);\n" + " \n" + "@@ -2300,9 +2304,10 @@ static bool migrate_vma_check_page(struct page *page)\n" + " \n" + " \t/* Page from ZONE_DEVICE have one extra reference */\n" + " \tif (is_zone_device_page(page)) {\n" + "-\t\tif (is_device_private_page(page)) {\n" + "+\t\tif (is_device_private_page(page) ||\n" + "+\t\t is_device_public_page)\n" + " \t\t\textra++;\n" + "-\t\t} else\n" + "+\t\telse\n" + " \t\t\t/* Other ZONE_DEVICE memory type are not supported */\n" + " \t\t\treturn false;\n" + " \t}\n" + "@@ -2621,7 +2626,7 @@ static void migrate_vma_pages(struct migrate_vma *migrate)\n" + " \t\t\t\t\tmigrate->src[i] &= ~MIGRATE_PFN_MIGRATE;\n" + " \t\t\t\t\tcontinue;\n" + " \t\t\t\t}\n" + "-\t\t\t} else {\n" + "+\t\t\t} else if (!is_device_public_page(newpage)) {\n" + " \t\t\t\t/*\n" + " \t\t\t\t * Other types of ZONE_DEVICE page are not\n" + " \t\t\t\t * supported.\n" + "-- \n" + 2.4.11 -c539471f82ff39495e2f0a773fd730392e9e40ee1d1458d255e119387c8ba6af +3c021b87c3fddad181551ea8d458f5c86fe8397f132e61b26439142fe063b642
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.