From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, songmuchun@bytedance.com,
mike.kravetz@oracle.com, willy@infradead.org,
jhubbard@nvidia.com, gerald.schaefer@linux.ibm.com,
Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: [PATCH v2 2/8] mm/hugetlb: convert hugetlbfs_pagecache_present() to folios
Date: Wed, 25 Jan 2023 09:05:31 -0800 [thread overview]
Message-ID: <20230125170537.96973-3-sidhartha.kumar@oracle.com> (raw)
In-Reply-To: <20230125170537.96973-1-sidhartha.kumar@oracle.com>
Refactor hugetlbfs_pagecache_present() to avoid getting and dropping
a refcount on a page. Use RCU and page_cache_next_miss() instead.
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
mm/hugetlb.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 849206e94742..e506a46b7871 100644
--- a/mm/hugetlb.c
+++ b/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,
--
2.39.1
next prev parent reply other threads:[~2023-01-25 17:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 17:05 [PATCH v2 0/8] convert hugetlb fault functions " Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 1/8] mm/hugetlb: convert hugetlb_install_page " Sidhartha Kumar
2023-01-25 17:05 ` Sidhartha Kumar [this message]
2023-01-25 17:05 ` [PATCH v2 3/8] mm/hugetlb: convert putback_active_hugepage to take in a folio Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 4/8] mm/hugetlb: convert hugetlb fault paths to use alloc_hugetlb_folio() Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 5/8] mm/hugetlb: convert restore_reserve_on_error to take in a folio Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 6/8] mm/hugetlb: convert hugetlb_add_to_page_cache " Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 7/8] mm/hugetlb: convert hugetlb_wp() " Sidhartha Kumar
2023-01-25 17:05 ` [PATCH v2 8/8] Documentation/mm: update hugetlbfs documentation to mention alloc_hugetlb_folio Sidhartha Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230125170537.96973-3-sidhartha.kumar@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=gerald.schaefer@linux.ibm.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=songmuchun@bytedance.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox