From: Chi Zhiling <chizhiling@163.com>
To: Matthew Wilcox <willy@infradead.org>
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: Thu, 24 Jul 2025 09:54:24 +0800 [thread overview]
Message-ID: <07dd7e42-b2c4-4fbb-87f3-ab888d11256d@163.com> (raw)
In-Reply-To: <aIDy076Sxt544qja@casper.infradead.org>
On 2025/7/23 22:33, Matthew Wilcox wrote:
> 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;
> + }
Yes, this is a completely better way.
Would you mind if I add
"Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>"
in the next version?
> err = filemap_update_page(iocb, mapping, count, folio,
> need_uptodate);
> if (err)
Thanks,
next prev parent reply other threads:[~2025-07-24 1:54 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
2025-07-24 1:54 ` Chi Zhiling [this message]
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=07dd7e42-b2c4-4fbb-87f3-ab888d11256d@163.com \
--to=chizhiling@163.com \
--cc=akpm@linux-foundation.org \
--cc=chizhiling@kylinos.cn \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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
all inboxes | Powered by JetHome®