Linux filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Jinliang Zheng <alexjlzheng@gmail.com>
Cc: alexjlzheng@tencent.com, brauner@kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH] iomap: avoid unnecessary ifs_set_range_uptodate() with locks
Date: Wed, 2 Jul 2025 11:52:13 -0700	[thread overview]
Message-ID: <20250702185213.GY10009@frogsfrogsfrogs> (raw)
In-Reply-To: <20250702120912.36380-1-alexjlzheng@tencent.com>

On Wed, Jul 02, 2025 at 08:09:12PM +0800, Jinliang Zheng wrote:
> On Tue, 1 Jul 2025 11:47:37 -0700, djwong@kernel.org wrote:
> > On Tue, Jul 03, 2025 at 10:48:47PM +0800, alexjlzheng@gmail.com wrote:
> > > From: Jinliang Zheng <alexjlzheng@tencent.com>
> > > 
> > > In the buffer write path, iomap_set_range_uptodate() is called every
> > > time iomap_end_write() is called. But if folio_test_uptodate() holds, we
> > > know that all blocks in this folio are already in the uptodate state, so
> > > there is no need to go deep into the critical section of state_lock to
> > > execute bitmap_set().
> > > 
> > > Although state_lock may not have significant lock contention due to
> > > folio lock, this patch at least reduces the number of instructions.
> > > 
> > > Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
> > > ---
> > >  fs/iomap/buffered-io.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> > > index 3729391a18f3..fb4519158f3a 100644
> > > --- a/fs/iomap/buffered-io.c
> > > +++ b/fs/iomap/buffered-io.c
> > > @@ -71,6 +71,9 @@ static void iomap_set_range_uptodate(struct folio *folio, size_t off,
> > >  	unsigned long flags;
> > >  	bool uptodate = true;
> > >  
> > > +	if (folio_test_uptodate(folio))
> > > +		return;
> > 
> > Looks fine, but how exhaustively have you tested this with heavy IO
> > workloads?  I /think/ it's the case that folios always creep towards
> > ifs_is_fully_uptodate() == true state and once they've gotten there
> > never go back.  But folio state bugs are tricky to detect once they've
> > crept in.
> 
> I tested fio, ltp and xfstests combined for about 30 hours. The command
> used for fio test is:
> 
>   fio --name=4k-rw \
>     --filename=/data2/testfile \
>     --size=1G \
>     --bs=4096 \
>     --ioengine=libaio \
>     --iodepth=32 \
>     --rw=randrw \
>     --direct=0 \
>     --buffered=1 \
>     --numjobs=16 \
>     --runtime=60 \
>     --time_based \
>     --group_reporting
> 
> ltp and xfstests showed no noticeable errors caused by this patch.

<nod> I think this fine then...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> 
> thanks,
> Jinliang Zheng. :)
> 
> > 
> > --D
> > 
> > > +
> > >  	if (ifs) {
> > >  		spin_lock_irqsave(&ifs->state_lock, flags);
> > >  		uptodate = ifs_set_range_uptodate(folio, ifs, off, len);
> > > -- 
> > > 2.49.0
> > > 
> > > 
> 

  reply	other threads:[~2025-07-02 18:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 14:48 [PATCH] iomap: avoid unnecessary ifs_set_range_uptodate() with locks alexjlzheng
2025-07-01 18:47 ` Darrick J. Wong
2025-07-02 12:09   ` Jinliang Zheng
2025-07-02 18:52     ` Darrick J. Wong [this message]
2025-07-03 13:50     ` Christoph Hellwig
2025-07-03 14:33       ` Jinliang Zheng
2025-07-03 13:52 ` Christoph Hellwig
2025-07-03 17:34   ` Matthew Wilcox
2025-07-07  4:08     ` Jinliang Zheng
2025-07-09  3:30   ` Jinliang Zheng
2025-07-11  7:44     ` Christoph Hellwig

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=20250702185213.GY10009@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=alexjlzheng@gmail.com \
    --cc=alexjlzheng@tencent.com \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.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