From: Peng Zhang <zhangpeng362@huawei.com>
To: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<akpm@linux-foundation.org>, <willy@infradead.org>,
<mike.kravetz@oracle.com>, <muchun.song@linux.dev>,
<sidhartha.kumar@oracle.com>
Cc: <vishal.moola@gmail.com>, <wangkefeng.wang@huawei.com>,
<sunnanyong@huawei.com>, ZhangPeng <zhangpeng362@huawei.com>
Subject: [PATCH v2 3/3] mm/hugetlb: Use a folio in hugetlb_fault()
Date: Tue, 6 Jun 2023 14:20:13 +0800 [thread overview]
Message-ID: <20230606062013.2947002-4-zhangpeng362@huawei.com> (raw)
In-Reply-To: <20230606062013.2947002-1-zhangpeng362@huawei.com>
From: ZhangPeng <zhangpeng362@huawei.com>
We can replace seven implicit calls to compound_head() with one by using
folio.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/hugetlb.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e58f8001fd92..e34329e25abe 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -6062,7 +6062,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
vm_fault_t ret;
u32 hash;
pgoff_t idx;
- struct page *page = NULL;
+ struct folio *folio = NULL;
struct folio *pagecache_folio = NULL;
struct hstate *h = hstate_vma(vma);
struct address_space *mapping;
@@ -6181,14 +6181,14 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
* pagecache_folio, so here we need take the former one
* when page != pagecache_folio or !pagecache_folio.
*/
- page = pte_page(entry);
- if (page_folio(page) != pagecache_folio)
- if (!trylock_page(page)) {
+ folio = page_folio(pte_page(entry));
+ if (folio != pagecache_folio)
+ if (!folio_trylock(folio)) {
need_wait_lock = 1;
goto out_ptl;
}
- get_page(page);
+ folio_get(folio);
if (flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) {
if (!huge_pte_write(entry)) {
@@ -6204,9 +6204,9 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
flags & FAULT_FLAG_WRITE))
update_mmu_cache(vma, haddr, ptep);
out_put_page:
- if (page_folio(page) != pagecache_folio)
- unlock_page(page);
- put_page(page);
+ if (folio != pagecache_folio)
+ folio_unlock(folio);
+ folio_put(folio);
out_ptl:
spin_unlock(ptl);
@@ -6225,7 +6225,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
* here without taking refcount.
*/
if (need_wait_lock)
- wait_on_page_locked(page);
+ folio_wait_locked(folio);
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2023-06-06 6:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 6:20 [PATCH v2 0/3] Convert several functions in hugetlb.c to use a folio Peng Zhang
2023-06-06 6:20 ` [PATCH v2 1/3] mm/hugetlb: Use a folio in copy_hugetlb_page_range() Peng Zhang
2023-06-06 17:46 ` Matthew Wilcox
2023-06-06 6:20 ` [PATCH v2 2/3] mm/hugetlb: Use a folio in hugetlb_wp() Peng Zhang
2023-06-06 17:50 ` Matthew Wilcox
2023-06-06 6:20 ` Peng Zhang [this message]
2023-06-06 17:28 ` [PATCH v2 3/3] mm/hugetlb: Use a folio in hugetlb_fault() Sidhartha Kumar
2023-06-06 17:56 ` Matthew Wilcox
2023-06-07 3:55 ` Muchun Song
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=20230606062013.2947002-4-zhangpeng362@huawei.com \
--to=zhangpeng362@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=sidhartha.kumar@oracle.com \
--cc=sunnanyong@huawei.com \
--cc=vishal.moola@gmail.com \
--cc=wangkefeng.wang@huawei.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
all inboxes | Powered by JetHome®