Skip to content

Commit

Permalink
mm/hugetlb: convert hugetlbfs_pagecache_present() to folios
Browse files Browse the repository at this point in the history
Refactor hugetlbfs_pagecache_present() to avoid getting and dropping a
refcount on a page.  Use RCU and page_cache_next_miss() instead.

Link: https://lkml.kernel.org/r/[email protected]
Suggested-by: Matthew Wilcox <[email protected]>
Signed-off-by: Sidhartha Kumar <[email protected]>
Cc: Gerald Schaefer <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: kernel test robot <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Muchun Song <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sidkumar99 authored and akpm00 committed Feb 13, 2023
1 parent ea4c353 commit 91a2fb9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5651,17 +5651,15 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
static bool hugetlbfs_pagecache_present(struct hstate *h,
struct vm_area_struct *vma, unsigned long address)
{
struct address_space *mapping;
pgoff_t idx;
struct page *page;
struct address_space *mapping = vma->vm_file->f_mapping;
pgoff_t idx = vma_hugecache_offset(h, vma, address);
bool present;

mapping = vma->vm_file->f_mapping;
idx = vma_hugecache_offset(h, vma, address);
rcu_read_lock();
present = page_cache_next_miss(mapping, idx, 1) != idx;
rcu_read_unlock();

page = find_get_page(mapping, idx);
if (page)
put_page(page);
return page != NULL;
return present;
}

int hugetlb_add_to_page_cache(struct page *page, struct address_space *mapping,
Expand Down

0 comments on commit 91a2fb9

Please sign in to comment.