From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
David Hildenbrand <david@redhat.com>,
Sidhartha Kumar <sidhartha.kumar@oracle.com>,
<linux-mm@kvack.org>, Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH 1/5] mm: remove find_subpage()
Date: Sat, 17 Aug 2024 17:51:18 +0800 [thread overview]
Message-ID: <20240817095122.2460977-2-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20240817095122.2460977-1-wangkefeng.wang@huawei.com>
After commit a08c7193e4f1 ("mm/filemap: remove hugetlb special casing
in filemap.c"), the find_subpage() should remove hugetlb case as the
folio_file_page(), furthermore, we could convert to use folio_file_page()
to remove find_subpage().
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
include/linux/pagemap.h | 13 -------------
lib/iov_iter.c | 24 +++++++++++++-----------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index d9c7edb6422b..68f59cd7637d 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -860,19 +860,6 @@ static inline bool folio_contains(struct folio *folio, pgoff_t index)
return index - folio_index(folio) < folio_nr_pages(folio);
}
-/*
- * Given the page we found in the page cache, return the page corresponding
- * to this index in the file
- */
-static inline struct page *find_subpage(struct page *head, pgoff_t index)
-{
- /* HugeTLBfs wants the head page regardless */
- if (PageHuge(head))
- return head;
-
- return head + (index & (thp_nr_pages(head) - 1));
-}
-
unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start,
pgoff_t end, struct folio_batch *fbatch);
unsigned filemap_get_folios_contig(struct address_space *mapping,
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 4a6a9f419bd7..b0bb1e5ff331 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -891,21 +891,21 @@ static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa
pgoff_t index, unsigned int nr_pages)
{
XA_STATE(xas, xa, index);
- struct page *page;
+ struct folio *folio;
unsigned int ret = 0;
rcu_read_lock();
- for (page = xas_load(&xas); page; page = xas_next(&xas)) {
- if (xas_retry(&xas, page))
+ for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
+ if (xas_retry(&xas, folio))
continue;
/* Has the page moved or been split? */
- if (unlikely(page != xas_reload(&xas))) {
+ if (unlikely(folio != xas_reload(&xas))) {
xas_reset(&xas);
continue;
}
- pages[ret] = find_subpage(page, xas.xa_index);
+ pages[ret] = folio_file_page(folio, xas.xa_index);
get_page(pages[ret]);
if (++ret == nr_pages)
break;
@@ -1408,7 +1408,8 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
iov_iter_extraction_t extraction_flags,
size_t *offset0)
{
- struct page *page, **p;
+ struct page **p;
+ struct folio *folio;
unsigned int nr = 0, offset;
loff_t pos = i->xarray_start + i->iov_offset;
pgoff_t index = pos >> PAGE_SHIFT;
@@ -1420,20 +1421,21 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i,
maxpages = want_pages_array(pages, maxsize, offset, maxpages);
if (!maxpages)
return -ENOMEM;
+
p = *pages;
rcu_read_lock();
- for (page = xas_load(&xas); page; page = xas_next(&xas)) {
- if (xas_retry(&xas, page))
+ for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
+ if (xas_retry(&xas, folio))
continue;
- /* Has the page moved or been split? */
- if (unlikely(page != xas_reload(&xas))) {
+ /* Has the folio moved or been split? */
+ if (unlikely(folio != xas_reload(&xas))) {
xas_reset(&xas);
continue;
}
- p[nr++] = find_subpage(page, xas.xa_index);
+ p[nr++] = folio_file_page(folio, xas.xa_index);
if (nr == maxpages)
break;
}
--
2.27.0
next prev parent reply other threads:[~2024-08-17 9:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-17 9:51 [PATCH 0/5] mm: finish three more folio conversion Kefeng Wang
2024-08-17 9:51 ` Kefeng Wang [this message]
2024-08-19 11:02 ` [PATCH 1/5] mm: remove find_subpage() Kefeng Wang
2024-08-19 13:27 ` David Hildenbrand
2024-08-20 8:22 ` Kefeng Wang
2024-08-20 8:23 ` David Hildenbrand
2024-08-20 8:34 ` Kefeng Wang
2024-08-17 9:51 ` [PATCH 2/5] pagemap: use a folio in __readahead_batch() Kefeng Wang
2024-08-17 9:51 ` [PATCH 3/5] mm: remove thp_nr_pages() Kefeng Wang
2024-08-17 9:51 ` [PATCH 4/5] mm: khugepaged: pass a folio for set_huge_pmd() Kefeng Wang
2024-08-17 9:51 ` [PATCH 5/5] mm: remove PageTransHuge() Kefeng Wang
2024-08-18 20:33 ` [PATCH 0/5] mm: finish three more folio conversion Matthew Wilcox
2024-08-19 9:59 ` David Hildenbrand
2024-08-19 11:13 ` Kefeng Wang
2024-08-19 13:20 ` Matthew Wilcox
2024-08-20 8:41 ` Kefeng Wang
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=20240817095122.2460977-2-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=sidhartha.kumar@oracle.com \
--cc=viro@zeniv.linux.org.uk \
--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