FAILED: patch "[PATCH] mm,swapops: update check in is_pfn_swap_entry for hwpoison" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 07a57a338adb6ec9e766d6a6790f76527f45ceb5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024042309-rural-overlying-190b@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
07a57a338adb ("mm,swapops: update check in is_pfn_swap_entry for hwpoison entries") d027122d8363 ("mm/hwpoison: move definitions of num_poisoned_pages_* to memory-failure.c") e591ef7d96d6 ("mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 07a57a338adb6ec9e766d6a6790f76527f45ceb5 Mon Sep 17 00:00:00 2001
From: Oscar Salvador <[email protected]>
Date: Sun, 7 Apr 2024 15:05:37 +0200
Subject: [PATCH] mm,swapops: update check in is_pfn_swap_entry for hwpoison
entries
Tony reported that the Machine check recovery was broken in v6.9-rc1, as he was hitting a VM_BUG_ON when injecting uncorrectable memory errors to DRAM.
After some more digging and debugging on his side, he realized that this went back to v6.1, with the introduction of 'commit 0d206b5d2e0d ("mm/swap: add swp_offset_pfn() to fetch PFN from swap entry")'. That commit, among other things, introduced swp_offset_pfn(), replacing hwpoison_entry_to_pfn() in its favour.
The patch also introduced a VM_BUG_ON() check for is_pfn_swap_entry(), but is_pfn_swap_entry() never got updated to cover hwpoison entries, which means that we would hit the VM_BUG_ON whenever we would call swp_offset_pfn() for such entries on environments with CONFIG_DEBUG_VM set. Fix this by updating the check to cover hwpoison entries as well, and update the comment while we are it.
include/linux/swapops.h +33 -32
@@ -390,6 +390,35 @@ static inline bool is_migration_entry_dirty(swp_entry_t entry) }#endif /* CONFIG_MIGRATION */ +#ifdef CONFIG_MEMORY_FAILURE + +/* +* Support for hardware poisoned pages +*/ +static inline swp_entry_t make_hwpoison_entry (struct page *page) +{ +BUG_ON (!PageLocked (page)); +return swp_entry (SWP_HWPOISON ,page_to_pfn (page)); +} + +static inline int is_hwpoison_entry (swp_entry_t entry) +{ +return swp_type (entry) ==SWP_HWPOISON ; +} + +#else + +static inline swp_entry_t make_hwpoison_entry (struct page *page) +{ +return swp_entry (0 ,0 ); +} + +static inline int is_hwpoison_entry (swp_entry_t swp) +{ +return 0 ; +} +#endif +typedef unsigned long pte_marker ;#define PTE_MARKER_UFFD_WP BIT(0)
@@ -483,8 +512,9 @@ static inline struct folio *pfn_swap_entry_folio(swp_entry_t entry)/* * A pfn swap entry is a special type of swap entry that always has a pfn stored -* in the swap offset. They are used to represent unaddressable device memory -* and to restrict access to a page undergoing migration. +* in the swap offset. They can either be used to represent unaddressable device +* memory, to restrict access to a page undergoing migration or to represent a +* pfn which has been hwpoisoned and unmapped. */ static inline bool is_pfn_swap_entry (swp_entry_t entry) {
@@ -492,7 +522,7 @@ static inline bool is_pfn_swap_entry(swp_entry_t entry)BUILD_BUG_ON (SWP_TYPE_SHIFT <SWP_PFN_BITS );return is_migration_entry (entry) ||is_device_private_entry (entry) || -is_device_exclusive_entry (entry); +is_device_exclusive_entry (entry) ||is_hwpoison_entry (entry); }struct page_vma_mapped_walk ;
@@ -561,35 +591,6 @@ static inline int is_pmd_migration_entry(pmd_t pmd) }#endif /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ -#ifdef CONFIG_MEMORY_FAILURE - -/* -* Support for hardware poisoned pages -*/ -static inline swp_entry_t make_hwpoison_entry (struct page *page) -{ -BUG_ON (!PageLocked (page)); -return swp_entry (SWP_HWPOISON ,page_to_pfn (page)); -} - -static inline int is_hwpoison_entry (swp_entry_t entry) -{ -return swp_type (entry) ==SWP_HWPOISON ; -} - -#else - -static inline swp_entry_t make_hwpoison_entry (struct page *page) -{ -return swp_entry (0 ,0 ); -} - -static inline int is_hwpoison_entry (swp_entry_t swp) -{ -return 0 ; -} -#endif -static inline int non_swap_entry (swp_entry_t entry) {return swp_type (entry) >=MAX_SWAPFILES ;
PATCH 1/1 mm,swapops: update check in is_pfn_swap_entry for hwpoison entries
From: Oscar Salvador <[email protected]>
Tony reported that the Machine check recovery was broken in v6.9-rc1, as he was hitting a VM_BUG_ON when injecting uncorrectable memory errors to DRAM.
After some more digging and debugging on his side, he realized that this went back to v6.1, with the introduction of 'commit 0d206b5d2e0d ("mm/swap: add swp_offset_pfn() to fetch PFN from swap entry")'. That commit, among other things, introduced swp_offset_pfn(), replacing hwpoison_entry_to_pfn() in its favour.
The patch also introduced a VM_BUG_ON() check for is_pfn_swap_entry(), but is_pfn_swap_entry() never got updated to cover hwpoison entries, which means that we would hit the VM_BUG_ON whenever we would call swp_offset_pfn() for such entries on environments with CONFIG_DEBUG_VM set. Fix this by updating the check to cover hwpoison entries as well, and update the comment while we are it.
--- include/linux/swapops.h | 105 ++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 52 deletions(-)
include/linux/swapops.h +53 -52
@@ -409,6 +409,55 @@ static inline bool is_migration_entry_dirty(swp_entry_t entry) }#endif /* CONFIG_MIGRATION */ +#ifdef CONFIG_MEMORY_FAILURE + +extern atomic_long_t num_poisoned_pages__read_mostly ; + +/* +* Support for hardware poisoned pages +*/ +static inline swp_entry_t make_hwpoison_entry (struct page *page) +{ +BUG_ON (!PageLocked (page)); +return swp_entry (SWP_HWPOISON ,page_to_pfn (page)); +} + +static inline int is_hwpoison_entry (swp_entry_t entry) +{ +return swp_type (entry) ==SWP_HWPOISON ; +} + +static inline void num_poisoned_pages_inc (void ) +{ +atomic_long_inc (&num_poisoned_pages); +} + +static inline void num_poisoned_pages_sub (long i) +{ +atomic_long_sub (i, &num_poisoned_pages); +} + +#else /* CONFIG_MEMORY_FAILURE */ + +static inline swp_entry_t make_hwpoison_entry (struct page *page) +{ +return swp_entry (0 ,0 ); +} + +static inline int is_hwpoison_entry (swp_entry_t swp) +{ +return 0 ; +} + +static inline void num_poisoned_pages_inc (void ) +{ +} + +static inline void num_poisoned_pages_sub (long i) +{ +} +#endif /* CONFIG_MEMORY_FAILURE */ +typedef unsigned long pte_marker ;#define PTE_MARKER_UFFD_WP BIT(0)
@@ -503,8 +552,9 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)/* * A pfn swap entry is a special type of swap entry that always has a pfn stored -* in the swap offset. They are used to represent unaddressable device memory -* and to restrict access to a page undergoing migration. +* in the swap offset. They can either be used to represent unaddressable device +* memory, to restrict access to a page undergoing migration or to represent a +* pfn which has been hwpoisoned and unmapped. */ static inline bool is_pfn_swap_entry (swp_entry_t entry) {
@@ -512,7 +562,7 @@ static inline bool is_pfn_swap_entry(swp_entry_t entry)BUILD_BUG_ON (SWP_TYPE_SHIFT <SWP_PFN_BITS );return is_migration_entry (entry) ||is_device_private_entry (entry) || -is_device_exclusive_entry (entry); +is_device_exclusive_entry (entry) ||is_hwpoison_entry (entry); }struct page_vma_mapped_walk ;
@@ -581,55 +631,6 @@ static inline int is_pmd_migration_entry(pmd_t pmd) }#endif /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ -#ifdef CONFIG_MEMORY_FAILURE - -extern atomic_long_t num_poisoned_pages__read_mostly ; - -/* -* Support for hardware poisoned pages -*/ -static inline swp_entry_t make_hwpoison_entry (struct page *page) -{ -BUG_ON (!PageLocked (page)); -return swp_entry (SWP_HWPOISON ,page_to_pfn (page)); -} - -static inline int is_hwpoison_entry (swp_entry_t entry) -{ -return swp_type (entry) ==SWP_HWPOISON ; -} - -static inline void num_poisoned_pages_inc (void ) -{ -atomic_long_inc (&num_poisoned_pages); -} - -static inline void num_poisoned_pages_sub (long i) -{ -atomic_long_sub (i, &num_poisoned_pages); -} - -#else /* CONFIG_MEMORY_FAILURE */ - -static inline swp_entry_t make_hwpoison_entry (struct page *page) -{ -return swp_entry (0 ,0 ); -} - -static inline int is_hwpoison_entry (swp_entry_t swp) -{ -return 0 ; -} - -static inline void num_poisoned_pages_inc (void ) -{ -} - -static inline void num_poisoned_pages_sub (long i) -{ -} -#endif /* CONFIG_MEMORY_FAILURE */ -static inline int non_swap_entry (swp_entry_t entry) {return swp_type (entry) >=MAX_SWAPFILES ;
Signature · 1 line
2.33.0
Greg KH
maintainerRe: [PATCH 6.1.y] mm,swapops: update check in is_pfn_swap_entry for hwpoison entries
Quoted 32 lines · Miaohe Lin
From: Oscar Salvador <[email protected]>
Tony reported that the Machine check recovery was broken in v6.9-rc1, as he was hitting a
VM_BUG_ONwhen injecting uncorrectable memory errors to DRAM.After some more digging and debugging on his side, he realized that this went back to v6.1, with the introduction of 'commit
0d206b5d2e0d("mm/swap: addswp_offset_pfn()to fetch PFN from swap entry")'. That commit, among other things, introducedswp_offset_pfn(), replacinghwpoison_entry_to_pfn()in its favour.The patch also introduced a
VM_BUG_ON()check foris_pfn_swap_entry(), butis_pfn_swap_entry()never got updated to cover hwpoison entries, which means that we would hit theVM_BUG_ONwhenever we would callswp_offset_pfn()for such entries on environments withCONFIG_DEBUG_VMset. Fix this by updating the check to cover hwpoison entries as well, and update the comment while we are it.Fixes 0d206b5d2e0d ("mm/swap: add swp_offset_pfn() to fetch PFN from swap entry")Signed-off-by Oscar Salvador <[email protected]>Reported-by Tony Luck <[email protected]>Tested-by Tony Luck <[email protected]>Reviewed-by Peter Xu <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Miaohe Lin <[email protected]>Cc <[email protected]> [6.1.x]Signed-off-by Andrew Morton <[email protected]>(cherry picked from commit 07a57a338adb6ec9e766d6a6790f76527f45ceb5)Signed-off-by Miaohe Lin <[email protected]>
Quoted 3 lines
--- include/linux/swapops.h | 105 ++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 52 deletions(-)
Now queued up, thanks.
greg k-h