[PATCH 05/12] mm: Remove remaining uses of PFN_DEV

2025-05-29 Thread Alistair Popple
vmf_insert_mixed(). This is unnecessary as it is no longer checked, instead relying on pfn_valid() to determine if there is an associated page or not. Signed-off-by: Alistair Popple Reviewed-by: Christoph Hellwig --- drivers/gpu/drm/gma500/fbdev.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 5

[PATCH 12/12] mm/memremap: Remove unused devmap_managed_key

2025-05-28 Thread Alistair Popple
It's no longer used so remove it. Signed-off-by: Alistair Popple --- mm/memremap.c | 27 --- 1 file changed, 27 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 2ea5322..5deb181 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -38,30 +38,6 @@ unsigned

[PATCH 11/12] mm: Remove callers of pfn_t functionality

2025-05-28 Thread Alistair Popple
All PFN_* pfn_t flags have been removed. Therefore there is no longer a need for the pfn_t type and all uses can be replaced with normal pfns. Signed-off-by: Alistair Popple Reviewed-by: Christoph Hellwig --- arch/x86/mm/pat/memtype.c| 6 +- drivers/dax/device.c

[PATCH 07/12] mm: Remove redundant pXd_devmap calls

2025-05-28 Thread Alistair Popple
behaviour as it will always be false. Signed-off-by: Alistair Popple --- fs/dax.c | 5 ++--- include/linux/huge_mm.h| 10 -- include/linux/pgtable.h| 2 +- mm/hmm.c | 4 ++-- mm/huge_memory.c | 30 +- mm

[PATCH 10/12] mm: Remove devmap related functions and page table bits

2025-05-28 Thread Alistair Popple
Now that DAX and all other reference counts to ZONE_DEVICE pages are managed normally there is no need for the special devmap PTE/PMD/PUD page table bits. So drop all references to these, freeing up a software defined page table bit on architectures supporting it. Signed-off-by: Alistair Popple

[PATCH 09/12] powerpc: Remove checks for devmap pages and PMDs/PUDs

2025-05-28 Thread Alistair Popple
PFN_DEV no longer exists. This means no devmap PMDs or PUDs will be created, so checking for them is redundant. Instead mappings of pages that would have previously returned true for pXd_devmap() will return true for pXd_trans_huge() Signed-off-by: Alistair Popple --- arch/powerpc/mm/book3s64

[PATCH 08/12] mm/khugepaged: Remove redundant pmd_devmap() check

2025-05-28 Thread Alistair Popple
The only users of pmd_devmap were device dax and fs dax. The check for pmd_devmap() in check_pmd_state() is therefore redundant as callers explicitly check for is_zone_device_page(), so this check can be dropped. Signed-off-by: Alistair Popple --- mm/khugepaged.c | 2 -- 1 file changed, 2

[PATCH 02/12] mm: Convert pXd_devmap checks to vma_is_dax

2025-05-28 Thread Alistair Popple
pXd_devmap to skip DAX pages continue to do so by adding explicit checks of the VMA instead. Signed-off-by: Alistair Popple --- fs/userfaultfd.c | 2 +- mm/hmm.c | 2 +- mm/userfaultfd.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c

[PATCH 06/12] mm/gup: Remove pXX_devmap usage from get_user_pages()

2025-05-28 Thread Alistair Popple
memmap so there is no need to hold a reference on the pgmap data structure to ensure this. Furthermore mappings with PFN_DEV are no longer created, hence this effectively dead code anyway so can be removed. Signed-off-by: Alistair Popple --- include/linux/huge_mm.h | 3 +- mm/gup.c

[PATCH 04/12] mm: Convert vmf_insert_mixed() from using pte_devmap to pte_special

2025-05-28 Thread Alistair Popple
;t support pte_devmap so those will continue to rely on pfn_valid() to determine if the page can be mapped. Signed-off-by: Alistair Popple --- mm/hmm.c| 3 --- mm/memory.c | 20 ++-- mm/vmscan.c | 2 +- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/mm/hmm.c b/mm/h

[PATCH 00/12] mm: Remove pXX_devmap page table bit and pfn_t type

2025-05-28 Thread Alistair Popple
@lists.ozlabs.org Cc: linux-ri...@lists.infradead.org Cc: nvd...@lists.linux.dev Cc: linux-...@vger.kernel.org Cc: dri-de...@lists.freedesktop.org Cc: j...@groves.net Alistair Popple (12): mm: Remove PFN_MAP, PFN_SG_CHAIN and PFN_SG_LAST mm: Convert pXd_devmap checks to vma_is_dax mm/pagewalk: S

[PATCH 03/12] mm/pagewalk: Skip dax pages in pagewalk

2025-05-28 Thread Alistair Popple
Previously dax pages were skipped by the pagewalk code as pud_special() or vm_normal_page{_pmd}() would be false for DAX pages. Now that dax pages are refcounted normally that is no longer the case, so add explicit checks to skip them. Signed-off-by: Alistair Popple --- include/linux/memremap.h

[PATCH 01/12] mm: Remove PFN_MAP, PFN_SG_CHAIN and PFN_SG_LAST

2025-05-28 Thread Alistair Popple
The PFN_MAP flag is no longer used for anything, so remove it. The PFN_SG_CHAIN and PFN_SG_LAST flags never appear to have been used so also remove them. Signed-off-by: Alistair Popple Reviewed-by: Christoph Hellwig --- include/linux/pfn_t.h | 31 +++ mm

[PATCH v9 03/20] fs/dax: Don't skip locked entries when scanning entries

2025-02-27 Thread Alistair Popple
to make it clear that it may advance the iterator state. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- fs/dax.c | 50 +- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index b35f538..f5fdb43 1006

[PATCH v9 09/20] mm/gup: Remove redundant check for PCI P2PDMA page

2025-02-27 Thread Alistair Popple
PCI P2PDMA pages are not mapped with pXX_devmap PTEs therefore the check in __gup_device_huge() is redundant. Remove it Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Wiliams Acked-by: David Hildenbrand --- mm/gup.c | 5 - 1 file changed, 5 deletions

[PATCH v9 02/20] fs/dax: Return unmapped busy pages from dax_layout_busy_page_range()

2025-02-27 Thread Alistair Popple
user-space with mapping_mapped() and returns early if not, skipping the check for DMA busy pages. This is wrong as pages may still be undergoing DMA access even if they have subsequently been unmapped from user-space. Fix this by dropping the check for mapping_mapped(). Signed-off-by: Alistair

[PATCH v9 20/20] device/dax: Properly refcount device dax pages when mapping

2025-02-27 Thread Alistair Popple
t the pages normally as defined by vm_normal_page(). Signed-off-by: Alistair Popple Changes for v9: - Fix warnings when pgmap->ops isn't defined for FS_DAX, reported by Gerald Schaefer. --- drivers/dax/device.c | 15 +-- mm/memremap.c| 14 +++--- 2 file

Re: [PATCH v9 00/20] fs/dax: Fix ZONE_DEVICE page reference counts

2025-02-27 Thread Alistair Popple
tair On Fri, Feb 28, 2025 at 02:30:55PM +1100, Alistair Popple wrote: > Main updates since v8: > > - Fixed reading of bad pgmap in migrate_vma_collect_pmd() as reported/fixed >by Balbir. > > - Fixed bad warnings generated in free_zone_device_folio() when pgmap->ops >

[PATCH v9 07/20] fs/dax: Ensure all pages are idle prior to filesystem unmount

2025-02-27 Thread Alistair Popple
ystem block to be freed will not wait for the remote access to complete. Therefore a busy block may be reallocated to a new file leading to corruption. Signed-off-by: Alistair Popple --- Changes for v7: - Don't take locks during inode eviction as suggested by Darrick and therefore

[PATCH v9 00/20] fs/dax: Fix ZONE_DEVICE page reference counts

2025-02-27 Thread Alistair Popple
rchitectures that have devmap PTE bits defined. It also almost certainly allows further clean-up of the devmap managed functions, but I have left that as a future improvment. It also enables support for compound ZONE_DEVICE pages which is one of my primary motivators for doing this work. Signed-off-

[PATCH v9 06/20] fs/dax: Always remove DAX page-cache entries when breaking layouts

2025-02-27 Thread Alistair Popple
when the file-system calls dax_break_mapping() as part of it's truncate operation. This ensures only idle pages can be removed from the FS DAX page-cache and makes it easy to detect if a file-system hasn't called dax_break_mapping() prior to a truncate operation. Signed-off-by:

[PATCH v9 08/20] fs/dax: Remove PAGE_MAPPING_DAX_SHARED mapping flag

2025-02-27 Thread Alistair Popple
L, implying it is present in at least one address space. This also makes it easier for a future change to detect when a page is first mapped into an address space which requires special handling. Signed-off-by: Alistair Popple --- Changes for v8: - Rebased on mm-unstable which includes Matthe

[PATCH v9 19/20] fs/dax: Properly refcount fs dax pages

2025-02-27 Thread Alistair Popple
to remove the pgmap refcounting that is currently done in mm/gup.c. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- Changes for v8: - Rebased on mm-unstable - conflicts with Matthew's earlier changes. - Made dax_folio_put() easier to read thanks to David's s

[PATCH v9 18/20] dcssblk: Mark DAX broken, remove FS_DAX_LIMITED support

2025-02-27 Thread Alistair Popple
Gorbik Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Jan Kara Cc: Matthew Wilcox Cc: Christoph Hellwig Cc: Alistair Popple Signed-off-by: Dan Williams --- Documentation/filesystems/dax.rst | 1 - drivers/s390/block/Kconfig| 12 ++-- drivers/s390/block/dcssblk.c

[PATCH v9 17/20] mm/gup: Don't allow FOLL_LONGTERM pinning of FS DAX pages

2025-02-27 Thread Alistair Popple
Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Signed-off-by: Alistair Popple Reviewed-by: John Hubbard

[PATCH v9 15/20] mm/huge_memory: Add vmf_insert_folio_pud()

2025-02-27 Thread Alistair Popple
current mechanism, vmf_insert_pfn_pud, which simply inserts a special devmap PUD entry into the page table without holding a reference to the page for the mapping. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- Changes for v7: - Added a comment

[PATCH v9 12/20] mm/memory: Enhance insert_page_into_pte_locked() to create writable mappings

2025-02-27 Thread Alistair Popple
In preparation for using insert_page() for DAX, enhance insert_page_into_pte_locked() to handle establishing writable mappings. Recall that DAX returns VM_FAULT_NOPAGE after installing a PTE which bypasses the typical set_pte_range() in finish_fault. Signed-off-by: Alistair Popple Suggested-by

[PATCH v9 16/20] mm/huge_memory: Add vmf_insert_folio_pmd()

2025-02-27 Thread Alistair Popple
(). This is because PTE faults require only a subpage of the folio to be PTE mapped rather than the entire folio. It would be possible to add this context somewhere but callers already need to handle PTE faults and PMD faults separately so a more generic function is not useful. Signed-off-by: Alistair

[PATCH v9 13/20] mm/memory: Add vmf_insert_page_mkwrite()

2025-02-27 Thread Alistair Popple
-off-by: Alistair Popple Acked-by: David Hildenbrand --- Changes for v8: - Remove temp suggested by David. Changes for v7: - Fix vmf_insert_page_mkwrite by removing pfn gunk as suggested by David. Updates from v2: - Rename function to make not DAX specific - Split the

[PATCH v9 14/20] mm/rmap: Add support for PUD sized mappings to rmap

2025-02-27 Thread Alistair Popple
PUD-sized folios so we don't support for that for now. Signed-off-by: Alistair Popple Acked-by: David Hildenbrand Reviewed-by: Dan Williams --- Changes for v8: - Rebase on mm-unstable, only a minor conflict due to code addition at the same place. Changes for v6: - Minor comment

[PATCH v9 11/20] mm: Allow compound zone device pages

2025-02-27 Thread Alistair Popple
>pgmap. The page->pgmap field must be common to all pages within a folio, even if the folio spans memory sections. Therefore pgmap is the same for both head and tail pages and can be moved into the folio and we can use the standard scheme to find compound_head from a tail page. Signed-off-

[PATCH v9 10/20] mm/mm_init: Move p2pdma page refcount initialisation to p2pdma

2025-02-27 Thread Alistair Popple
refcount as required. P2PDMA uses vm_insert_page() to map the page, and that requires a non-zero reference count when initialising the page so set that when the page is first mapped. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- Changes since v2

[PATCH v9 04/20] fs/dax: Refactor wait for dax idle page

2025-02-27 Thread Alistair Popple
A FS DAX page is considered idle when its refcount drops to one. This is currently open-coded in all file systems supporting FS DAX. Move the idle detection to a common function to make future changes easier. Signed-off-by: Alistair Popple Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig

[PATCH v9 05/20] fs/dax: Create a common implementation to break DAX layouts

2025-02-27 Thread Alistair Popple
: Alistair Popple Reviewed-by: Dan Williams --- Changes for v7: - Fix smatch warning, also reported by Dan and Darrick - Make sure xfs_break_layouts() can return -ERESTARTSYS, reported by Darrick - Use common definition of dax_page_is_idle() - Removed misplaced hunk changing madvise

[PATCH v9 01/20] fuse: Fix dax truncate/punch_hole fault path

2025-02-27 Thread Alistair Popple
to fuse_dax_break_layouts() which will invalidate the entire file range to dax_layout_busy_page_range(). Signed-off-by: Alistair Popple Co-developed-by: Dan Williams Signed-off-by: Dan Williams Reviewed-by: Balbir Singh Fixes: 6ae330cad6ef ("virtiofs: serialize truncate/punch_hole and dax

Re: [PATCH v8 20/20] device/dax: Properly refcount device dax pages when mapping

2025-02-24 Thread Alistair Popple
On Thu, Feb 20, 2025 at 07:33:34PM +0100, Gerald Schaefer wrote: > On Tue, 18 Feb 2025 14:55:36 +1100 > Alistair Popple wrote: > > [...] > > diff --git a/mm/memremap.c b/mm/memremap.c > > index 9a8879b..532a52a 100644 > > --- a/mm/memremap.c > > +++ b/mm/memre

Re: [PATCH v8 19/20] fs/dax: Properly refcount fs dax pages

2025-02-18 Thread Alistair Popple
On Tue, Feb 18, 2025 at 12:37:28PM +0100, David Hildenbrand wrote: > On 18.02.25 04:55, Alistair Popple wrote: > > Currently fs dax pages are considered free when the refcount drops to > > one and their refcounts are not increased when mapped via PTEs or > > decreased when un

[PATCH v8 14/20] mm/rmap: Add support for PUD sized mappings to rmap

2025-02-17 Thread Alistair Popple
PUD-sized folios so we don't support for that for now. Signed-off-by: Alistair Popple Acked-by: David Hildenbrand Reviewed-by: Dan Williams --- Changes for v8: - Rebase on mm-unstable, only a minor conflict due to code addition at the same place. Changes for v6: - Minor comment

[PATCH v8 05/20] fs/dax: Create a common implementation to break DAX layouts

2025-02-17 Thread Alistair Popple
: Alistair Popple Reviewed-by: Dan Williams --- Changes for v7: - Fix smatch warning, also reported by Dan and Darrick - Make sure xfs_break_layouts() can return -ERESTARTSYS, reported by Darrick - Use common definition of dax_page_is_idle() - Removed misplaced hunk changing madvise

[PATCH v8 19/20] fs/dax: Properly refcount fs dax pages

2025-02-17 Thread Alistair Popple
to remove the pgmap refcounting that is currently done in mm/gup.c. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- Changes for v8: - Rebased on mm-unstable - conflicts with Matthew's earlier changes. - Made dax_folio_put() easier to read thanks to David's s

[PATCH v8 09/20] mm/gup: Remove redundant check for PCI P2PDMA page

2025-02-17 Thread Alistair Popple
PCI P2PDMA pages are not mapped with pXX_devmap PTEs therefore the check in __gup_device_huge() is redundant. Remove it Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Wiliams Acked-by: David Hildenbrand --- mm/gup.c | 5 - 1 file changed, 5 deletions

[PATCH v8 08/20] fs/dax: Remove PAGE_MAPPING_DAX_SHARED mapping flag

2025-02-17 Thread Alistair Popple
L, implying it is present in at least one address space. This also makes it easier for a future change to detect when a page is first mapped into an address space which requires special handling. Signed-off-by: Alistair Popple --- Changes for v8: - Rebased on mm-unstable which includes Matthe

[PATCH v8 20/20] device/dax: Properly refcount device dax pages when mapping

2025-02-17 Thread Alistair Popple
t the pages normally as defined by vm_normal_page(). Signed-off-by: Alistair Popple --- drivers/dax/device.c | 15 +-- mm/memremap.c| 13 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index bc871a3..32

[PATCH v8 18/20] dcssblk: Mark DAX broken, remove FS_DAX_LIMITED support

2025-02-17 Thread Alistair Popple
Gorbik Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Jan Kara Cc: Matthew Wilcox Cc: Christoph Hellwig Cc: Alistair Popple Signed-off-by: Dan Williams --- Documentation/filesystems/dax.rst | 1 - drivers/s390/block/Kconfig| 12 ++-- drivers/s390/block/dcssblk.c

[PATCH v8 13/20] mm/memory: Add vmf_insert_page_mkwrite()

2025-02-17 Thread Alistair Popple
-off-by: Alistair Popple Acked-by: David Hildenbrand --- Changes for v8: - Remove temp suggested by David. Changes for v7: - Fix vmf_insert_page_mkwrite by removing pfn gunk as suggested by David. Updates from v2: - Rename function to make not DAX specific - Split the

[PATCH v8 17/20] mm/gup: Don't allow FOLL_LONGTERM pinning of FS DAX pages

2025-02-17 Thread Alistair Popple
Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Signed-off-by: Alistair Popple Reviewed-by: John Hubbard

[PATCH v8 16/20] mm/huge_memory: Add vmf_insert_folio_pmd()

2025-02-17 Thread Alistair Popple
(). This is because PTE faults require only a subpage of the folio to be PTE mapped rather than the entire folio. It would be possible to add this context somewhere but callers already need to handle PTE faults and PMD faults separately so a more generic function is not useful. Signed-off-by: Alistair

[PATCH v8 15/20] mm/huge_memory: Add vmf_insert_folio_pud()

2025-02-17 Thread Alistair Popple
current mechanism, vmf_insert_pfn_pud, which simply inserts a special devmap PUD entry into the page table without holding a reference to the page for the mapping. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- Changes for v7: - Added a comment

[PATCH v8 12/20] mm/memory: Enhance insert_page_into_pte_locked() to create writable mappings

2025-02-17 Thread Alistair Popple
In preparation for using insert_page() for DAX, enhance insert_page_into_pte_locked() to handle establishing writable mappings. Recall that DAX returns VM_FAULT_NOPAGE after installing a PTE which bypasses the typical set_pte_range() in finish_fault. Signed-off-by: Alistair Popple Suggested-by

[PATCH v8 11/20] mm: Allow compound zone device pages

2025-02-17 Thread Alistair Popple
>pgmap. The page->pgmap field must be common to all pages within a folio, even if the folio spans memory sections. Therefore pgmap is the same for both head and tail pages and can be moved into the folio and we can use the standard scheme to find compound_head from a tail page. Signed-off-

[PATCH v8 10/20] mm/mm_init: Move p2pdma page refcount initialisation to p2pdma

2025-02-17 Thread Alistair Popple
refcount as required. P2PDMA uses vm_insert_page() to map the page, and that requires a non-zero reference count when initialising the page so set that when the page is first mapped. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- Changes since v2

[PATCH v8 07/20] fs/dax: Ensure all pages are idle prior to filesystem unmount

2025-02-17 Thread Alistair Popple
ystem block to be freed will not wait for the remote access to complete. Therefore a busy block may be reallocated to a new file leading to corruption. Signed-off-by: Alistair Popple --- Changes for v7: - Don't take locks during inode eviction as suggested by Darrick and therefore

[PATCH v8 03/20] fs/dax: Don't skip locked entries when scanning entries

2025-02-17 Thread Alistair Popple
to make it clear that it may advance the iterator state. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- fs/dax.c | 50 +- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index b35f538..f5fdb43 1006

[PATCH v8 06/20] fs/dax: Always remove DAX page-cache entries when breaking layouts

2025-02-17 Thread Alistair Popple
when the file-system calls dax_break_mapping() as part of it's truncate operation. This ensures only idle pages can be removed from the FS DAX page-cache and makes it easy to detect if a file-system hasn't called dax_break_mapping() prior to a truncate operation. Signed-off-by:

[PATCH v8 04/20] fs/dax: Refactor wait for dax idle page

2025-02-17 Thread Alistair Popple
A FS DAX page is considered idle when its refcount drops to one. This is currently open-coded in all file systems supporting FS DAX. Move the idle detection to a common function to make future changes easier. Signed-off-by: Alistair Popple Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig

[PATCH v8 00/20] fs/dax: Fix ZONE_DEVICE page reference counts

2025-02-17 Thread Alistair Popple
ts defined. It also almost certainly allows further clean-up of the devmap managed functions, but I have left that as a future improvment. It also enables support for compound ZONE_DEVICE pages which is one of my primary motivators for doing this work. Signed-off-by: Alistair Popple Tested-by: Alison

[PATCH v8 02/20] fs/dax: Return unmapped busy pages from dax_layout_busy_page_range()

2025-02-17 Thread Alistair Popple
user-space with mapping_mapped() and returns early if not, skipping the check for DMA busy pages. This is wrong as pages may still be undergoing DMA access even if they have subsequently been unmapped from user-space. Fix this by dropping the check for mapping_mapped(). Signed-off-by: Alistair

[PATCH v8 01/20] fuse: Fix dax truncate/punch_hole fault path

2025-02-17 Thread Alistair Popple
to fuse_dax_break_layouts() which will invalidate the entire file range to dax_layout_busy_page_range(). Signed-off-by: Alistair Popple Co-developed-by: Dan Williams Signed-off-by: Dan Williams Reviewed-by: Balbir Singh Fixes: 6ae330cad6ef ("virtiofs: serialize truncate/punch_hole and dax

Re: [PATCH v7 16/20] huge_memory: Add vmf_insert_folio_pmd()

2025-02-16 Thread Alistair Popple
On Mon, Feb 10, 2025 at 07:45:09PM +0100, David Hildenbrand wrote: > On 04.02.25 23:48, Alistair Popple wrote: > > Currently DAX folio/page reference counts are managed differently to normal > > pages. To allow these to be managed the same as normal pages introduce > > vmf_i

Re: [PATCH v6 21/26] fs/dax: Properly refcount fs dax pages

2025-02-09 Thread Alistair Popple
On Thu, Feb 06, 2025 at 09:50:07PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > On Mon, Jan 13, 2025 at 07:35:07PM -0800, Dan Williams wrote: > > > Alistair Popple wrote: > > > > [...] > > > > > ...and here is that aformentioned patch: &

Re: [PATCH v6 23/26] mm: Remove pXX_devmap callers

2025-02-05 Thread Alistair Popple
On Tue, Feb 04, 2025 at 11:06:08AM -0800, Dan Williams wrote: > Alistair Popple wrote: > > On Tue, Jan 14, 2025 at 10:50:49AM -0800, Dan Williams wrote: > > > Alistair Popple wrote: > > > > The devmap PTE special bit was used to detect mappings of FS DAX > > &

[PATCH v7 12/20] mm/memory: Enhance insert_page_into_pte_locked() to create writable mappings

2025-02-04 Thread Alistair Popple
In preparation for using insert_page() for DAX, enhance insert_page_into_pte_locked() to handle establishing writable mappings. Recall that DAX returns VM_FAULT_NOPAGE after installing a PTE which bypasses the typical set_pte_range() in finish_fault. Signed-off-by: Alistair Popple Suggested-by

[PATCH v7 20/20] device/dax: Properly refcount device dax pages when mapping

2025-02-04 Thread Alistair Popple
t the pages normally as defined by vm_normal_page(). Signed-off-by: Alistair Popple --- drivers/dax/device.c | 15 +-- mm/memremap.c| 13 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 6d74e62..fd

[PATCH v7 19/20] fs/dax: Properly refcount fs dax pages

2025-02-04 Thread Alistair Popple
to remove the pgmap refcounting that is currently done in mm/gup.c. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- Changes for v7: - s/dax_device_folio_init/dax_folio_init/ as suggested by Dan - s/dax_folio_share_put/dax_folio_put/ Changes since v2: Based on some questions

[PATCH v7 18/20] dcssblk: Mark DAX broken, remove FS_DAX_LIMITED support

2025-02-04 Thread Alistair Popple
Gorbik Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Jan Kara Cc: Matthew Wilcox Cc: Christoph Hellwig Cc: Alistair Popple Signed-off-by: Dan Williams --- Documentation/filesystems/dax.rst | 1 - drivers/s390/block/Kconfig| 12 ++-- drivers/s390/block/dcssblk.c

[PATCH v7 15/20] huge_memory: Add vmf_insert_folio_pud()

2025-02-04 Thread Alistair Popple
current mechanism, vmf_insert_pfn_pud, which simply inserts a special devmap PUD entry into the page table without holding a reference to the page for the mapping. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- Changes for v7: - Added a comment clarifying why we can insert without

[PATCH v7 17/20] mm/gup: Don't allow FOLL_LONGTERM pinning of FS DAX pages

2025-02-04 Thread Alistair Popple
Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Signed-off-by: Alistair Popple Reviewed-by: John Hubbard

[PATCH v7 16/20] huge_memory: Add vmf_insert_folio_pmd()

2025-02-04 Thread Alistair Popple
(). This is because PTE faults require only a subpage of the folio to be PTE mapped rather than the entire folio. It would be possible to add this context somewhere but callers already need to handle PTE faults and PMD faults separately so a more generic function is not useful. Signed-off-by: Alistair

[PATCH v7 14/20] rmap: Add support for PUD sized mappings to rmap

2025-02-04 Thread Alistair Popple
PUD-sized folios so we don't support for that for now. Signed-off-by: Alistair Popple Acked-by: David Hildenbrand Reviewed-by: Dan Williams --- Changes for v6: - Minor comment formatting fix - Add an additional check for CONFIG_TRANSPARENT_HUGEPAGE to fix a buil

[PATCH v7 13/20] mm/memory: Add vmf_insert_page_mkwrite()

2025-02-04 Thread Alistair Popple
-off-by: Alistair Popple --- Changes for v7: - Fix vmf_insert_page_mkwrite by removing pfn gunk as suggested by David. Updates from v2: - Rename function to make not DAX specific - Split the insert_page_into_pte_locked() change into a separate patch. Updates from v1: - Re-arrange

[PATCH v7 11/20] mm: Allow compound zone device pages

2025-02-04 Thread Alistair Popple
>pgmap. The page->pgmap field must be common to all pages within a folio, even if the folio spans memory sections. Therefore pgmap is the same for both head and tail pages and can be moved into the folio and we can use the standard scheme to find compound_head from a tail page. Signed-off-

[PATCH v7 10/20] mm/mm_init: Move p2pdma page refcount initialisation to p2pdma

2025-02-04 Thread Alistair Popple
refcount as required. P2PDMA uses vm_insert_page() to map the page, and that requires a non-zero reference count when initialising the page so set that when the page is first mapped. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- Changes since v2

[PATCH v7 09/20] mm/gup: Remove redundant check for PCI P2PDMA page

2025-02-04 Thread Alistair Popple
PCI P2PDMA pages are not mapped with pXX_devmap PTEs therefore the check in __gup_device_huge() is redundant. Remove it Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Wiliams Acked-by: David Hildenbrand --- mm/gup.c | 5 - 1 file changed, 5 deletions

[PATCH v7 06/20] fs/dax: Always remove DAX page-cache entries when breaking layouts

2025-02-04 Thread Alistair Popple
when the file-system calls dax_break_mapping() as part of it's truncate operation. This ensures only idle pages can be removed from the FS DAX page-cache and makes it easy to detect if a file-system hasn't called dax_break_mapping() prior to a truncate operation. Signed-off-by:

[PATCH v7 08/20] fs/dax: Remove PAGE_MAPPING_DAX_SHARED mapping flag

2025-02-04 Thread Alistair Popple
L, implying it is present in at least one address space. This also makes it easier for a future change to detect when a page is first mapped into an address space which requires special handling. Signed-off-by: Alistair Popple --- Changes for v7: - Fix for checking when creating a

[PATCH v7 07/20] fs/dax: Ensure all pages are idle prior to filesystem unmount

2025-02-04 Thread Alistair Popple
ystem block to be freed will not wait for the remote access to complete. Therefore a busy block may be reallocated to a new file leading to corruption. Signed-off-by: Alistair Popple --- Changes for v7: - Don't take locks during inode eviction as suggested by Darrick and therefore

[PATCH v7 05/20] fs/dax: Create a common implementation to break DAX layouts

2025-02-04 Thread Alistair Popple
: Alistair Popple Reviewed-by: Dan Williams --- Changes for v7: - Fix smatch warning, also reported by Dan and Darrick - Make sure xfs_break_layouts() can return -ERESTARTSYS, reported by Darrick - Use common definition of dax_page_is_idle() - Removed misplaced hunk changing madvise

[PATCH v7 04/20] fs/dax: Refactor wait for dax idle page

2025-02-04 Thread Alistair Popple
A FS DAX page is considered idle when its refcount drops to one. This is currently open-coded in all file systems supporting FS DAX. Move the idle detection to a common function to make future changes easier. Signed-off-by: Alistair Popple Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig

[PATCH v7 02/20] fs/dax: Return unmapped busy pages from dax_layout_busy_page_range()

2025-02-04 Thread Alistair Popple
user-space with mapping_mapped() and returns early if not, skipping the check for DMA busy pages. This is wrong as pages may still be undergoing DMA access even if they have subsequently been unmapped from user-space. Fix this by dropping the check for mapping_mapped(). Signed-off-by: Alistair

[PATCH v7 03/20] fs/dax: Don't skip locked entries when scanning entries

2025-02-04 Thread Alistair Popple
to make it clear that it may advance the iterator state. Signed-off-by: Alistair Popple Reviewed-by: Dan Williams --- fs/dax.c | 50 +- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 5133568..d010c10 1006

[PATCH v7 01/20] fuse: Fix dax truncate/punch_hole fault path

2025-02-04 Thread Alistair Popple
to fuse_dax_break_layouts() which will invalidate the entire file range to dax_layout_busy_page_range(). Signed-off-by: Alistair Popple Co-developed-by: Dan Williams Signed-off-by: Dan Williams Fixes: 6ae330cad6ef ("virtiofs: serialize truncate/punch_hole and dax fault path") Cc: V

[PATCH v7 00/20] fs/dax: Fix ZONE_DEVICE page reference counts

2025-02-04 Thread Alistair Popple
ts defined. It also almost certainly allows further clean-up of the devmap managed functions, but I have left that as a future improvment. It also enables support for compound ZONE_DEVICE pages which is one of my primary motivators for doing this work. Signed-off-by: Alistair Popple Tested-by: Alison

Re: [PATCH v6 22/26] device/dax: Properly refcount device dax pages when mapping

2025-02-03 Thread Alistair Popple
On Mon, Jan 13, 2025 at 10:12:41PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > Device DAX pages are currently not reference counted when mapped, > > instead relying on the devmap PTE bit to ensure mapping code will not > > get/put references. This requires specia

Re: [PATCH v6 20/26] mm/mlock: Skip ZONE_DEVICE PMDs during mlock

2025-01-16 Thread Alistair Popple
On Mon, Jan 13, 2025 at 06:42:46PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > At present mlock skips ptes mapping ZONE_DEVICE pages. A future change > > to remove pmd_devmap will allow pmd_trans_huge_lock() to return > > ZONE_DEVICE folios so make sure we c

Re: [PATCH v6 19/26] proc/task_mmu: Mark devdax and fsdax pages as always unpinned

2025-01-16 Thread Alistair Popple
On Tue, Jan 14, 2025 at 05:45:46PM +0100, David Hildenbrand wrote: > On 14.01.25 03:28, Dan Williams wrote: > > Alistair Popple wrote: > > > The procfs mmu files such as smaps and pagemap currently ignore devdax and > > > fsdax pages because these pages are consider

Re: [PATCH v6 11/26] mm: Allow compound zone device pages

2025-01-16 Thread Alistair Popple
On Tue, Jan 14, 2025 at 03:59:31PM +0100, David Hildenbrand wrote: > On 10.01.25 07:00, Alistair Popple wrote: > > Zone device pages are used to represent various type of device memory > > managed by device drivers. Currently compound zone device pages are > > not suppo

Re: [PATCH v6 08/26] fs/dax: Remove PAGE_MAPPING_DAX_SHARED mapping flag

2025-01-16 Thread Alistair Popple
On Tue, Jan 14, 2025 at 09:44:38PM -0800, Dan Williams wrote: > Alistair Popple wrote: > [..] > > > How does this case happen? I don't think any page would ever enter with > > > both ->mapping and ->share set, right? > > > > Sigh. You're right

Re: [PATCH v6 23/26] mm: Remove pXX_devmap callers

2025-01-14 Thread Alistair Popple
On Tue, Jan 14, 2025 at 10:50:49AM -0800, Dan Williams wrote: > Alistair Popple wrote: > > The devmap PTE special bit was used to detect mappings of FS DAX > > pages. This tracking was required to ensure the generic mm did not > > manipulate the page reference counts as FS DAX

Re: [PATCH v6 16/26] huge_memory: Add vmf_insert_folio_pmd()

2025-01-14 Thread Alistair Popple
On Tue, Jan 14, 2025 at 09:22:00AM -0800, Dan Williams wrote: > David Hildenbrand wrote: > > > +vm_fault_t vmf_insert_folio_pmd(struct vm_fault *vmf, struct folio > > > *folio, bool write) > > > +{ > > > + struct vm_area_struct *vma = vmf->vma; > > > + unsigned long addr = vmf->address & PMD_MASK;

Re: [PATCH v6 15/26] huge_memory: Add vmf_insert_folio_pud()

2025-01-14 Thread Alistair Popple
On Tue, Jan 14, 2025 at 05:22:15PM +0100, David Hildenbrand wrote: > On 10.01.25 07:00, Alistair Popple wrote: > > Currently DAX folio/page reference counts are managed differently to > > normal pages. To allow these to be managed the same as normal pages > > introduce vmf_i

Re: [PATCH v6 13/26] mm/memory: Add vmf_insert_page_mkwrite()

2025-01-14 Thread Alistair Popple
On Tue, Jan 14, 2025 at 05:15:54PM +0100, David Hildenbrand wrote: > On 10.01.25 07:00, Alistair Popple wrote: > > Currently to map a DAX page the DAX driver calls vmf_insert_pfn. This > > creates a special devmap PTE entry for the pfn but does not take a > > reference on

Re: [PATCH v6 12/26] mm/memory: Enhance insert_page_into_pte_locked() to create writable mappings

2025-01-14 Thread Alistair Popple
On Mon, Jan 13, 2025 at 05:08:31PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > In preparation for using insert_page() for DAX, enhance > > insert_page_into_pte_locked() to handle establishing writable > > mappings. Recall that DAX returns VM_FAULT_NOPAGE after

Re: [PATCH v6 08/26] fs/dax: Remove PAGE_MAPPING_DAX_SHARED mapping flag

2025-01-14 Thread Alistair Popple
On Mon, Jan 13, 2025 at 04:52:34PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > PAGE_MAPPING_DAX_SHARED is the same as PAGE_MAPPING_ANON. > > I think a bit a bit more detail is warranted, how about? > > The page ->mapping pointer can have magic values like &

Re: [PATCH v6 07/26] fs/dax: Ensure all pages are idle prior to filesystem unmount

2025-01-12 Thread Alistair Popple
On Sun, Jan 12, 2025 at 06:49:40PM -0800, Darrick J. Wong wrote: > On Mon, Jan 13, 2025 at 11:57:18AM +1100, Alistair Popple wrote: > > On Fri, Jan 10, 2025 at 08:50:19AM -0800, Darrick J. Wong wrote: > > > On Fri, Jan 10, 2025 at 05:00:35PM +1100, Alistair Popple wrote: > &g

Re: [PATCH v6 21/26] fs/dax: Properly refcount fs dax pages

2025-01-12 Thread Alistair Popple
On Fri, Jan 10, 2025 at 08:54:55AM -0800, Darrick J. Wong wrote: > On Fri, Jan 10, 2025 at 05:00:49PM +1100, Alistair Popple wrote: > > Currently fs dax pages are considered free when the refcount drops to > > one and their refcounts are not increased when mapped via PTEs or >

Re: [PATCH v6 00/26] fs/dax: Fix ZONE_DEVICE page reference counts

2025-01-12 Thread Alistair Popple
On Fri, Jan 10, 2025 at 07:35:57PM -0800, Dan Williams wrote: > Andrew Morton wrote: > > On Thu, 9 Jan 2025 23:05:56 -0800 Dan Williams > > wrote: > > > > > > - Remove PTE_DEVMAP definitions from Loongarch which were added since > > > >this series was initially written. > > > [..] > > > >

Re: [PATCH v6 07/26] fs/dax: Ensure all pages are idle prior to filesystem unmount

2025-01-12 Thread Alistair Popple
On Fri, Jan 10, 2025 at 08:50:19AM -0800, Darrick J. Wong wrote: > On Fri, Jan 10, 2025 at 05:00:35PM +1100, Alistair Popple wrote: > > File systems call dax_break_mapping() prior to reallocating file > > system blocks to ensure the page is not undergoing any DMA or other > >

Re: [PATCH v6 05/26] fs/dax: Create a common implementation to break DAX layouts

2025-01-12 Thread Alistair Popple
On Fri, Jan 10, 2025 at 08:44:38AM -0800, Darrick J. Wong wrote: > On Fri, Jan 10, 2025 at 05:00:33PM +1100, Alistair Popple wrote: > > Prior to freeing a block file systems supporting FS DAX must check > > that the associated pages are both unmapped from user-space and not > &

[PATCH v6 25/26] Revert "riscv: mm: Add support for ZONE_DEVICE"

2025-01-09 Thread Alistair Popple
DEVMAP PTEs are no longer required to support ZONE_DEVICE so remove them. Signed-off-by: Alistair Popple Suggested-by: Chunyan Zhang Reviewed-by: Björn Töpel --- arch/riscv/Kconfig| 1 - arch/riscv/include/asm/pgtable-64.h | 20 arch/riscv/include

[PATCH v6 24/26] mm: Remove devmap related functions and page table bits

2025-01-09 Thread Alistair Popple
Now that DAX and all other reference counts to ZONE_DEVICE pages are managed normally there is no need for the special devmap PTE/PMD/PUD page table bits. So drop all references to these, freeing up a software defined page table bit on architectures supporting it. Signed-off-by: Alistair Popple

  1   2   3   4   5   6   7   >