mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-08 15:04:45 +00:00
mm/hugetlb: convert hugetlbfs_pagecache_present() to folios
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/20230125170537.96973-3-sidhartha.kumar@oracle.com Suggested-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: kernel test robot <lkp@intel.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Muchun Song <songmuchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
ea4c353df3
commit
91a2fb956a
16
mm/hugetlb.c
16
mm/hugetlb.c
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user