linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Chi Zhiling <chizhiling@163.com>
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Chi Zhiling <chizhiling@kylinos.cn>
Subject: Re: [RFC PATCH 2/3] mm/filemap: Avoid modifying iocb->ki_flags for AIO in filemap_get_pages()
Date: Wed, 23 Jul 2025 15:33:55 +0100	[thread overview]
Message-ID: <aIDy076Sxt544qja@casper.infradead.org> (raw)
In-Reply-To: <20250723101825.607184-3-chizhiling@163.com>

On Wed, Jul 23, 2025 at 06:18:24PM +0800, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@kylinos.cn>
> 
> Setting IOCB_NOWAIT in filemap_get_pages() for AIO is only used to
> indicate not to block in the filemap_update_page(), with no other purpose.
> Moreover, in filemap_read(), IOCB_NOWAIT will be set again for AIO.
> 
> Therefore, adding a parameter to the filemap_update_page function to
> explicitly indicate not to block serves the same purpose as indicating
> through iocb->ki_flags, thus avoiding modifications to iocb->ki_flags.
> 
> This patch does not change the original logic and is preparation for the
> next patch.

Passing multiple booleans to a function is an antipattern.
Particularly in this case, since we could just pass iocb->ki_flags
to the function.

But I think there's a less complicated way to do what you want.
Just don't call filemap_update_page() if there are uptodate folios
in the batch:

+++ b/mm/filemap.c
@@ -2616,9 +2616,10 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
                        goto err;
        }
        if (!folio_test_uptodate(folio)) {
-               if ((iocb->ki_flags & IOCB_WAITQ) &&
-                   folio_batch_count(fbatch) > 1)
-                       iocb->ki_flags |= IOCB_NOWAIT;
+               if (folio_batch_count(fbatch) > 1) {
+                       err = -EAGAIN;
+                       goto err;
+               }
                err = filemap_update_page(iocb, mapping, count, folio,
                                          need_uptodate);
                if (err)


  reply	other threads:[~2025-07-23 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 10:18 [RFC PATCH 0/3] Tiny optimization for large read operations Chi Zhiling
2025-07-23 10:18 ` [RFC PATCH 1/3] mm/filemap: Do not use is_partially_uptodate for entire folio Chi Zhiling
2025-07-23 10:18 ` [RFC PATCH 2/3] mm/filemap: Avoid modifying iocb->ki_flags for AIO in filemap_get_pages() Chi Zhiling
2025-07-23 14:33   ` Matthew Wilcox [this message]
2025-07-24  1:54     ` Chi Zhiling
2025-07-23 10:18 ` [RFC PATCH 3/3] mm/filemap: Skip non-uptodate folio when folios are available Chi Zhiling

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=aIDy076Sxt544qja@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=chizhiling@163.com \
    --cc=chizhiling@kylinos.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;
as well as URLs for NNTP newsgroup(s).