Skip to content

Commit 376907f

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm/memory-failure: pass the folio and the page to collect_procs()
Patch series "Three memory-failure fixes". I've been looking at the memory-failure code and I believe I have found three bugs that need fixing -- one going all the way back to 2010! I'll have more patches later to use folios more extensively but didn't want these bugfixes to get caught up in that. This patch (of 3): Both collect_procs_anon() and collect_procs_file() iterate over the VMA interval trees looking for a single pgoff, so it is wrong to look for the pgoff of the head page as is currently done. However, it is also wrong to look at page->mapping of the precise page as this is invalid for tail pages. Clear up the confusion by passing both the folio and the precise page to collect_procs(). Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 415c64c ("mm/memory-failure: split thp earlier in memory error handling") Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Dan Williams <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0aac13a commit 376907f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

mm/memory-failure.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,9 @@ struct task_struct *task_early_kill(struct task_struct *tsk, int force_early)
595595
/*
596596
* Collect processes when the error hit an anonymous page.
597597
*/
598-
static void collect_procs_anon(struct page *page, struct list_head *to_kill,
599-
int force_early)
598+
static void collect_procs_anon(struct folio *folio, struct page *page,
599+
struct list_head *to_kill, int force_early)
600600
{
601-
struct folio *folio = page_folio(page);
602601
struct vm_area_struct *vma;
603602
struct task_struct *tsk;
604603
struct anon_vma *av;
@@ -633,12 +632,12 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
633632
/*
634633
* Collect processes when the error hit a file mapped page.
635634
*/
636-
static void collect_procs_file(struct page *page, struct list_head *to_kill,
637-
int force_early)
635+
static void collect_procs_file(struct folio *folio, struct page *page,
636+
struct list_head *to_kill, int force_early)
638637
{
639638
struct vm_area_struct *vma;
640639
struct task_struct *tsk;
641-
struct address_space *mapping = page->mapping;
640+
struct address_space *mapping = folio->mapping;
642641
pgoff_t pgoff;
643642

644643
i_mmap_lock_read(mapping);
@@ -704,17 +703,17 @@ static void collect_procs_fsdax(struct page *page,
704703
/*
705704
* Collect the processes who have the corrupted page mapped to kill.
706705
*/
707-
static void collect_procs(struct page *page, struct list_head *tokill,
708-
int force_early)
706+
static void collect_procs(struct folio *folio, struct page *page,
707+
struct list_head *tokill, int force_early)
709708
{
710-
if (!page->mapping)
709+
if (!folio->mapping)
711710
return;
712711
if (unlikely(PageKsm(page)))
713712
collect_procs_ksm(page, tokill, force_early);
714713
else if (PageAnon(page))
715-
collect_procs_anon(page, tokill, force_early);
714+
collect_procs_anon(folio, page, tokill, force_early);
716715
else
717-
collect_procs_file(page, tokill, force_early);
716+
collect_procs_file(folio, page, tokill, force_early);
718717
}
719718

720719
struct hwpoison_walk {
@@ -1602,7 +1601,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
16021601
* mapped in dirty form. This has to be done before try_to_unmap,
16031602
* because ttu takes the rmap data structures down.
16041603
*/
1605-
collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
1604+
collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED);
16061605

16071606
if (PageHuge(hpage) && !PageAnon(hpage)) {
16081607
/*
@@ -1772,7 +1771,7 @@ static int mf_generic_kill_procs(unsigned long long pfn, int flags,
17721771
* SIGBUS (i.e. MF_MUST_KILL)
17731772
*/
17741773
flags |= MF_ACTION_REQUIRED | MF_MUST_KILL;
1775-
collect_procs(&folio->page, &to_kill, true);
1774+
collect_procs(folio, &folio->page, &to_kill, true);
17761775

17771776
unmap_and_kill(&to_kill, pfn, folio->mapping, folio->index, flags);
17781777
unlock:

0 commit comments

Comments
 (0)