mm-use-pte-markers-for-swap-errors.patch removed from -mm tree
The quilt patch titled
Subject: mm: use pte markers for swap errors
has been removed from the -mm tree. Its filename was
mm-use-pte-markers-for-swap-errors.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Peter Xu <[email protected]>
Subject: mm: use pte markers for swap errors
Date: Sun, 30 Oct 2022 17:41:51 -0400
PTE markers are ideal mechanism for things like SWP_SWAPIN_ERROR. Using a whole swap entry type for this purpose can be an overkill, especially if we already have PTE markers. Define a new bit for swapin error and replace it with pte markers. Then we can safely drop SWP_SWAPIN_ERROR and give one device slot back to swap.
We used to have SWP_SWAPIN_ERROR taking the page pfn as part of the swap entry, but it's never used. Neither do I see how it can be useful because normally the swapin failure should not be caused by a bad page but bad swap device. Drop it alongside.
---
include/linux/swap.h | 6 +----- include/linux/swapops.h | 26 ++++++++++++++------------ mm/memory.c | 6 ++++-- mm/shmem.c | 2 +- mm/swapfile.c | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-use-pte-markers-for-swap-errors +1 -5
@@ -55,10 +55,6 @@ static inline int current_is_kswapd(void* actions on faults. */ -#define SWP_SWAPIN_ERROR_NUM 1 -#define SWP_SWAPIN_ERROR (MAX_SWAPFILES + SWP_HWPOISON_NUM + \ - SWP_MIGRATION_NUM + SWP_DEVICE_NUM + \ - SWP_PTE_MARKER_NUM)/* * PTE markers are used to persist information onto PTEs that otherwise * should be a none pte. As its name "PTE" hints, it should only be
@@ -121,7 +117,7 @@ static inline int current_is_kswapd(void#define MAX_SWAPFILES \ ((1 << MAX_SWAPFILES_SHIFT) - SWP_DEVICE_NUM - \ SWP_MIGRATION_NUM - SWP_HWPOISON_NUM - \ - SWP_PTE_MARKER_NUM - SWP_SWAPIN_ERROR_NUM) + SWP_PTE_MARKER_NUM)/* * Magic header for a swap area. The first part of the union is
include/linux/swapops.h renamed from include/linux/swapops.h~mm-use-pte-markers-for-swap-errors +14 -12
@@ -162,16 +162,6 @@ static inline void *swp_to_radix_entry(sreturn xa_mk_value (entry.val); } -static inline swp_entry_t make_swapin_error_entry (struct page *page) -{ -return swp_entry (SWP_SWAPIN_ERROR ,page_to_pfn (page)); -} - -static inline int is_swapin_error_entry (swp_entry_t entry) -{ -return swp_type (entry) ==SWP_SWAPIN_ERROR ; -} -#if IS_ENABLED (CONFIG_DEVICE_PRIVATE )static inline swp_entry_t make_readable_device_private_entry (pgoff_t offset) {
@@ -409,8 +399,9 @@ static inline bool is_migration_entry_ditypedef unsigned long pte_marker ; -#define PTE_MARKER_UFFD_WP BIT(0) -#define PTE_MARKER_MASK (PTE_MARKER_UFFD_WP) +#define PTE_MARKER_UFFD_WP BIT(0) +#define PTE_MARKER_SWAPIN_ERROR BIT(1) +#define PTE_MARKER_MASK (BIT(2) - 1)static inline swp_entry_t make_pte_marker_entry (pte_marker marker) {
@@ -437,6 +428,17 @@ static inline pte_t make_pte_marker(pte_return swp_entry_to_pte (make_pte_marker_entry (marker)); } +static inline swp_entry_t make_swapin_error_entry (void ) +{ +return make_pte_marker_entry (PTE_MARKER_SWAPIN_ERROR ); +} + +static inline int is_swapin_error_entry (swp_entry_t entry) +{ +return is_pte_marker_entry (entry) && + (pte_marker_get (entry) &PTE_MARKER_SWAPIN_ERROR ); +} +/* * This is a special version to check pte_none() just to cover the case when * the pte is a pte marker. It existed because in many cases the pte marker
mm/memory.c renamed from mm/memory.c~mm-use-pte-markers-for-swap-errors +4 -2
@@ -3668,6 +3668,10 @@ static vm_fault_t handle_pte_marker(struif (WARN_ON_ONCE (!marker))return VM_FAULT_SIGBUS ; +/* Higher priority than uffd-wp when data corrupted */ +if (marker &PTE_MARKER_SWAPIN_ERROR ) +return VM_FAULT_SIGBUS ; +if (pte_marker_entry_uffd_wp (entry))return pte_marker_handle_uffd_wp (vmf);
@@ -3727,8 +3731,6 @@ vm_fault_t do_swap_page(struct vm_faultput_page (vmf->page); }else if (is_hwpoison_entry (entry)) { ret =VM_FAULT_HWPOISON ; - }else if (is_swapin_error_entry (entry)) { - ret =VM_FAULT_SIGBUS ; }else if (is_pte_marker_entry (entry)) { ret =handle_pte_marker (vmf); }else {
mm/shmem.c renamed from mm/shmem.c~mm-use-pte-markers-for-swap-errors +1 -1
@@ -1682,7 +1682,7 @@ static void shmem_set_folio_swapin_errorswp_entry_t swapin_error;void *old; - swapin_error =make_swapin_error_entry (&folio->page); + swapin_error =make_swapin_error_entry (); old =xa_cmpxchg_irq (&mapping->i_pages, index,swp_to_radix_entry (swap),swp_to_radix_entry (swapin_error),0 );
mm/swapfile.c renamed from mm/swapfile.c~mm-use-pte-markers-for-swap-errors +1 -1
@@ -1781,7 +1781,7 @@ static int unuse_pte(struct vm_area_strupte_t pteval;dec_mm_counter (vma->vm_mm,MM_SWAPENTS ); - pteval =swp_entry_to_pte (make_swapin_error_entry (page)); + pteval =swp_entry_to_pte (make_swapin_error_entry ());set_pte_at (vma->vm_mm, addr, pte, pteval);swap_free (entry); ret =0 ;
_
Patches currently in -mm which might be from [email protected] are
mm-migrate-fix-read-only-page-got-writable-when-recover-pte.patch mm-hugetlb-let-vma_offset_start-to-return-start.patch mm-hugetlb-dont-wait-for-migration-entry-during-follow-page.patch mm-hugetlb-document-huge_pte_offset-usage.patch mm-hugetlb-move-swap-entry-handling-into-vma-lock-when-faulted.patch mm-hugetlb-make-userfaultfd_huge_must_wait-safe-to-pmd-unshare.patch mm-hugetlb-make-hugetlb_follow_page_mask-safe-to-pmd-unshare.patch mm-hugetlb-make-follow_hugetlb_page-safe-to-pmd-unshare.patch mm-hugetlb-make-walk_hugetlb_range-safe-to-pmd-unshare.patch mm-hugetlb-make-page_vma_mapped_walk-safe-to-pmd-unshare.patch mm-hugetlb-introduce-hugetlb_walk.patch mm-hugetlb-introduce-hugetlb_walk-fix.patch mm-hugetlb-introduce-hugetlb_walk-fix-2.patch