On Thu, 3 Jul 2025 06:52:44 -0700, Christoph Hellwig wrote: > On Tue, Jul 01, 2025 at 10:48:47PM +0800, alexjlzheng@xxxxxxxxx wrote: > > From: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx> > > > > 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. > > That means the uptodate bitmap is stale in that case. That would Hi, after days of silence, I re-read this email thread to make sure I didn't miss something important. I realized that maybe we are not aligned and I didn't understand your sentence above. Would you mind explaining your meaning in more detail? In addition, what I want to say is that once folio_test_uptodate() is true, all bits in ifs->state are in the uptodate state. So there is no need to acquire the lock and set it again. This repeated setting happens in __iomap_write_end(). thanks, Jinliang Zheng. :) > only matter if we could clear the folio uptodate bit and still > expect the page content to survive. Which sounds dubious and I could > not find anything relevant grepping the tree, but I'm adding the > linux-mm list just in case. > > > > > Signed-off-by: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx> > > --- > > 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; > > + > > if (ifs) { > > spin_lock_irqsave(&ifs->state_lock, flags); > > uptodate = ifs_set_range_uptodate(folio, ifs, off, len); > > -- > > 2.49.0 > > > > > ---end quoted text---