From: Andrew Morton <akpm@linux-foundation.org> To: stable@vger.kernel.org,osalvador@suse.de,naoya.horiguchi@nec.com,mgorman@suse.de,linmiaohe@huawei.com,hannes@cmpxchg.org,riel@surriel.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org Subject: [patch 11/16] mm,hwpoison: unmap poisoned page before invalidation Date: Fri, 01 Apr 2022 11:21:21 -0700 [thread overview] Message-ID: <20220401182122.0AFB4C340EE@smtp.kernel.org> (raw) In-Reply-To: <l> From: Rik van Riel <riel@surriel.com> Subject: mm,hwpoison: unmap poisoned page before invalidation In some cases it appears the invalidation of a hwpoisoned page fails because the page is still mapped in another process. This can cause a program to be continuously restarted and die when it page faults on the page that was not invalidated. Avoid that problem by unmapping the hwpoisoned page when we find it. Another issue is that sometimes we end up oopsing in finish_fault, if the code tries to do something with the now-NULL vmf->page. I did not hit this error when submitting the previous patch because there are several opportunities for alloc_set_pte to bail out before accessing vmf->page, and that apparently happened on those systems, and most of the time on other systems, too. However, across several million systems that error does occur a handful of times a day. It can be avoided by returning VM_FAULT_NOPAGE which will cause do_read_fault to return before calling finish_fault. Link: https://lkml.kernel.org/r/20220325161428.5068d97e@imladris.surriel.com Fixes: e53ac7374e64 ("mm: invalidate hwpoison page cache page in fault path") Signed-off-by: Rik van Riel <riel@surriel.com> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> Tested-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: Mel Gorman <mgorman@suse.de> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/memory.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/mm/memory.c~mmhwpoison-unmap-poisoned-page-before-invalidation +++ a/mm/memory.c @@ -3918,14 +3918,18 @@ static vm_fault_t __do_fault(struct vm_f return ret; if (unlikely(PageHWPoison(vmf->page))) { + struct page *page = vmf->page; vm_fault_t poisonret = VM_FAULT_HWPOISON; if (ret & VM_FAULT_LOCKED) { + if (page_mapped(page)) + unmap_mapping_pages(page_mapping(page), + page->index, 1, false); /* Retry if a clean page was removed from the cache. */ - if (invalidate_inode_page(vmf->page)) - poisonret = 0; - unlock_page(vmf->page); + if (invalidate_inode_page(page)) + poisonret = VM_FAULT_NOPAGE; + unlock_page(page); } - put_page(vmf->page); + put_page(page); vmf->page = NULL; return poisonret; } _
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org> To: stable@vger.kernel.org, osalvador@suse.de, naoya.horiguchi@nec.com, mgorman@suse.de, linmiaohe@huawei.com, hannes@cmpxchg.org, riel@surriel.com, akpm@linux-foundation.org, patches@lists.linux.dev, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org Subject: [patch 11/16] mm,hwpoison: unmap poisoned page before invalidation Date: Fri, 01 Apr 2022 11:21:21 -0700 [thread overview] Message-ID: <20220401182122.0AFB4C340EE@smtp.kernel.org> (raw) In-Reply-To: <l> From: Rik van Riel <riel@surriel.com> Subject: mm,hwpoison: unmap poisoned page before invalidation In some cases it appears the invalidation of a hwpoisoned page fails because the page is still mapped in another process. This can cause a program to be continuously restarted and die when it page faults on the page that was not invalidated. Avoid that problem by unmapping the hwpoisoned page when we find it. Another issue is that sometimes we end up oopsing in finish_fault, if the code tries to do something with the now-NULL vmf->page. I did not hit this error when submitting the previous patch because there are several opportunities for alloc_set_pte to bail out before accessing vmf->page, and that apparently happened on those systems, and most of the time on other systems, too. However, across several million systems that error does occur a handful of times a day. It can be avoided by returning VM_FAULT_NOPAGE which will cause do_read_fault to return before calling finish_fault. Link: https://lkml.kernel.org/r/20220325161428.5068d97e@imladris.surriel.com Fixes: e53ac7374e64 ("mm: invalidate hwpoison page cache page in fault path") Signed-off-by: Rik van Riel <riel@surriel.com> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> Tested-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: Mel Gorman <mgorman@suse.de> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/memory.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/mm/memory.c~mmhwpoison-unmap-poisoned-page-before-invalidation +++ a/mm/memory.c @@ -3918,14 +3918,18 @@ static vm_fault_t __do_fault(struct vm_f return ret; if (unlikely(PageHWPoison(vmf->page))) { + struct page *page = vmf->page; vm_fault_t poisonret = VM_FAULT_HWPOISON; if (ret & VM_FAULT_LOCKED) { + if (page_mapped(page)) + unmap_mapping_pages(page_mapping(page), + page->index, 1, false); /* Retry if a clean page was removed from the cache. */ - if (invalidate_inode_page(vmf->page)) - poisonret = 0; - unlock_page(vmf->page); + if (invalidate_inode_page(page)) + poisonret = VM_FAULT_NOPAGE; + unlock_page(page); } - put_page(vmf->page); + put_page(page); vmf->page = NULL; return poisonret; } _
next prev parent reply other threads:[~2022-04-01 18:21 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <l> 2022-04-01 18:20 ` [patch 01/16] Revert "mm: madvise: skip unmapped vma holes passed to process_madvise" Andrew Morton 2022-04-01 18:20 ` Andrew Morton 2022-04-01 18:20 ` [patch 02/16] ocfs2: fix crash when mount with quota enabled Andrew Morton 2022-04-01 18:20 ` Andrew Morton 2022-04-01 18:20 ` [patch 03/16] nilfs2: fix lockdep warnings in page operations for btree nodes Andrew Morton 2022-04-01 18:20 ` Andrew Morton 2022-04-01 18:21 ` [patch 04/16] nilfs2: fix lockdep warnings during disk space reclamation Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 05/16] nilfs2: get rid of nilfs_mapping_init() Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 06/16] mm/munlock: add lru_add_drain() to fix memcg_stat_test Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 07/16] mm/munlock: update Documentation/vm/unevictable-lru.rst Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 08/16] mm/munlock: protect the per-CPU pagevec by a local_lock_t Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 09/16] mm: kfence: fix objcgs vector allocation Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 10/16] mailmap: update Kirill's email Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` Andrew Morton [this message] 2022-04-01 18:21 ` [patch 11/16] mm,hwpoison: unmap poisoned page before invalidation Andrew Morton 2022-04-01 18:21 ` [patch 12/16] mm, kasan: fix __GFP_BITS_SHIFT definition breaking LOCKDEP Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 13/16] tools/vm/page_owner_sort.c: remove -c option Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 14/16] doc/vm/page_owner.rst: remove content related to " Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 15/16] mm/kmemleak: reset tag when compare object pointer Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:21 ` [patch 16/16] mm/damon: prevent activated scheme from sleeping by deactivated schemes Andrew Morton 2022-04-01 18:21 ` Andrew Morton 2022-04-01 18:27 incoming Andrew Morton 2022-04-01 18:28 ` [patch 11/16] mm,hwpoison: unmap poisoned page before invalidation Andrew Morton 2022-04-01 18:28 ` Andrew Morton
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220401182122.0AFB4C340EE@smtp.kernel.org \ --to=akpm@linux-foundation.org \ --cc=hannes@cmpxchg.org \ --cc=linmiaohe@huawei.com \ --cc=linux-mm@kvack.org \ --cc=mgorman@suse.de \ --cc=mm-commits@vger.kernel.org \ --cc=naoya.horiguchi@nec.com \ --cc=osalvador@suse.de \ --cc=patches@lists.linux.dev \ --cc=riel@surriel.com \ --cc=stable@vger.kernel.org \ --cc=torvalds@linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.