Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pedro Falcato <pfalcato@suse.de>
To: Gregg Leventhal <gleventhal@janestreet.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Song Liu <song@kernel.org>,
	linux-fsdevel@vger.kernel.org,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	 Eric Hagberg <ehagberg@janestreet.com>,
	David Hildenbrand <david@kernel.org>,
	 Lorenzo Stoakes <ljs@kernel.org>, Zi Yan <ziy@nvidia.com>
Subject: Re: Subject: [BUG/RFC] write-open file THP cache purge can discard dirty page cache
Date: Wed, 1 Jul 2026 15:23:10 +0100	[thread overview]
Message-ID: <akUezvsxuDKR8D6z@pedro-suse> (raw)
In-Reply-To: <CAFN_u7EE0ooQsH2JAnYn6EFrxnRToXAqvW_uUE0aqPDEPEmSAw@mail.gmail.com>

On Wed, Jul 01, 2026 at 09:07:44AM -0400, Gregg Leventhal wrote:
> Thanks all, it sounds like there is nothing for me to do quite yet, correct?

Correct.

> Also Zi Yan is correct, I meant order-0 folios.
> 
> Please let me know if there is anything I can do.
> FWIW: The patch I suggested did seem to resolve the issue (based on my
> testing) and did prevent my reproducer from reproducing (whereas it
> repros ~instantly for me on a not patched kernel), but I (obviously)
> defer to you all here.

FWIW, yes, I think your patch approaches correctness, but there are subtle issues, like:

Thread 0                    | Thread 1
do_dentry_open()            | do_dentry_open()
 FMODE_WRITE                | FMODE_WRITE
  nr_thps > 0               | /* the rest of the THP truncate logic */
  write_and_wait            |
                            |  write(opened_file)
                            |  /* we now have dirtied folios */
  truncate()                |

where the effective result depends on whether the invalidate lock
is held across filemap_write_and_wait() as well. But it will always,
as far as I can see, result in weird cases where writes can simply go
missing (truncate isn't really supposed to be called without the inode
lock, I think).

Matthew raised that, fundamentally, large-folio unaware filesystems should
not see these file THPs mixed in with dirty folios. Which is sensible and
seems to result in a simpler and easier to reason about fix overall.


-- 
Pedro


  reply	other threads:[~2026-07-01 14:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 17:01 Subject: [BUG/RFC] write-open file THP cache purge can discard dirty page cache Gregg Leventhal
2026-06-30 17:18 ` Gregg Leventhal
2026-06-30 18:31 ` Pedro Falcato
2026-06-30 18:49   ` Pedro Falcato
2026-06-30 19:55     ` Pedro Falcato
2026-06-30 22:34       ` Matthew Wilcox
2026-06-30 22:48       ` Zi Yan
2026-07-01 12:05         ` Pedro Falcato
2026-07-01 11:54       ` Matthew Wilcox
2026-07-01 12:04         ` Pedro Falcato
2026-07-01 12:48         ` Pedro Falcato
2026-07-01 13:07           ` Gregg Leventhal
2026-07-01 14:23             ` Pedro Falcato [this message]
2026-06-30 18:36 ` Matthew Wilcox
2026-06-30 19:05   ` Zi Yan
2026-06-30 19:07     ` Matthew Wilcox

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=akUezvsxuDKR8D6z@pedro-suse \
    --to=pfalcato@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=ehagberg@janestreet.com \
    --cc=gleventhal@janestreet.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=song@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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