* [PATCH v2 0/2] fix cache mode tracking for pmem + dax @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, David Airlie, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, akpm, Kirill A. Shutemov, Kai Zhang While writing an improved changelog, as prompted by Andrew, for v1 of "mm: fix cache mode of dax pmd mappings" [1], it struck me that vmf_insert_pfn_pmd() is implemented correctly. Instead, it is the memtype tree that is missing a memtype reservation for devm_memremap_pages() ranges. vmf_insert_pfn_pmd() is correct to validate the memtype before inserting a mapping, but this highlights that vm_insert_mixed() is missing this validation. I would still like to take patch 1 through the nvdimm.git tree, with -mm acks, along with the device-dax fixes for v4.8-rc6. Patch 2 can go the typical -mm route for v4.9 since it has potential to change behavior in its DRI usages, needs soak time in -next, and there no known memtype conflict problems it would fix. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-September/006781.html --- Dan Williams (2): mm: fix cache mode of dax pmd mappings mm: fix cache mode tracking in vm_insert_mixed() arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ mm/memory.c | 8 ++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 0/2] fix cache mode tracking for pmem + dax @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw Cc: Matthew Wilcox, David Airlie, Nilesh Choudhury, linux-kernel-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, Kirill A. Shutemov, Kai Zhang While writing an improved changelog, as prompted by Andrew, for v1 of "mm: fix cache mode of dax pmd mappings" [1], it struck me that vmf_insert_pfn_pmd() is implemented correctly. Instead, it is the memtype tree that is missing a memtype reservation for devm_memremap_pages() ranges. vmf_insert_pfn_pmd() is correct to validate the memtype before inserting a mapping, but this highlights that vm_insert_mixed() is missing this validation. I would still like to take patch 1 through the nvdimm.git tree, with -mm acks, along with the device-dax fixes for v4.8-rc6. Patch 2 can go the typical -mm route for v4.9 since it has potential to change behavior in its DRI usages, needs soak time in -next, and there no known memtype conflict problems it would fix. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-September/006781.html --- Dan Williams (2): mm: fix cache mode of dax pmd mappings mm: fix cache mode tracking in vm_insert_mixed() arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ mm/memory.c | 8 ++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 0/2] fix cache mode tracking for pmem + dax @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, David Airlie, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang While writing an improved changelog, as prompted by Andrew, for v1 of "mm: fix cache mode of dax pmd mappings" [1], it struck me that vmf_insert_pfn_pmd() is implemented correctly. Instead, it is the memtype tree that is missing a memtype reservation for devm_memremap_pages() ranges. vmf_insert_pfn_pmd() is correct to validate the memtype before inserting a mapping, but this highlights that vm_insert_mixed() is missing this validation. I would still like to take patch 1 through the nvdimm.git tree, with -mm acks, along with the device-dax fixes for v4.8-rc6. Patch 2 can go the typical -mm route for v4.9 since it has potential to change behavior in its DRI usages, needs soak time in -next, and there no known memtype conflict problems it would fix. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-September/006781.html --- Dan Williams (2): mm: fix cache mode of dax pmd mappings mm: fix cache mode tracking in vm_insert_mixed() arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ mm/memory.c | 8 ++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) -- 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> ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 0/2] fix cache mode tracking for pmem + dax @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, David Airlie, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang While writing an improved changelog, as prompted by Andrew, for v1 of "mm: fix cache mode of dax pmd mappings" [1], it struck me that vmf_insert_pfn_pmd() is implemented correctly. Instead, it is the memtype tree that is missing a memtype reservation for devm_memremap_pages() ranges. vmf_insert_pfn_pmd() is correct to validate the memtype before inserting a mapping, but this highlights that vm_insert_mixed() is missing this validation. I would still like to take patch 1 through the nvdimm.git tree, with -mm acks, along with the device-dax fixes for v4.8-rc6. Patch 2 can go the typical -mm route for v4.9 since it has potential to change behavior in its DRI usages, needs soak time in -next, and there no known memtype conflict problems it would fix. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-September/006781.html --- Dan Williams (2): mm: fix cache mode of dax pmd mappings mm: fix cache mode tracking in vm_insert_mixed() arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ mm/memory.c | 8 ++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 0/2] fix cache mode tracking for pmem + dax @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, David Airlie, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang While writing an improved changelog, as prompted by Andrew, for v1 of "mm: fix cache mode of dax pmd mappings" [1], it struck me that vmf_insert_pfn_pmd() is implemented correctly. Instead, it is the memtype tree that is missing a memtype reservation for devm_memremap_pages() ranges. vmf_insert_pfn_pmd() is correct to validate the memtype before inserting a mapping, but this highlights that vm_insert_mixed() is missing this validation. I would still like to take patch 1 through the nvdimm.git tree, with -mm acks, along with the device-dax fixes for v4.8-rc6. Patch 2 can go the typical -mm route for v4.9 since it has potential to change behavior in its DRI usages, needs soak time in -next, and there no known memtype conflict problems it would fix. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-September/006781.html --- Dan Williams (2): mm: fix cache mode of dax pmd mappings mm: fix cache mode tracking in vm_insert_mixed() arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ mm/memory.c | 8 ++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings 2016-09-07 22:26 ` Dan Williams ` (2 preceding siblings ...) (?) @ 2016-09-07 22:26 ` Dan Williams -1 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, akpm, Kirill A. Shutemov, Kai Zhang track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as uncacheable rendering them impractical for application usage. DAX-pte mappings are cached and the goal of establishing DAX-pmd mappings is to attain more performance, not dramatically less (3 orders of magnitude). track_pfn_insert() relies on a previous call to reserve_memtype() to establish the expected page_cache_mode for the range. While memremap() arranges for reserve_memtype() to be called, devm_memremap_pages() does not. So, teach track_pfn_insert() and untrack_pfn() how to handle tracking without a vma, and arrange for devm_memremap_pages() to establish the write-back-cache reservation in the memtype tree. Cc: <stable@vger.kernel.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reported-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Kai Zhang <kai.ka.zhang@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) } /* - * prot is passed in as a parameter for the new mapping. If the vma has a - * linear pfn mapping for the entire range reserve the entire vma range with - * single reserve_pfn_range call. + * prot is passed in as a parameter for the new mapping. If the vma has + * a linear pfn mapping for the entire range, or no vma is provided, + * reserve the entire pfn + size range with single reserve_pfn_range + * call. */ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, enum page_cache_mode pcm; /* reserve the whole chunk starting from paddr */ - if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { + if (!vma || (addr == vma->vm_start + && size == (vma->vm_end - vma->vm_start))) { int ret; ret = reserve_pfn_range(paddr, size, prot, 0); - if (!ret) + if (ret == 0 && vma) vma->vm_flags |= VM_PAT; return ret; } @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, resource_size_t paddr; unsigned long prot; - if (!(vma->vm_flags & VM_PAT)) + if (vma && !(vma->vm_flags & VM_PAT)) return; /* free the chunk starting from pfn or the whole chunk */ @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; } free_pfn_range(paddr, size); - vma->vm_flags &= ~VM_PAT; + if (vma) + vma->vm_flags &= ~VM_PAT; } /* diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(resource_size(res), SECTION_SIZE); arch_remove_memory(align_start, align_size); + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { resource_size_t key, align_start, align_size, align_end; + pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, if (nid < 0) nid = numa_mem_id(); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, + align_size); + if (error) + goto err_pfn_remap; + error = arch_add_memory(nid, align_start, align_size, true); if (error) goto err_add_memory; @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, return __va(res->start); err_add_memory: + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + err_pfn_remap: err_radix: pgmap_radix_release(res); devres_free(page_map); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as uncacheable rendering them impractical for application usage. DAX-pte mappings are cached and the goal of establishing DAX-pmd mappings is to attain more performance, not dramatically less (3 orders of magnitude). track_pfn_insert() relies on a previous call to reserve_memtype() to establish the expected page_cache_mode for the range. While memremap() arranges for reserve_memtype() to be called, devm_memremap_pages() does not. So, teach track_pfn_insert() and untrack_pfn() how to handle tracking without a vma, and arrange for devm_memremap_pages() to establish the write-back-cache reservation in the memtype tree. Cc: <stable@vger.kernel.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reported-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Kai Zhang <kai.ka.zhang@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) } /* - * prot is passed in as a parameter for the new mapping. If the vma has a - * linear pfn mapping for the entire range reserve the entire vma range with - * single reserve_pfn_range call. + * prot is passed in as a parameter for the new mapping. If the vma has + * a linear pfn mapping for the entire range, or no vma is provided, + * reserve the entire pfn + size range with single reserve_pfn_range + * call. */ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, enum page_cache_mode pcm; /* reserve the whole chunk starting from paddr */ - if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { + if (!vma || (addr == vma->vm_start + && size == (vma->vm_end - vma->vm_start))) { int ret; ret = reserve_pfn_range(paddr, size, prot, 0); - if (!ret) + if (ret == 0 && vma) vma->vm_flags |= VM_PAT; return ret; } @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, resource_size_t paddr; unsigned long prot; - if (!(vma->vm_flags & VM_PAT)) + if (vma && !(vma->vm_flags & VM_PAT)) return; /* free the chunk starting from pfn or the whole chunk */ @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; } free_pfn_range(paddr, size); - vma->vm_flags &= ~VM_PAT; + if (vma) + vma->vm_flags &= ~VM_PAT; } /* diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(resource_size(res), SECTION_SIZE); arch_remove_memory(align_start, align_size); + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { resource_size_t key, align_start, align_size, align_end; + pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, if (nid < 0) nid = numa_mem_id(); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, + align_size); + if (error) + goto err_pfn_remap; + error = arch_add_memory(nid, align_start, align_size, true); if (error) goto err_add_memory; @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, return __va(res->start); err_add_memory: + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + err_pfn_remap: err_radix: pgmap_radix_release(res); devres_free(page_map); _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as uncacheable rendering them impractical for application usage. DAX-pte mappings are cached and the goal of establishing DAX-pmd mappings is to attain more performance, not dramatically less (3 orders of magnitude). track_pfn_insert() relies on a previous call to reserve_memtype() to establish the expected page_cache_mode for the range. While memremap() arranges for reserve_memtype() to be called, devm_memremap_pages() does not. So, teach track_pfn_insert() and untrack_pfn() how to handle tracking without a vma, and arrange for devm_memremap_pages() to establish the write-back-cache reservation in the memtype tree. Cc: <stable@vger.kernel.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reported-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Kai Zhang <kai.ka.zhang@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) } /* - * prot is passed in as a parameter for the new mapping. If the vma has a - * linear pfn mapping for the entire range reserve the entire vma range with - * single reserve_pfn_range call. + * prot is passed in as a parameter for the new mapping. If the vma has + * a linear pfn mapping for the entire range, or no vma is provided, + * reserve the entire pfn + size range with single reserve_pfn_range + * call. */ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, enum page_cache_mode pcm; /* reserve the whole chunk starting from paddr */ - if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { + if (!vma || (addr == vma->vm_start + && size == (vma->vm_end - vma->vm_start))) { int ret; ret = reserve_pfn_range(paddr, size, prot, 0); - if (!ret) + if (ret == 0 && vma) vma->vm_flags |= VM_PAT; return ret; } @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, resource_size_t paddr; unsigned long prot; - if (!(vma->vm_flags & VM_PAT)) + if (vma && !(vma->vm_flags & VM_PAT)) return; /* free the chunk starting from pfn or the whole chunk */ @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; } free_pfn_range(paddr, size); - vma->vm_flags &= ~VM_PAT; + if (vma) + vma->vm_flags &= ~VM_PAT; } /* diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(resource_size(res), SECTION_SIZE); arch_remove_memory(align_start, align_size); + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { resource_size_t key, align_start, align_size, align_end; + pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, if (nid < 0) nid = numa_mem_id(); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, + align_size); + if (error) + goto err_pfn_remap; + error = arch_add_memory(nid, align_start, align_size, true); if (error) goto err_add_memory; @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, return __va(res->start); err_add_memory: + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + err_pfn_remap: err_radix: pgmap_radix_release(res); devres_free(page_map); -- 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> ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as uncacheable rendering them impractical for application usage. DAX-pte mappings are cached and the goal of establishing DAX-pmd mappings is to attain more performance, not dramatically less (3 orders of magnitude). track_pfn_insert() relies on a previous call to reserve_memtype() to establish the expected page_cache_mode for the range. While memremap() arranges for reserve_memtype() to be called, devm_memremap_pages() does not. So, teach track_pfn_insert() and untrack_pfn() how to handle tracking without a vma, and arrange for devm_memremap_pages() to establish the write-back-cache reservation in the memtype tree. Cc: <stable@vger.kernel.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reported-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Kai Zhang <kai.ka.zhang@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) } /* - * prot is passed in as a parameter for the new mapping. If the vma has a - * linear pfn mapping for the entire range reserve the entire vma range with - * single reserve_pfn_range call. + * prot is passed in as a parameter for the new mapping. If the vma has + * a linear pfn mapping for the entire range, or no vma is provided, + * reserve the entire pfn + size range with single reserve_pfn_range + * call. */ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, enum page_cache_mode pcm; /* reserve the whole chunk starting from paddr */ - if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { + if (!vma || (addr == vma->vm_start + && size == (vma->vm_end - vma->vm_start))) { int ret; ret = reserve_pfn_range(paddr, size, prot, 0); - if (!ret) + if (ret == 0 && vma) vma->vm_flags |= VM_PAT; return ret; } @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, resource_size_t paddr; unsigned long prot; - if (!(vma->vm_flags & VM_PAT)) + if (vma && !(vma->vm_flags & VM_PAT)) return; /* free the chunk starting from pfn or the whole chunk */ @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; } free_pfn_range(paddr, size); - vma->vm_flags &= ~VM_PAT; + if (vma) + vma->vm_flags &= ~VM_PAT; } /* diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(resource_size(res), SECTION_SIZE); arch_remove_memory(align_start, align_size); + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { resource_size_t key, align_start, align_size, align_end; + pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, if (nid < 0) nid = numa_mem_id(); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, + align_size); + if (error) + goto err_pfn_remap; + error = arch_add_memory(nid, align_start, align_size, true); if (error) goto err_add_memory; @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, return __va(res->start); err_add_memory: + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + err_pfn_remap: err_radix: pgmap_radix_release(res); devres_free(page_map); ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, akpm, Kirill A. Shutemov, Kai Zhang track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as uncacheable rendering them impractical for application usage. DAX-pte mappings are cached and the goal of establishing DAX-pmd mappings is to attain more performance, not dramatically less (3 orders of magnitude). track_pfn_insert() relies on a previous call to reserve_memtype() to establish the expected page_cache_mode for the range. While memremap() arranges for reserve_memtype() to be called, devm_memremap_pages() does not. So, teach track_pfn_insert() and untrack_pfn() how to handle tracking without a vma, and arrange for devm_memremap_pages() to establish the write-back-cache reservation in the memtype tree. Cc: <stable@vger.kernel.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reported-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Kai Zhang <kai.ka.zhang@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/pat.c | 17 ++++++++++------- kernel/memremap.c | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) } /* - * prot is passed in as a parameter for the new mapping. If the vma has a - * linear pfn mapping for the entire range reserve the entire vma range with - * single reserve_pfn_range call. + * prot is passed in as a parameter for the new mapping. If the vma has + * a linear pfn mapping for the entire range, or no vma is provided, + * reserve the entire pfn + size range with single reserve_pfn_range + * call. */ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, enum page_cache_mode pcm; /* reserve the whole chunk starting from paddr */ - if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { + if (!vma || (addr == vma->vm_start + && size == (vma->vm_end - vma->vm_start))) { int ret; ret = reserve_pfn_range(paddr, size, prot, 0); - if (!ret) + if (ret == 0 && vma) vma->vm_flags |= VM_PAT; return ret; } @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, resource_size_t paddr; unsigned long prot; - if (!(vma->vm_flags & VM_PAT)) + if (vma && !(vma->vm_flags & VM_PAT)) return; /* free the chunk starting from pfn or the whole chunk */ @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; } free_pfn_range(paddr, size); - vma->vm_flags &= ~VM_PAT; + if (vma) + vma->vm_flags &= ~VM_PAT; } /* diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(resource_size(res), SECTION_SIZE); arch_remove_memory(align_start, align_size); + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { resource_size_t key, align_start, align_size, align_end; + pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, if (nid < 0) nid = numa_mem_id(); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, + align_size); + if (error) + goto err_pfn_remap; + error = arch_add_memory(nid, align_start, align_size, true); if (error) goto err_add_memory; @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, return __va(res->start); err_add_memory: + untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + err_pfn_remap: err_radix: pgmap_radix_release(res); devres_free(page_map); ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings 2016-09-07 22:26 ` Dan Williams @ 2016-09-08 22:49 ` Andrew Morton -1 siblings, 0 replies; 16+ messages in thread From: Andrew Morton @ 2016-09-08 22:49 UTC (permalink / raw) To: Dan Williams Cc: linux-nvdimm, Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, Kirill A. Shutemov, Kai Zhang On Wed, 07 Sep 2016 15:26:14 -0700 Dan Williams <dan.j.williams@intel.com> wrote: > track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as > uncacheable rendering them impractical for application usage. DAX-pte > mappings are cached and the goal of establishing DAX-pmd mappings is to > attain more performance, not dramatically less (3 orders of magnitude). > > track_pfn_insert() relies on a previous call to reserve_memtype() to > establish the expected page_cache_mode for the range. While memremap() > arranges for reserve_memtype() to be called, devm_memremap_pages() does > not. So, teach track_pfn_insert() and untrack_pfn() how to handle > tracking without a vma, and arrange for devm_memremap_pages() to > establish the write-back-cache reservation in the memtype tree. Acked-by: Andrew Morton <akpm@linux-foundation.org> I'll grab [2/2]. -- 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> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings @ 2016-09-08 22:49 ` Andrew Morton 0 siblings, 0 replies; 16+ messages in thread From: Andrew Morton @ 2016-09-08 22:49 UTC (permalink / raw) To: Dan Williams Cc: linux-nvdimm, Toshi Kani, Matthew Wilcox, Nilesh Choudhury, linux-kernel, stable, linux-mm, dri-devel, Ross Zwisler, Kirill A. Shutemov, Kai Zhang On Wed, 07 Sep 2016 15:26:14 -0700 Dan Williams <dan.j.williams@intel.com> wrote: > track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as > uncacheable rendering them impractical for application usage. DAX-pte > mappings are cached and the goal of establishing DAX-pmd mappings is to > attain more performance, not dramatically less (3 orders of magnitude). > > track_pfn_insert() relies on a previous call to reserve_memtype() to > establish the expected page_cache_mode for the range. While memremap() > arranges for reserve_memtype() to be called, devm_memremap_pages() does > not. So, teach track_pfn_insert() and untrack_pfn() how to handle > tracking without a vma, and arrange for devm_memremap_pages() to > establish the write-back-cache reservation in the memtype tree. Acked-by: Andrew Morton <akpm@linux-foundation.org> I'll grab [2/2]. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] mm: fix cache mode tracking in vm_insert_mixed() 2016-09-07 22:26 ` Dan Williams (?) (?) @ 2016-09-07 22:26 ` Dan Williams -1 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, David Airlie, linux-kernel, dri-devel, linux-mm, akpm vm_insert_mixed() unlike vm_insert_pfn_prot() and vmf_insert_pfn_pmd(), fails to check the pgprot_t it uses for the mapping against the one recorded in the memtype tracking tree. Add the missing call to track_pfn_insert() to preclude cases where incompatible aliased mappings are established for a given physical address range. Cc: David Airlie <airlied@linux.ie> Cc: dri-devel@lists.freedesktop.org Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- mm/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 83be99d9d8a1..8841fed328f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1649,10 +1649,14 @@ EXPORT_SYMBOL(vm_insert_pfn_prot); int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { + pgprot_t pgprot = vma->vm_page_prot; + BUG_ON(!(vma->vm_flags & VM_MIXEDMAP)); if (addr < vma->vm_start || addr >= vma->vm_end) return -EFAULT; + if (track_pfn_insert(vma, &pgprot, pfn)) + return -EINVAL; /* * If we don't have pte special, then we have to use the pfn_valid() @@ -1670,9 +1674,9 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, * result in pfn_t_has_page() == false. */ page = pfn_to_page(pfn_t_to_pfn(pfn)); - return insert_page(vma, addr, page, vma->vm_page_prot); + return insert_page(vma, addr, page, pgprot); } - return insert_pfn(vma, addr, pfn, vma->vm_page_prot); + return insert_pfn(vma, addr, pfn, pgprot); } EXPORT_SYMBOL(vm_insert_mixed); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] mm: fix cache mode tracking in vm_insert_mixed() @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, linux-kernel, dri-devel, linux-mm, akpm, Ross Zwisler vm_insert_mixed() unlike vm_insert_pfn_prot() and vmf_insert_pfn_pmd(), fails to check the pgprot_t it uses for the mapping against the one recorded in the memtype tracking tree. Add the missing call to track_pfn_insert() to preclude cases where incompatible aliased mappings are established for a given physical address range. Cc: David Airlie <airlied@linux.ie> Cc: dri-devel@lists.freedesktop.org Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- mm/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 83be99d9d8a1..8841fed328f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1649,10 +1649,14 @@ EXPORT_SYMBOL(vm_insert_pfn_prot); int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { + pgprot_t pgprot = vma->vm_page_prot; + BUG_ON(!(vma->vm_flags & VM_MIXEDMAP)); if (addr < vma->vm_start || addr >= vma->vm_end) return -EFAULT; + if (track_pfn_insert(vma, &pgprot, pfn)) + return -EINVAL; /* * If we don't have pte special, then we have to use the pfn_valid() @@ -1670,9 +1674,9 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, * result in pfn_t_has_page() == false. */ page = pfn_to_page(pfn_t_to_pfn(pfn)); - return insert_page(vma, addr, page, vma->vm_page_prot); + return insert_page(vma, addr, page, pgprot); } - return insert_pfn(vma, addr, pfn, vma->vm_page_prot); + return insert_pfn(vma, addr, pfn, pgprot); } EXPORT_SYMBOL(vm_insert_mixed); _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] mm: fix cache mode tracking in vm_insert_mixed() @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, David Airlie, linux-kernel, dri-devel, linux-mm, akpm, Ross Zwisler vm_insert_mixed() unlike vm_insert_pfn_prot() and vmf_insert_pfn_pmd(), fails to check the pgprot_t it uses for the mapping against the one recorded in the memtype tracking tree. Add the missing call to track_pfn_insert() to preclude cases where incompatible aliased mappings are established for a given physical address range. Cc: David Airlie <airlied@linux.ie> Cc: dri-devel@lists.freedesktop.org Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- mm/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 83be99d9d8a1..8841fed328f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1649,10 +1649,14 @@ EXPORT_SYMBOL(vm_insert_pfn_prot); int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { + pgprot_t pgprot = vma->vm_page_prot; + BUG_ON(!(vma->vm_flags & VM_MIXEDMAP)); if (addr < vma->vm_start || addr >= vma->vm_end) return -EFAULT; + if (track_pfn_insert(vma, &pgprot, pfn)) + return -EINVAL; /* * If we don't have pte special, then we have to use the pfn_valid() @@ -1670,9 +1674,9 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, * result in pfn_t_has_page() == false. */ page = pfn_to_page(pfn_t_to_pfn(pfn)); - return insert_page(vma, addr, page, vma->vm_page_prot); + return insert_page(vma, addr, page, pgprot); } - return insert_pfn(vma, addr, pfn, vma->vm_page_prot); + return insert_pfn(vma, addr, pfn, pgprot); } EXPORT_SYMBOL(vm_insert_mixed); -- 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> ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] mm: fix cache mode tracking in vm_insert_mixed() @ 2016-09-07 22:26 ` Dan Williams 0 siblings, 0 replies; 16+ messages in thread From: Dan Williams @ 2016-09-07 22:26 UTC (permalink / raw) To: linux-nvdimm Cc: Matthew Wilcox, David Airlie, linux-kernel, dri-devel, linux-mm, akpm, Ross Zwisler vm_insert_mixed() unlike vm_insert_pfn_prot() and vmf_insert_pfn_pmd(), fails to check the pgprot_t it uses for the mapping against the one recorded in the memtype tracking tree. Add the missing call to track_pfn_insert() to preclude cases where incompatible aliased mappings are established for a given physical address range. Cc: David Airlie <airlied@linux.ie> Cc: dri-devel@lists.freedesktop.org Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- mm/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 83be99d9d8a1..8841fed328f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1649,10 +1649,14 @@ EXPORT_SYMBOL(vm_insert_pfn_prot); int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { + pgprot_t pgprot = vma->vm_page_prot; + BUG_ON(!(vma->vm_flags & VM_MIXEDMAP)); if (addr < vma->vm_start || addr >= vma->vm_end) return -EFAULT; + if (track_pfn_insert(vma, &pgprot, pfn)) + return -EINVAL; /* * If we don't have pte special, then we have to use the pfn_valid() @@ -1670,9 +1674,9 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, * result in pfn_t_has_page() == false. */ page = pfn_to_page(pfn_t_to_pfn(pfn)); - return insert_page(vma, addr, page, vma->vm_page_prot); + return insert_page(vma, addr, page, pgprot); } - return insert_pfn(vma, addr, pfn, vma->vm_page_prot); + return insert_pfn(vma, addr, pfn, pgprot); } EXPORT_SYMBOL(vm_insert_mixed); ^ permalink raw reply related [flat|nested] 16+ messages in thread
end of thread, other threads:[~2016-09-08 22:49 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-09-07 22:26 [PATCH v2 0/2] fix cache mode tracking for pmem + dax Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` [PATCH v2 1/2] mm: fix cache mode of dax pmd mappings Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-08 22:49 ` Andrew Morton 2016-09-08 22:49 ` Andrew Morton 2016-09-07 22:26 ` [PATCH v2 2/2] mm: fix cache mode tracking in vm_insert_mixed() Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams 2016-09-07 22:26 ` Dan Williams
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.