The patch titled Subject: mm/memory-failure: move hwpoison_filter() higher up has been added to the -mm mm-unstable branch. Its filename is mm-memory-failure-move-hwpoison_filter-higher-up.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memory-failure-move-hwpoison_filter-higher-up.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Jane Chu <jane.chu@xxxxxxxxxx> Subject: mm/memory-failure: move hwpoison_filter() higher up Date: Fri, 24 May 2024 15:53:05 -0600 Move hwpoison_filter() higher up as there is no need to spend a lot cycles only to find out later that the page is supposed to be skipped from hwpoison handling. Link: https://lkml.kernel.org/r/20240524215306.2705454-5-jane.chu@xxxxxxxxxx Signed-off-by: Jane Chu <jane.chu@xxxxxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Acked-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Naoya Horiguchi <nao.horiguchi@xxxxxxxxx> Cc: Oscar Salvador <oalvador@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory-failure.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/mm/memory-failure.c~mm-memory-failure-move-hwpoison_filter-higher-up +++ a/mm/memory-failure.c @@ -2300,6 +2300,18 @@ try_again: } folio = page_folio(p); + + /* filter pages that are protected from hwpoison test by users */ + folio_lock(folio); + if (hwpoison_filter(p)) { + ClearPageHWPoison(p); + folio_unlock(folio); + folio_put(folio); + res = -EOPNOTSUPP; + goto unlock_mutex; + } + folio_unlock(folio); + if (folio_test_large(folio)) { /* * The flag must be set after the refcount is bumped @@ -2363,14 +2375,6 @@ try_again: */ page_flags = folio->flags; - if (hwpoison_filter(p)) { - ClearPageHWPoison(p); - folio_unlock(folio); - folio_put(folio); - res = -EOPNOTSUPP; - goto unlock_mutex; - } - /* * __munlock_folio() may clear a writeback folio's LRU flag without * the folio lock. We need to wait for writeback completion for this _ Patches currently in -mm which might be from jane.chu@xxxxxxxxxx are mm-memory-failure-try-to-send-sigbus-even-if-unmap-failed.patch mm-madvise-add-mf_action_required-to-madvisemadv_hwpoison.patch mm-memory-failure-improve-memory-failure-action_result-messages.patch mm-memory-failure-move-hwpoison_filter-higher-up.patch mm-memory-failure-send-sigbus-in-the-event-of-thp-split-fail.patch