From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,willy@infradead.org,jack@suse.cz,chizhiling@kylinos.cn,akpm@linux-foundation.org
Subject: [merged mm-stable] mm-filemap-reduce-unnecessary-xarray-lookups-in-filemap_get_folios_contig.patch removed from -mm tree
Date: Tue, 28 Jul 2026 21:13:06 -0700 [thread overview]
Message-ID: <20260729041306.D97841F000E9@smtp.kernel.org> (raw)
The quilt patch titled
Subject: mm/filemap: reduce unnecessary xarray lookups in filemap_get_folios_contig()
has been removed from the -mm tree. Its filename was
mm-filemap-reduce-unnecessary-xarray-lookups-in-filemap_get_folios_contig.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Chi Zhiling <chizhiling@kylinos.cn>
Subject: mm/filemap: reduce unnecessary xarray lookups in filemap_get_folios_contig()
Date: Sat, 20 Jun 2026 14:24:46 +0800
Apply the same optimization used in filemap_get_read_batch() by moving the
boundary check from the loop condition to before xas_next(), avoiding an
unnecessary xarray lookup and reducing branches in the fast path.
Link: https://lore.kernel.org/20260620062446.351475-3-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/filemap.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
--- a/mm/filemap.c~mm-filemap-reduce-unnecessary-xarray-lookups-in-filemap_get_folios_contig
+++ a/mm/filemap.c
@@ -2270,10 +2270,11 @@ unsigned filemap_get_folios_contig(struc
unsigned long nr;
struct folio *folio;
- rcu_read_lock();
+ if (*start > end)
+ return 0;
- for (folio = xas_load(&xas); folio && xas.xa_index <= end;
- folio = xas_next(&xas)) {
+ rcu_read_lock();
+ for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
if (xas_retry(&xas, folio))
continue;
/*
@@ -2281,11 +2282,11 @@ unsigned filemap_get_folios_contig(struc
* No current caller is looking for DAX entries.
*/
if (xa_is_value(folio))
- goto update_start;
+ break;
/* If we landed in the middle of a THP, continue at its end. */
if (xa_is_sibling(folio))
- goto update_start;
+ break;
if (!folio_try_get(folio))
goto retry;
@@ -2293,29 +2294,27 @@ unsigned filemap_get_folios_contig(struc
if (unlikely(folio != xas_reload(&xas)))
goto put_folio;
- if (!folio_batch_add(fbatch, folio)) {
- *start = folio_next_index(folio);
- goto out;
- }
+ if (!folio_batch_add(fbatch, folio))
+ break;
+
xas_advance(&xas, folio_next_index(folio) - 1);
+ if (xas.xa_index >= end)
+ break;
continue;
+
put_folio:
folio_put(folio);
-
retry:
xas_reset(&xas);
}
+ rcu_read_unlock();
-update_start:
nr = folio_batch_count(fbatch);
-
if (nr) {
folio = fbatch->folios[nr - 1];
*start = folio_next_index(folio);
}
-out:
- rcu_read_unlock();
- return folio_batch_count(fbatch);
+ return nr;
}
EXPORT_SYMBOL(filemap_get_folios_contig);
_
Patches currently in -mm which might be from chizhiling@kylinos.cn are
reply other threads:[~2026-07-29 4:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260729041306.D97841F000E9@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=chizhiling@kylinos.cn \
--cc=jack@suse.cz \
--cc=mm-commits@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).