fs/dax: deposit pagetable even when installing zero page
Subsystems (5)
PATCH 1/2 fs/dax: deposit pagetable even when installing zero page
Architectures like ppc64 use the deposited page table to store hardware page table slot information. Make sure we deposit a page table when using zero page at the pmd level for hash.
Without this we hit
Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000082a74 Oops: Kernel access of bad area, sig: 11 [#1]
....
NIP [c000000000082a74] __hash_page_thp+0x224/0x5b0 LR [c0000000000829a4] __hash_page_thp+0x154/0x5b0
Call Trace: hash_page_mm+0x43c/0x740 do_hash_page+0x2c/0x3c copy_from_iter_flushcache+0xa4/0x4a0 pmem_copy_from_iter+0x2c/0x50 [nd_pmem] dax_copy_from_iter+0x40/0x70 dax_iomap_actor+0x134/0x360 iomap_apply+0xfc/0x1b0 dax_iomap_rw+0xac/0x130 ext4_file_write_iter+0x254/0x460 [ext4] __vfs_write+0x120/0x1e0 vfs_write+0xd8/0x220 SyS_write+0x6c/0x110 system_call+0x3c/0x130
---
TODO:
* Add fixes tag
fs/dax.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/dax.c +15 -0
@@ -33,6 +33,7 @@#include <linux/sizes.h> #include <linux/mmu_notifier.h> #include <linux/iomap.h> +#include <asm/pgalloc.h> #include "internal.h" #define CREATE_TRACE_POINTS
@@ -1410,7 +1411,9 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, {struct address_space *mapping = vmf->vma->vm_file->f_mapping;unsigned long pmd_addr = vmf->address &PMD_MASK ; +struct vm_area_struct *vma = vmf->vma;struct inode *inode = mapping->host; +pgtable_t pgtable =NULL ;struct page *zero_page;spinlock_t *ptl;pmd_t pmd_entry;
@@ -1425,12 +1428,22 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, *entry =dax_insert_entry (xas, mapping, vmf, *entry, pfn,DAX_PMD |DAX_ZERO_PAGE , false); +if (arch_needs_pgtable_deposit ()) { + pgtable =pte_alloc_one (vma->vm_mm); +if (!pgtable) +return VM_FAULT_OOM ; + } + ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (!pmd_none (*(vmf->pmd))) {spin_unlock (ptl); goto fallback; } +if (pgtable) { +pgtable_trans_huge_deposit (vma->vm_mm, vmf->pmd, pgtable); +mm_inc_nr_ptes (vma->vm_mm); + } pmd_entry =mk_pmd (zero_page, vmf->vma->vm_page_prot); pmd_entry =pmd_mkhuge (pmd_entry);set_pmd_at (vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry);
@@ -1439,6 +1452,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,return VM_FAULT_NOPAGE ; fallback: +if (pgtable) +pte_free (vma->vm_mm, pgtable);trace_dax_pmd_load_hole_fallback (inode, vmf, zero_page, *entry);return VM_FAULT_FALLBACK ; }
Signature · 1 line
2.20.1
PATCH 2/2 mm/dax: Don't enable huge dax mapping by default
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
Architectures mostly do transparent_hugepage_flag = 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.
Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4
NOTE: The patch also use
echo never > /sys/kernel/mm/transparent_hugepage/enabled to disable dax huge page mapping.
---
TODO:
* Add Fixes: tag
include/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)
include/linux/huge_mm.h +3 -1
@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,
@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true; -if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true; if (transparent_hugepage_flags &
mm/huge_memory.c +4 -0
@@ -53,6 +53,7 @@ unsigned long transparent_hugepage_flags __read_mostly =#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE (1 <<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG )| #endif + (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG ) | (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG );
@@ -475,6 +476,8 @@ static int __init setup_transparent_hugepage(char *str) &transparent_hugepage_flags);clear_bit (TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG , &transparent_hugepage_flags); +clear_bit (TRANSPARENT_HUGEPAGE_DAX_FLAG , + &transparent_hugepage_flags); ret =1 ; } out:
@@ -753,6 +756,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,spinlock_t *ptl; ptl =pmd_lock (mm, pmd); +/* should we check for none here again? */ entry =pmd_mkhuge (pfn_t_pmd (pfn, prot));if (pfn_t_devmap (pfn)) entry =pmd_mkdevmap (entry);
Signature · 1 line
2.20.1
Jan Kara
reviewerRe: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 12 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
Quoted 8 lines
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>
Added Dan to CC for opinion. I kind of fail to see why you don't use TRANSPARENT_HUGEPAGE_FLAG for this. I know that technically DAX huge pages and normal THPs are different things but so far we've tried to avoid making that distinction visible to userspace.
Honza
Quoted 62 lines
---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +3
-1@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true; -if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true; if (transparent_hugepage_flags &mm/huge_memory.c +4
-0@@ -53,6 +53,7 @@ unsigned long transparent_hugepage_flags __read_mostly =#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE (1 <<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG )| #endif + (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG ) | (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG );@@ -475,6 +476,8 @@ static int __init setup_transparent_hugepage(char *str) &transparent_hugepage_flags);clear_bit (TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG , &transparent_hugepage_flags); +clear_bit (TRANSPARENT_HUGEPAGE_DAX_FLAG , + &transparent_hugepage_flags); ret =1 ; } out:@@ -753,6 +756,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,spinlock_t *ptl; ptl =pmd_lock (mm, pmd); +/* should we check for none here again? */ entry =pmd_mkhuge (pfn_t_pmd (pfn, prot));if (pfn_t_devmap (pfn)) entry =pmd_mkdevmap (entry);Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 20 lines · Jan Kara
Quoted 19 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.
Quoted 6 lines
Quoted 1 line
Signed-off-by Aneesh Kumar K.V <[email protected]>Added Dan to CC for opinion. I kind of fail to see why you don't use
TRANSPARENT_HUGEPAGE_FLAGfor this. I know that technically DAX huge pages and normal THPs are different things but so far we've tried to avoid making that distinction visible to userspace.
I would also like to use the same flag. Was not sure whether it was ok. In fact that is one of the reason I hooked this to /sys/kernel/mm/transparent_hugepage/enabled. If we are ok with using same flag, we can kill the vma_is_dax() check completely.
-aneesh
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
In reply to Aneesh Kumar K.VQuoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 35 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 7 lines
include/linux/huge_mm.h +2
-1@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true; -if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;
Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Quoted 24 lines
include/linux/huge_mm.h +0
-0if (transparent_hugepage_flags &mm/huge_memory.c +3
-0@@ -53,6 +53,7 @@ unsigned long transparent_hugepage_flags __read_mostly =#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE (1 <<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG )| #endif + (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG ) | (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG );@@ -475,6 +476,8 @@ static int __init setup_transparent_hugepage(char *str) &transparent_hugepage_flags);clear_bit (TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG , &transparent_hugepage_flags); +clear_bit (TRANSPARENT_HUGEPAGE_DAX_FLAG , + &transparent_hugepage_flags); ret =1 ; } out:
mm/huge_memory.c static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, · line 759
Quoted 4 lines
mm/huge_memory.c +1
-0@@ -753,6 +756,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,spinlock_t *ptl; ptl =pmd_lock (mm, pmd); +/* should we check for none here again? */
VM_WARN_ON() maybe? If THP is disabled and we're here then something has gone wrong.
Quoted 6 lines
mm/huge_memory.c +0
-1entry =pmd_mkhuge (pfn_t_pmd (pfn, prot));if (pfn_t_devmap (pfn)) entry =pmd_mkdevmap (entry); --2.20.1
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 49 lines · Oliver
Quoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 38 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true;
Quoted 13 lines
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 4 lines
include/linux/huge_mm.h +2
-1-if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Will fix that. I will make PFN_DEFAULT_ALIGNMENT arch specific.
Quoted 23 lines
Quoted 22 lines
include/linux/huge_mm.h +0
-0if (transparent_hugepage_flags &mm/huge_memory.c +3
-0@@ -53,6 +53,7 @@ unsigned long transparent_hugepage_flags __read_mostly =#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE (1 <<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG )| #endif + (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG ) | (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG )| (1 <<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG );@@ -475,6 +476,8 @@ static int __init setup_transparent_hugepage(char *str) &transparent_hugepage_flags);clear_bit (TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG , &transparent_hugepage_flags); +clear_bit (TRANSPARENT_HUGEPAGE_DAX_FLAG , + &transparent_hugepage_flags); ret =1 ; } out:
Quoted 8 lines
mm/huge_memory.c static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, · line 759
Quoted 5 lines
mm/huge_memory.c +1
-0@@ -753,6 +756,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,spinlock_t *ptl; ptl =pmd_lock (mm, pmd); +/* should we check for none here again? */
VM_WARN_ON()maybe? If THP is disabled and we're here then something has gone wrong.
I was wondering whether we can end up calling insert_pfn_pmd in parallel and hence end up having a pmd entry here already. Usually we check for if (!pmd_none(pmd)) after holding pmd_lock. Was not sure whether there is anything preventing a parallel fault in case of dax.
Quoted 8 lines
Quoted 7 lines
mm/huge_memory.c +0
-1entry =pmd_mkhuge (pfn_t_pmd (pfn, prot));if (pfn_t_devmap (pfn)) entry =pmd_mkdevmap (entry); --2.20.1
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
In reply to OliverQuoted 50 lines · Oliver
Quoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 38 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true;
Quoted 12 lines
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 4 lines
include/linux/huge_mm.h +2
-1-if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Given this is an explicit setting I think device-dax should explicitly fail to enable in the presence of this flag to preserve the application visible behavior.
I.e. if device-dax was enabled after this setting was made then I think future faults should fail as well.
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 64 lines · Dan Williams
Quoted 50 lines · Oliver
Quoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 38 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true;Quoted 12 lines
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 4 lines
include/linux/huge_mm.h +2
-1-if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Quoted 6 lines
Given this is an explicit setting I think device-dax should explicitly fail to enable in the presence of this flag to preserve the application visible behavior.
I.e. if device-dax was enabled after this setting was made then I think future faults should fail as well.
Not sure I understood that. Now we are disabling the ability to map pages as huge pages. I am now considering that this should not be user configurable. Ie, this is something that platform can use to avoid dax forcing huge page mapping, but if the architecture can enable huge dax mapping, we should always default to using that.
Now w.r.t to failures, can device-dax do an opportunistic huge page usage? I haven't looked at the device-dax details fully yet. Do we make the assumption of the mapping page size as a format w.r.t device-dax? Is that derived from nd_pfn->align value?
Here is what I am working on:
1) If the platform doesn't support huge page and if the device superblock indicated that it was created with huge page support, we fail the device init.
2) Now if we are creating a new namespace without huge page support in the platform, then we force the align details to PAGE_SIZE. In such a configuration when handling dax fault even with THP enabled during the build, we should not try to use hugepage. This I think we can achieve by using TRANSPARENT_HUGEPAEG_DAX_FLAG.
Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.
This still doesn't cover the details of a device-dax created with PAGE_SIZE align later booted with a kernel that can do hugepage dax.How should we handle that? That makes me think, this should be a VMA flag which got derived from device config? May be use VM_HUGEPAGE to indicate if device should use a hugepage mapping or not?
-aneesh
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 10 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.
Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
Thanks
Michal
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 14 lines · Michal Suchánek
Quoted 10 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.
Quoted 7 lines
Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
My understanding was that is not true for dax pages? These are not regular memory that got allocated. They are allocated out of /dev/dax/ or /dev/pmem*. Do we have a reason not to use hugepages for mapping pages in that case?
-aneesh
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 22 lines · Aneesh Kumar K.V
Quoted 13 lines · Michal Such�nek
Quoted 9 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.Quoted 7 lines
Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
Quoted 4 lines
My understanding was that is not true for dax pages? These are not regular memory that got allocated. They are allocated out of
/dev/dax/or/dev/pmem*. Do we have a reason not to use hugepages for mapping pages in that case?
Yes. Like when you don't want dax to compete for TLB with mission-critical application (which uses hugetlb for instance).
Signature · 1 line
Kirill A. Shutemov
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
In reply to Aneesh Kumar K.VQuoted 24 lines · Aneesh Kumar K.V
Quoted 14 lines · Michal Suchánek
Quoted 10 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.Quoted 7 lines
Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
Quoted 4 lines
My understanding was that is not true for dax pages? These are not regular memory that got allocated. They are allocated out of
/dev/dax/or/dev/pmem*. Do we have a reason not to use hugepages for mapping pages in that case?
The problem with the transparent_hugepage/enabled interface is that it conflates performing compaction work to produce THP-pages with the ability to map huge pages at all. The compaction is a nop for dax because the memory is already statically allocated. If the administrator does not want dax to consume huge TLB entries then don't configure huge-page dax. If a hypervisor wants to force disable huge-page-configured device-dax instances after the fact it seems we need an explicit interface for that and not overload transparent_hugepage/enabled.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 26 lines · Dan Williams
Quoted 24 lines · Aneesh Kumar K.V
Quoted 21 lines · Michal Suchánek
Quoted 10 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
Quoted 8 lines
Quoted 4 lines
My understanding was that is not true for dax pages? These are not regular memory that got allocated. They are allocated out of
/dev/dax/or/dev/pmem*. Do we have a reason not to use hugepages for mapping pages in that case?The problem with the transparent_hugepage/enabled interface is that it conflates performing compaction work to produce THP-pages with the ability to map huge pages at all.
That's not [entirely] true. transparent_hugepage/defrag gates heavy-duty compaction. We do only very limited compaction if it's not advised by transparent_hugepage/defrag.
I believe DAX has to respect transparent_hugepage/enabled. Or not advertise its huge pages as THP. It's confusing for user.
Signature · 5 lines
Kirill A. Shutemov _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 37 lines · Kirill A. Shutemov
Quoted 26 lines · Dan Williams
Quoted 24 lines · Aneesh Kumar K.V
Quoted 21 lines · Michal Suchánek
Quoted 10 lines · On Wed, 06 Mar 2019 14:47:33 +0530 "Aneesh Kumar K.V"…
Quoted 4 lines · Dan Williams
Quoted 3 lines · Oliver
On Thu, Feb 28, 2019 at 7:35 PM Aneesh Kumar K.V
<[email protected]> wrote:Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.Is this a good idea?
This knob is there for a reason. In some situations having huge pages can severely impact performance of the system (due to host-guest interaction or whatever) and the ability to really turn off all THP would be important in those cases, right?
Quoted 8 lines
Quoted 4 lines
My understanding was that is not true for dax pages? These are not regular memory that got allocated. They are allocated out of
/dev/dax/or/dev/pmem*. Do we have a reason not to use hugepages for mapping pages in that case?The problem with the transparent_hugepage/enabled interface is that it conflates performing compaction work to produce THP-pages with the ability to map huge pages at all.
Quoted 6 lines
That's not [entirely] true. transparent_hugepage/defrag gates heavy-duty compaction. We do only very limited compaction if it's not advised by transparent_hugepage/defrag.
I believe DAX has to respect transparent_hugepage/enabled. Or not advertise its huge pages as THP. It's confusing for user.
What does "advertise its huge pages as THP" mean in practice? I think it's confusing that DAX, a facility that bypasses System RAM, is affected by a transparent_hugepage flag which is a feature for combining System RAM pages into larger pages. For the same reason that transparent_hugepage does not gate / control hugetlb operation is the same reason that transparent_hugepage should not gate / control DAX. A global setting to disable opportunistic large page mappings of System-RAM makes sense, but I don't see why that should read on DAX?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
In reply to Aneesh Kumar K.VQuoted 71 lines · Aneesh Kumar K.V
Quoted 68 lines · Dan Williams
Quoted 50 lines · Oliver
Quoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 38 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true;Quoted 12 lines
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 4 lines
include/linux/huge_mm.h +2
-1-if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Given this is an explicit setting I think device-dax should explicitly fail to enable in the presence of this flag to preserve the application visible behavior.
Quoted 8 lines
Quoted 2 lines
I.e. if device-dax was enabled after this setting was made then I think future faults should fail as well.
Not sure I understood that. Now we are disabling the ability to map pages as huge pages. I am now considering that this should not be user configurable. Ie, this is something that platform can use to avoid dax forcing huge page mapping, but if the architecture can enable huge dax mapping, we should always default to using that.
No, that's an application visible behavior regression. The side effect of this setting is that all huge-page configured device-dax instances must be disabled.
Quoted 2 lines
Now w.r.t to failures, can device-dax do an opportunistic huge page usage?
device-dax explicitly disclaims the ability to do opportunistic mappings.
Quoted 3 lines
I haven't looked at the device-dax details fully yet. Do we make the assumption of the mapping page size as a format w.r.t device-dax? Is that derived from
nd_pfn->alignvalue?
Correct.
Quoted 5 lines
Here is what I am working on:
1) If the platform doesn't support huge page and if the device superblock indicated that it was created with huge page support, we fail the device init.
Ok.
Quoted 5 lines
2) Now if we are creating a new namespace without huge page support in the platform, then we force the align details to
PAGE_SIZE. In such a configuration when handling dax fault even with THP enabled during the build, we should not try to use hugepage. This I think we can achieve by usingTRANSPARENT_HUGEPAEG_DAX_FLAG.
How is this dynamic property communicated to the guest?
Quoted 10 lines
Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.This still doesn't cover the details of a device-dax created with
PAGE_SIZEalign later booted with a kernel that can do hugepage dax.How should we handle that? That makes me think, this should be a VMA flag which got derived from device config? May be useVM_HUGEPAGEto indicate if device should use a hugepage mapping or not?
device-dax configured with PAGE_SIZE always gets PAGE_SIZE mappings.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 82 lines · Dan Williams
Quoted 71 lines · Aneesh Kumar K.V
Quoted 68 lines · Dan Williams
Quoted 50 lines · Oliver
Quoted 6 lines · Aneesh Kumar K.V
Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support.
*groan*
Quoted 38 lines
Architectures mostly do
transparent_hugepage_flag= 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change.Without this patch we get the below error with kvm on ppc64.
[ 118.849975] lpar: Failed hash pte insert with error -4NOTE: The patch also use
echo never >
/sys/kernel/mm/transparent_hugepage/enabledto disable dax huge page mapping.Signed-off-by Aneesh Kumar K.V <[email protected]>---
TODO:
* Add Fixes: taginclude/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-)include/linux/huge_mm.h +1
-0@@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write);enum transparent_hugepage_flag {TRANSPARENT_HUGEPAGE_FLAG , +TRANSPARENT_HUGEPAGE_DAX_FLAG ,TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG ,TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG ,@@ -111,7 +112,8 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)if (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_FLAG ))return true;Quoted 12 lines
include/linux/huge_mm.h static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · line 117
Quoted 4 lines
include/linux/huge_mm.h +2
-1-if (vma_is_dax (vma)) +if (vma_is_dax (vma) && + (transparent_hugepage_flags & (1 <<TRANSPARENT_HUGEPAGE_DAX_FLAG )))return true;Forcing PTE sized faults should be fine for fsdax, but it'll break devdax. The devdax driver requires the fault size be >= the namespace alignment since devdax tries to guarantee hugepage mappings will be used and PMD alignment is the default. We can probably have devdax fall back to the largest size the hypervisor has made available, but it does run contrary to the design. Ah well, I suppose it's better off being degraded rather than unusable.
Given this is an explicit setting I think device-dax should explicitly fail to enable in the presence of this flag to preserve the application visible behavior.
Quoted 8 lines
Quoted 2 lines
I.e. if device-dax was enabled after this setting was made then I think future faults should fail as well.
Not sure I understood that. Now we are disabling the ability to map pages as huge pages. I am now considering that this should not be user configurable. Ie, this is something that platform can use to avoid dax forcing huge page mapping, but if the architecture can enable huge dax mapping, we should always default to using that.
Quoted 3 lines
No, that's an application visible behavior regression. The side effect of this setting is that all huge-page configured device-dax instances must be disabled.
So if the device was created with a nd_pfn->align value of PMD_SIZE, that is an indication that we would map the pages in PMD_SIZE?
Ok with that understanding, If the align value is not a supported mapping size, we fail initializing the device.
Quoted 20 lines
Quoted 3 lines
Now w.r.t to failures, can device-dax do an opportunistic huge page usage?
device-dax explicitly disclaims the ability to do opportunistic mappings.
Quoted 3 lines
I haven't looked at the device-dax details fully yet. Do we make the assumption of the mapping page size as a format w.r.t device-dax? Is that derived from
nd_pfn->alignvalue?Correct.
Quoted 5 lines
Here is what I am working on:
1) If the platform doesn't support huge page and if the device superblock indicated that it was created with huge page support, we fail the device init.Ok.
Quoted 7 lines
Quoted 5 lines
2) Now if we are creating a new namespace without huge page support in the platform, then we force the align details to
PAGE_SIZE. In such a configuration when handling dax fault even with THP enabled during the build, we should not try to use hugepage. This I think we can achieve by usingTRANSPARENT_HUGEPAEG_DAX_FLAG.How is this dynamic property communicated to the guest?
via device tree on powerpc. We have a device tree node indicating supported page sizes.
Quoted 6 lines
Quoted 6 lines
Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.
Quoted 7 lines
Quoted 5 lines
This still doesn't cover the details of a device-dax created with
PAGE_SIZEalign later booted with a kernel that can do hugepage dax.How should we handle that? That makes me think, this should be a VMA flag which got derived from device config? May be useVM_HUGEPAGEto indicate if device should use a hugepage mapping or not?device-dax configured with
PAGE_SIZEalways getsPAGE_SIZEmappings.
Now what will be page size used for mapping vmemmap? Architectures possibly will use PMD_SIZE mapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned to PAGE_SIZE with the above example? We can't map that using PMD_SIZE page size?
-aneesh
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
On Wed, Mar 13, 2019 at 8:45 PM Aneesh Kumar K.V
<[email protected]> wrote:
[..]
Quoted 25 lines
Quoted 25 lines
Quoted 2 lines
Now w.r.t to failures, can device-dax do an opportunistic huge page usage?
device-dax explicitly disclaims the ability to do opportunistic mappings.
Quoted 3 lines
I haven't looked at the device-dax details fully yet. Do we make the assumption of the mapping page size as a format w.r.t device-dax? Is that derived from
nd_pfn->alignvalue?Correct.
Quoted 5 lines
Here is what I am working on:
1) If the platform doesn't support huge page and if the device superblock indicated that it was created with huge page support, we fail the device init.Ok.
Quoted 5 lines
2) Now if we are creating a new namespace without huge page support in the platform, then we force the align details to
PAGE_SIZE. In such a configuration when handling dax fault even with THP enabled during the build, we should not try to use hugepage. This I think we can achieve by usingTRANSPARENT_HUGEPAEG_DAX_FLAG.
Quoted 4 lines
Quoted 1 line
How is this dynamic property communicated to the guest?
via device tree on powerpc. We have a device tree node indicating supported page sizes.
Ah, ok, yeah let's plumb that straight to the device-dax driver and leave out the interaction / interpretation of the thp-enabled flags.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Also even if the user decided to not use THP, by
echo "never" > transparent_hugepage/enabled , we should continue to map dax fault using huge page on platforms that can support huge pages.This still doesn't cover the details of a device-dax created with
PAGE_SIZEalign later booted with a kernel that can do hugepage dax.How should we handle that? That makes me think, this should be a VMA flag which got derived from device config? May be useVM_HUGEPAGEto indicate if device should use a hugepage mapping or not?
Quoted 3 lines
Quoted 1 line
device-dax configured with
PAGE_SIZEalways getsPAGE_SIZEmappings.Now what will be page size used for mapping vmemmap?
That's up to the architecture's vmemmap_populate() implementation.
Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
Now, that said, I expect there may be bugs lurking in the implementation if PAGE_SIZE changes from one boot to the next simply because I've never tested that.
I think this also indicates that the section padding logic can't be removed until all arch vmemmap_populate() implementations understand the sub-section case.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?
Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using nd_pfn->align
if (nd_pfn->mode == PFN_MODE_PMEM) {
unsigned long memmap_size;
/*
* vmemmap_populate_hugepages() allocates the memmap array in
* HPAGE_SIZE chunks.
*/
memmap_size = ALIGN(64 * npfns, HPAGE_SIZE);
offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve,
nd_pfn->align) - start;
}IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Yes we find the npfns by aligning up using PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?
-aneesh
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 32 lines · Aneesh Kumar K.V
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using
nd_pfn->alignif (nd_pfn->mode == PFN_MODE_PMEM) { unsigned long memmap_size; /* * vmemmap_populate_hugepages() allocates the memmap array in * HPAGE_SIZE chunks. */ memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve, nd_pfn->align) - start; }
Quoted 7 lines
IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Yes we find the npfns by aligning up using
PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?
Also i guess those 4K assumptions there is wrong?
modified drivers/nvdimm/pfn_devs.c
@@ -783,7 +783,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
return -ENXIO;
}
- npfns = (size - offset - start_pad - end_trunc) / SZ_4K;
+ npfns = (size - offset - start_pad - end_trunc) / PAGE_SIZE;
pfn_sb->mode = cpu_to_le32(nd_pfn->mode);
pfn_sb->dataoff = cpu_to_le64(offset);
pfn_sb->npfns = cpu_to_le64(npfns);
-aneesh
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 35 lines · Aneesh Kumar K.V
Quoted 32 lines · Aneesh Kumar K.V
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using
nd_pfn->alignif (nd_pfn->mode == PFN_MODE_PMEM) { unsigned long memmap_size; /* * vmemmap_populate_hugepages() allocates the memmap array in * HPAGE_SIZE chunks. */ memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve, nd_pfn->align) - start; }
Quoted 3 lines
Quoted 3 lines
IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Right, that's the physical offset of where the vmemmap ends, and the memory to be mapped begins.
Quoted 5 lines
Quoted 3 lines
Yes we find the npfns by aligning up using
PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?Also i guess those 4K assumptions there is wrong?
Yes, I think to support non-4K-PAGE_SIZE systems the 'pfn' metadata needs to be revved and the PAGE_SIZE needs to be recorded in the info-block.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 49 lines · Dan Williams
Quoted 35 lines · Aneesh Kumar K.V
Quoted 32 lines · Aneesh Kumar K.V
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using
nd_pfn->alignif (nd_pfn->mode == PFN_MODE_PMEM) { unsigned long memmap_size; /* * vmemmap_populate_hugepages() allocates the memmap array in * HPAGE_SIZE chunks. */ memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve, nd_pfn->align) - start; }Quoted 3 lines
Quoted 3 lines
IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Right, that's the physical offset of where the vmemmap ends, and the memory to be mapped begins.
Quoted 4 lines
Quoted 3 lines
Yes we find the npfns by aligning up using
PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?
Quoted 5 lines
Quoted 1 line
Also i guess those 4K assumptions there is wrong?
Yes, I think to support non-4K-PAGE_SIZE systems the 'pfn' metadata needs to be revved and the
PAGE_SIZEneeds to be recorded in the info-block.
How often does a system change page-size. Is it fixed or do environment change it from one boot to the next? I'm thinking through the behavior of what do when the recorded PAGE_SIZE in the info-block does not match the current system page size. The simplest option is to just fail the device and require it to be reconfigured. Is that acceptable?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 57 lines · Dan Williams
Quoted 49 lines · Dan Williams
Quoted 35 lines · Aneesh Kumar K.V
Quoted 32 lines · Aneesh Kumar K.V
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using
nd_pfn->alignif (nd_pfn->mode == PFN_MODE_PMEM) { unsigned long memmap_size; /* * vmemmap_populate_hugepages() allocates the memmap array in * HPAGE_SIZE chunks. */ memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve, nd_pfn->align) - start; }Quoted 3 lines
Quoted 3 lines
IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Right, that's the physical offset of where the vmemmap ends, and the memory to be mapped begins.
Quoted 4 lines
Quoted 3 lines
Yes we find the npfns by aligning up using
PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?Quoted 5 lines
Quoted 1 line
Also i guess those 4K assumptions there is wrong?
Yes, I think to support non-4K-PAGE_SIZE systems the 'pfn' metadata needs to be revved and the
PAGE_SIZEneeds to be recorded in the info-block.
Quoted 6 lines
How often does a system change page-size. Is it fixed or do environment change it from one boot to the next? I'm thinking through the behavior of what do when the recorded
PAGE_SIZEin the info-block does not match the current system page size. The simplest option is to just fail the device and require it to be reconfigured. Is that acceptable?
The kernel page size is set at build time and as far as I know every distro configures their ppc64(le) kernel for 64K. I've used 4K kernels a few times in the past to debug PAGE_SIZE dependent problems, but I'd be surprised if anyone is using 4K in production.
Anyway, my view is that using 4K here isn't really a problem since it's just the accounting unit of the pfn superblock format. The kernel reading form it should understand that and scale it to whatever accounting unit it wants to use internally. Currently we don't so that should probably be fixed, but that doesn't seem to cause any real issues. As far as I can tell the only user of npfns in __nvdimm_setup_pfn() whih prints the "number of pfns truncated" message.
Am I missing something?
Quoted 4 lines
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default
Quoted 66 lines · Oliver
Quoted 57 lines · Dan Williams
Quoted 49 lines · Dan Williams
Quoted 35 lines · Aneesh Kumar K.V
Quoted 32 lines · Aneesh Kumar K.V
Quoted 11 lines · Dan Williams
Quoted 2 lines
Now what will be page size used for mapping vmemmap?
That's up to the architecture's
vmemmap_populate()implementation.Quoted 5 lines
Architectures
possibly will usePMD_SIZEmapping if supported for vmemmap. Now a device-dax with struct page in the device will have pfn reserve area aligned toPAGE_SIZEwith the above example? We can't map that usingPMD_SIZEpage size?Quoted 4 lines
IIUC, that's a different alignment. Currently that's handled by padding the reservation area up to a section (128MB on x86) boundary, but I'm working on patches to allow sub-section sized ranges to be mapped.
I am missing something w.r.t code. The below code align that using
nd_pfn->alignif (nd_pfn->mode == PFN_MODE_PMEM) { unsigned long memmap_size; /* * vmemmap_populate_hugepages() allocates the memmap array in * HPAGE_SIZE chunks. */ memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); offset = ALIGN(start + SZ_8K + memmap_size + dax_label_reserve, nd_pfn->align) - start; }Quoted 3 lines
Quoted 3 lines
IIUC that is finding the offset where to put vmemmap start. And that has to be aligned to the page size with which we may end up mapping vmemmap area right?
Right, that's the physical offset of where the vmemmap ends, and the memory to be mapped begins.
Quoted 4 lines
Quoted 3 lines
Yes we find the npfns by aligning up using
PAGES_PER_SECTION. But that is to compute howmany pfns we should map for this pfn dev right?Quoted 5 lines
Quoted 1 line
Also i guess those 4K assumptions there is wrong?
Yes, I think to support non-4K-PAGE_SIZE systems the 'pfn' metadata needs to be revved and the
PAGE_SIZEneeds to be recorded in the info-block.Quoted 6 lines
How often does a system change page-size. Is it fixed or do environment change it from one boot to the next? I'm thinking through the behavior of what do when the recorded
PAGE_SIZEin the info-block does not match the current system page size. The simplest option is to just fail the device and require it to be reconfigured. Is that acceptable?
Quoted 4 lines
The kernel page size is set at build time and as far as I know every distro configures their ppc64(le) kernel for 64K. I've used 4K kernels a few times in the past to debug
PAGE_SIZEdependent problems, but I'd be surprised if anyone is using 4K in production.
Ah, ok.
Quoted 10 lines
Anyway, my view is that using 4K here isn't really a problem since it's just the accounting unit of the pfn superblock format. The kernel reading form it should understand that and scale it to whatever accounting unit it wants to use internally. Currently we don't so that should probably be fixed, but that doesn't seem to cause any real issues. As far as I can tell the only user of npfns in
__nvdimm_setup_pfn()whih prints the "number of pfns truncated" message.Am I missing something?
No, I don't think so. The only time it would break is if a system with 64K page size laid down an info-block with not enough reserved capacity when the page-size is 4K (npfns too small). However, that sounds like an exceptional case which is why no problems have been reported to date.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 28 lines · Aneesh Kumar K.V
Architectures like ppc64 use the deposited page table to store hardware page table slot information. Make sure we deposit a page table when using zero page at the pmd level for hash.
Without this we hit
Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000082a74 Oops: Kernel access of bad area, sig: 11 [#1]....
NIP [
c000000000082a74]__hash_page_thp+0x224/0x5b0LR [c0000000000829a4]__hash_page_thp+0x154/0x5b0Call Trace: hash_page_mm+0x43c/0x740 do_hash_page+0x2c/0x3c copy_from_iter_flushcache+0xa4/0x4a0 pmem_copy_from_iter+0x2c/0x50 [nd_pmem] dax_copy_from_iter+0x40/0x70 dax_iomap_actor+0x134/0x360 iomap_apply+0xfc/0x1b0 dax_iomap_rw+0xac/0x130 ext4_file_write_iter+0x254/0x460 [ext4] __vfs_write+0x120/0x1e0 vfs_write+0xd8/0x220 SyS_write+0x6c/0x110 system_call+0x3c/0x130
Quoted 1 line
Signed-off-by Aneesh Kumar K.V <[email protected]>
Thanks for the patch. It looks good to me. You can add:
Quoted 3 lines
---
TODO:
* Add fixes tag
Probably this is a problem since initial PPC PMEM support, isn't it?
Honza
Quoted 61 lines
fs/dax.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)fs/dax.c +15
-0@@ -33,6 +33,7 @@#include <linux/sizes.h> #include <linux/mmu_notifier.h> #include <linux/iomap.h> +#include <asm/pgalloc.h> #include "internal.h" #define CREATE_TRACE_POINTS @@ -1410,7 +1411,9 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, {struct address_space *mapping = vmf->vma->vm_file->f_mapping;unsigned long pmd_addr = vmf->address &PMD_MASK ; +struct vm_area_struct *vma = vmf->vma;struct inode *inode = mapping->host; +pgtable_t pgtable =NULL ;struct page *zero_page;spinlock_t *ptl;pmd_t pmd_entry;@@ -1425,12 +1428,22 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, *entry =dax_insert_entry (xas, mapping, vmf, *entry, pfn,DAX_PMD |DAX_ZERO_PAGE , false); +if (arch_needs_pgtable_deposit ()) { + pgtable =pte_alloc_one (vma->vm_mm); +if (!pgtable) +return VM_FAULT_OOM ; + } + ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (!pmd_none (*(vmf->pmd))) {spin_unlock (ptl); goto fallback; } +if (pgtable) { +pgtable_trans_huge_deposit (vma->vm_mm, vmf->pmd, pgtable); +mm_inc_nr_ptes (vma->vm_mm); + } pmd_entry =mk_pmd (zero_page, vmf->vma->vm_page_prot); pmd_entry =pmd_mkhuge (pmd_entry);set_pmd_at (vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry);@@ -1439,6 +1452,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,return VM_FAULT_NOPAGE ; fallback: +if (pgtable) +pte_free (vma->vm_mm, pgtable);trace_dax_pmd_load_hole_fallback (inode, vmf, zero_page, *entry);return VM_FAULT_FALLBACK ; }Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 33 lines · Jan Kara
Quoted 28 lines · Aneesh Kumar K.V
Architectures like ppc64 use the deposited page table to store hardware page table slot information. Make sure we deposit a page table when using zero page at the pmd level for hash.
Without this we hit
Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000082a74 Oops: Kernel access of bad area, sig: 11 [#1]....
NIP [
c000000000082a74]__hash_page_thp+0x224/0x5b0LR [c0000000000829a4]__hash_page_thp+0x154/0x5b0Call Trace: hash_page_mm+0x43c/0x740 do_hash_page+0x2c/0x3c copy_from_iter_flushcache+0xa4/0x4a0 pmem_copy_from_iter+0x2c/0x50 [nd_pmem] dax_copy_from_iter+0x40/0x70 dax_iomap_actor+0x134/0x360 iomap_apply+0xfc/0x1b0 dax_iomap_rw+0xac/0x130 ext4_file_write_iter+0x254/0x460 [ext4] __vfs_write+0x120/0x1e0 vfs_write+0xd8/0x220 SyS_write+0x6c/0x110 system_call+0x3c/0x130Quoted 1 line
Signed-off-by Aneesh Kumar K.V <[email protected]>Thanks for the patch. It looks good to me. You can add:
Quoted 8 lines
Reviewed-by Jan Kara <[email protected]>Quoted 3 lines
---
TODO:
* Add fixes tagProbably this is a problem since initial PPC PMEM support, isn't it?
Considering ppc64 is the only broken architecture here, I guess I will use the commit that enabled PPC PMEM support here.
-aneesh