Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/memory-failure: fall back to vma_address() when ->notify_failure() fails

In the case where a filesystem is polled to take over the memory failure
and receives -EOPNOTSUPP it indicates that page->index and page->mapping
are valid for reverse mapping the failure address. Introduce
FSDAX_INVALID_PGOFF to distinguish when add_to_kill() is being called from
mf_dax_kill_procs() by a filesytem vs the typical memory_failure() path.

Otherwise, vma_pgoff_address() is called with an invalid fsdax_pgoff which
then trips this failing signature:

kernel BUG at mm/memory-failure.c:319!
invalid opcode: 0000 [#1] PREEMPT SMP PTI
CPU: 13 PID: 1262 Comm: dax-pmd Tainted: G OE N 6.0.0-rc2+ #62
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
RIP: 0010:add_to_kill.cold+0x19d/0x209
[..]
Call Trace:
<TASK>
collect_procs.part.0+0x2c4/0x460
memory_failure+0x71b/0xba0
? _printk+0x58/0x73
do_madvise.part.0.cold+0xaf/0xc5

Link: https://lkml.kernel.org/r/166153429427.2758201.14605968329933175594.stgit@dwillia2-xfh.jf.intel.com
Fixes: c36e20249571 ("mm: introduce mf_dax_kill_procs() for fsdax case")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Dan Williams and committed by
Andrew Morton
ac87ca0e 65d3440e

+12 -10
+12 -10
mm/memory-failure.c
··· 345 345 * not much we can do. We just print a message and ignore otherwise. 346 346 */ 347 347 348 + #define FSDAX_INVALID_PGOFF ULONG_MAX 349 + 348 350 /* 349 351 * Schedule a process for later kill. 350 352 * Uses GFP_ATOMIC allocations to avoid potential recursions in the VM. 351 353 * 352 - * Notice: @fsdax_pgoff is used only when @p is a fsdax page. 353 - * In other cases, such as anonymous and file-backend page, the address to be 354 - * killed can be caculated by @p itself. 354 + * Note: @fsdax_pgoff is used only when @p is a fsdax page and a 355 + * filesystem with a memory failure handler has claimed the 356 + * memory_failure event. In all other cases, page->index and 357 + * page->mapping are sufficient for mapping the page back to its 358 + * corresponding user virtual address. 355 359 */ 356 360 static void add_to_kill(struct task_struct *tsk, struct page *p, 357 361 pgoff_t fsdax_pgoff, struct vm_area_struct *vma, ··· 371 367 372 368 tk->addr = page_address_in_vma(p, vma); 373 369 if (is_zone_device_page(p)) { 374 - /* 375 - * Since page->mapping is not used for fsdax, we need 376 - * calculate the address based on the vma. 377 - */ 378 - if (p->pgmap->type == MEMORY_DEVICE_FS_DAX) 370 + if (fsdax_pgoff != FSDAX_INVALID_PGOFF) 379 371 tk->addr = vma_pgoff_address(fsdax_pgoff, 1, vma); 380 372 tk->size_shift = dev_pagemap_mapping_shift(vma, tk->addr); 381 373 } else ··· 523 523 if (!page_mapped_in_vma(page, vma)) 524 524 continue; 525 525 if (vma->vm_mm == t->mm) 526 - add_to_kill(t, page, 0, vma, to_kill); 526 + add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, 527 + to_kill); 527 528 } 528 529 } 529 530 read_unlock(&tasklist_lock); ··· 560 559 * to be informed of all such data corruptions. 561 560 */ 562 561 if (vma->vm_mm == t->mm) 563 - add_to_kill(t, page, 0, vma, to_kill); 562 + add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, 563 + to_kill); 564 564 } 565 565 } 566 566 read_unlock(&tasklist_lock);