From: Matthew Wilcox <willy@infradead.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: brauner@kernel.org, djwong@kernel.org, hch@lst.de,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
jun.li@nxp.com
Subject: Re: [PATCH v2] iomap: avoid redundant fault_in_iov_iter_readable() judgement when use larger chunks
Date: Fri, 17 May 2024 15:38:06 +0100 [thread overview]
Message-ID: <ZkdrzlM8d_GowdSO@casper.infradead.org> (raw)
In-Reply-To: <20240517201407.2144528-1-xu.yang_2@nxp.com>
On Sat, May 18, 2024 at 04:14:07AM +0800, Xu Yang wrote:
> Since commit (5d8edfb900d5 "iomap: Copy larger chunks from userspace"),
> iomap will try to copy in larger chunks than PAGE_SIZE. However, if the
> mapping doesn't support large folio, only one page of maximum 4KB will
> be created and 4KB data will be writen to pagecache each time. Then,
> next 4KB will be handled in next iteration.
>
> If chunk is 2MB, total 512 pages need to be handled finally. During this
> period, fault_in_iov_iter_readable() is called to check iov_iter readable
> validity. Since only 4KB will be handled each time, below address space
> will be checked over and over again:
>
> start end
> -
> buf, buf+2MB
> buf+4KB, buf+2MB
> buf+8KB, buf+2MB
> ...
> buf+2044KB buf+2MB
>
> Obviously the checking size is wrong since only 4KB will be handled each
> time. So this will get a correct bytes before fault_in_iov_iter_readable()
> to let iomap work well in non-large folio case.
You haven't talked at all about why this is important. Is it a
performance problem? If so, numbers please. Particularly if you want
this backported to stable.
I alos think this is the wrong way to solve the problem. We should
instead adjust 'chunk'. Given everything else going on, I think we
want:
(in filemap.h):
static inline size_t mapping_max_folio_size(struct address_space *mapping)
{
if (mapping_large_folio_support(mapping))
return PAGE_SIZE << MAX_PAGECACHE_ORDER;
return PAGE_SIZE;
}
and then in iomap,
- size_t chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER;
+ size_t chunk = mapping_max_folio_size(mapping);
(and move the initialisation of 'mapping' to before this)
next prev parent reply other threads:[~2024-05-17 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 20:14 [PATCH v2] iomap: avoid redundant fault_in_iov_iter_readable() judgement when use larger chunks Xu Yang
2024-05-17 14:38 ` Matthew Wilcox [this message]
2024-05-20 2:28 ` Xu Yang
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=ZkdrzlM8d_GowdSO@casper.infradead.org \
--to=willy@infradead.org \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=jun.li@nxp.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=xu.yang_2@nxp.com \
/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).