Skip to content

Commit f5df863

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm: use find_get_incore_page in memcontrol
The current code does not protect against swapoff of the underlying swap device, so this is a bug fix as well as a worthwhile reduction in code complexity. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Huang Ying <ying.huang@intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Matthew Auld <matthew.auld@intel.com> Cc: William Kucharski <william.kucharski@oracle.com> Link: https://lkml.kernel.org/r/20200910183318.20139-3-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 61ef186 commit f5df863

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

mm/memcontrol.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5539,35 +5539,15 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
55395539
static struct page *mc_handle_file_pte(struct vm_area_struct *vma,
55405540
unsigned long addr, pte_t ptent, swp_entry_t *entry)
55415541
{
5542-
struct page *page = NULL;
5543-
struct address_space *mapping;
5544-
pgoff_t pgoff;
5545-
55465542
if (!vma->vm_file) /* anonymous vma */
55475543
return NULL;
55485544
if (!(mc.flags & MOVE_FILE))
55495545
return NULL;
55505546

5551-
mapping = vma->vm_file->f_mapping;
5552-
pgoff = linear_page_index(vma, addr);
5553-
55545547
/* page is moved even if it's not RSS of this task(page-faulted). */
5555-
#ifdef CONFIG_SWAP
55565548
/* shmem/tmpfs may report page out on swap: account for that too. */
5557-
if (shmem_mapping(mapping)) {
5558-
page = find_get_entry(mapping, pgoff);
5559-
if (xa_is_value(page)) {
5560-
swp_entry_t swp = radix_to_swp_entry(page);
5561-
*entry = swp;
5562-
page = find_get_page(swap_address_space(swp),
5563-
swp_offset(swp));
5564-
}
5565-
} else
5566-
page = find_get_page(mapping, pgoff);
5567-
#else
5568-
page = find_get_page(mapping, pgoff);
5569-
#endif
5570-
return page;
5549+
return find_get_incore_page(vma->vm_file->f_mapping,
5550+
linear_page_index(vma, addr));
55715551
}
55725552

55735553
/**

0 commit comments

Comments
 (0)