Re: [RFC PATCH 2/8] mm: Add PG_atomic

Matthew Wilcox
2025-11-14T13:16:59Z

On Fri, Nov 14, 2025 at 10:30:09AM +0530, Ritesh Harjani wrote:
> Matthew Wilcox <willy@infradead.org> writes:
>
> > On Wed, Nov 12, 2025 at 04:36:05PM +0530, Ojaswin Mujoo wrote:
> >> From: John Garry <john.g.garry@oracle.com>
> >>
> >> Add page flag PG_atomic, meaning that a folio needs to be written back
> >> atomically. This will be used by for handling RWF_ATOMIC buffered IO
> >> in upcoming patches.
> >
> > Page flags are a precious resource. I'm not thrilled about allocating one
> > to this rather niche usecase. Wouldn't this be more aptly a flag on the
> > address_space rather than the folio? ie if we're doing this kind of write
> > to a file, aren't most/all of the writes to the file going to be atomic?
>
> As of today the atomic writes functionality works on the per-write
> basis (given it's a per-write characteristic).
>
> So, we can have two types of dirty folios sitting in the page cache of
> an inode. Ones which were done using atomic buffered I/O flag
> (RWF_ATOMIC) and the other ones which were non-atomic writes. Hence a
> need of a folio flag to distinguish between the two writes.

I know, but is this useful? AFAIK, the files where Postgres wants to
use this functionality are the log files, and all writes to the log
files will want to use the atomic functionality. What's the usecase
for "I want to mix atomic and non-atomic buffered writes to this file"?