From: Matthew Wilcox <willy@infradead.org>
To: chensong_2000@189.cn
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/filemap: introduce local helper for_each_folio
Date: Mon, 9 Sep 2024 20:47:46 +0100 [thread overview]
Message-ID: <Zt9Q4kegrxnulnR2@casper.infradead.org> (raw)
In-Reply-To: <20240909061735.152421-1-chensong_2000@189.cn>
On Mon, Sep 09, 2024 at 02:17:35PM +0800, chensong_2000@189.cn wrote:
> From: Song Chen <chensong_2000@189.cn>
>
> Introduce for_each_folio to iterate folios in xarray for code style
> compliance and better readability.
I'm not sure this is really worth it.
> Signed-off-by: Song Chen <chensong_2000@189.cn>
> ---
> mm/filemap.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index d62150418b91..5386348acacd 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -62,6 +62,9 @@
>
> #include "swap.h"
>
> +#define for_each_folio(folio, xas, max) \
> + for (folio = xas_load(&xas); \
> + folio && xas.xa_index <= max; folio = xas_next(&xas))
> /*
> * Shared mappings implemented 30.11.1994. It's not fully working yet,
> * though.
> @@ -2170,8 +2173,7 @@ unsigned filemap_get_folios_contig(struct address_space *mapping,
>
> rcu_read_lock();
>
> - for (folio = xas_load(&xas); folio && xas.xa_index <= end;
> - folio = xas_next(&xas)) {
> + for_each_folio(folio, xas, end) {
> if (xas_retry(&xas, folio))
> continue;
> /*
> @@ -2306,7 +2308,7 @@ static void filemap_get_read_batch(struct address_space *mapping,
> struct folio *folio;
>
> rcu_read_lock();
> - for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) {
> + for_each_folio(folio, xas, ULONG_MAX) {
> if (xas_retry(&xas, folio))
> continue;
> if (xas.xa_index > max || xa_is_value(folio))
> --
> 2.34.1
>
>
prev parent reply other threads:[~2024-09-09 19:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 6:17 chensong_2000
2024-09-09 19:47 ` Matthew Wilcox [this message]
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=Zt9Q4kegrxnulnR2@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=chensong_2000@189.cn \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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