Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ding Feng <dingf3ng@gmail.com>
To: Hugh Dickins <hughd@google.com>
Cc: Brian Foster <bfoster@redhat.com>,
	David Hildenbrand <david@kernel.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH v3 0/3] tmpfs: zero post-eof ranges on file extension
Date: Mon, 23 Nov 2026 19:53:35 +0800	[thread overview]
Message-ID: <20261123115335.17293-1-dingf3ng@gmail.com> (raw)
In-Reply-To: <c0c81eee-31a5-73e3-f113-deb1cd8a0b61@google.com>

Hi Hugh,

Thanks, that's very helpful. I won't just rebase it.

Rereading v3 against current mainline: on the fallocate path the new
folios are still !uptodate when shmem_zero_eof() runs, so it skips them
rather than zeroing them. It does still look up and lock every folio in
the extended range, so a large fallocate pays for a second pass over it.

Here is a smaller direction. A store past EOF through a mapping can only
land in the folio that straddles EOF, since shmem may PMD-map that folio
across i_size. The stored bytes leave that folio in two ways: a split,
where pages up to fallocend survive as separate folios, or swapout. If
we zero beyond i_size at both points (v3 2/3 for swapout, plus
__folio_freeze_split_file() for the split), the extending paths only
have to zero the tail of the EOF folio when it is resident. That costs
the same however large the extension is.

I tested it on 7.4-rc3 under qemu (arm64, zram swap, huge=always and
huge=never). Each test stores a byte at offsets 200 and 1MiB of a
100-byte file through a shared mapping, then optionally splits the
folio or pages it out with MADV_PAGEOUT, then extends the file with
ftruncate, pwrite or fallocate. Zeroing only the EOF folio's tail still
exposes the stored bytes after a split with a KEEP_SIZE fallocate, and
after swapout. With the split and swapout zeroing added, all 30 cases
read zero, the same as v3.

Does that match what you had in mind, or would you rather I wait until
you've had time to dig out your idea?

Thanks,
Ding Feng


      reply	other threads:[~2026-11-23 11:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 15:22 [PATCH v3 0/3] tmpfs: zero post-eof ranges on file extension Brian Foster
2025-11-21 15:22 ` [PATCH v3 1/3] tmpfs: factor out folio zeroing logic at writeout time Brian Foster
2025-11-21 15:22 ` [PATCH v3 2/3] tmpfs: zero post-eof folio ranges on swapout Brian Foster
2025-11-21 15:22 ` [PATCH v3 3/3] tmpfs: zero post-eof ranges on file extension Brian Foster
2025-11-25  2:20 ` [PATCH v3 0/3] " Baolin Wang
2026-11-20  5:13 ` Ding Feng
2026-11-21 12:47   ` David Hildenbrand (Arm)
2026-11-21 15:27     ` Ding Feng
2026-11-23 10:38       ` Hugh Dickins
2026-11-23 11:53         ` Ding Feng [this message]

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=20261123115335.17293-1-dingf3ng@gmail.com \
    --to=dingf3ng@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bfoster@redhat.com \
    --cc=david@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.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