From: "David Hildenbrand (Arm)" <david@kernel.org>
To: 天狼 <rockeet@gmail.com>, linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org,
"Lorenzo Stoakes (Arm)" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>
Subject: Re: [RFC] madvise: best-effort deferred writeback for shared file mappings
Date: Mon, 28 Sep 2026 13:29:43 +0200 [thread overview]
Message-ID: <7ebe4591-2306-4b5c-b83e-6a2e34b52bd8@kernel.org> (raw)
In-Reply-To: <CAAE3jtcL_CZJdcattCwe0RraKnHcZO=UknxEUQVG858ouZCUQA@mail.gmail.com>
On 9/28/26 09:07, 天狼 wrote:
> Hello,
Hi,
>
> I would like to request feedback on a mapping-scoped, best-effort hint
> to defer background writeback while an application is still constructing
> data in a writable MAP_SHARED mapping of a regular disk-backed file.
> This is a feature request, not a patch submission or a benchmark report.
>
> Motivation
> ----------
>
> Consider an application building a large data structure, for example
> 10 GiB, through multiple passes that repeatedly modify the same pages.
> After construction, it persists the file and publishes it for other
> processes to mmap and read.
Is it an option to just construct the data using anonymous memory and then
write()'in it once ready in one operation?
Why exactly are you using writable MAP_SHARED mappings?
>
> Building directly in MAP_SHARED keeps the data in the file's page cache,
> which also serves the consumers. However, background writeback can write
> intermediate contents that subsequent construction passes dirty again.
> The application knows when construction ends, but cannot express that
> knowledge as a mapping-local writeback scheduling hint.
>
> Building in private memory and then doing buffered writes adds a bulk
> copy into the file's page cache. Direct I/O does not itself populate that
> cache for subsequent file-mapped consumers. A memfd can share the build
> buffer, but requires a separate object for persistence and changes the
> consumer interface. Global dirty/writeback tuning is broader than this
> particular mapping and construction phase.
>
> Proposed interface and behavior
> -------------------------------
>
> Tentatively, a pair of madvise operations could express this:
>
> madvise(addr, len, MADV_DEFER_WRITEBACK);
> /* Construct and repeatedly update the shared file mapping. */
> madvise(addr, len, MADV_ALLOW_WRITEBACK);
> /* Use existing synchronization calls if durability is required. */
>
> The names are placeholders for discussion, not existing constants.
I don't think this behavior should be part of madvise. Way too specific.
--
Cheers,
David
next prev parent reply other threads:[~2026-09-28 11:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 7:07 [RFC] madvise: best-effort deferred writeback for shared file mappings 天狼
2026-09-28 11:29 ` David Hildenbrand (Arm) [this message]
2026-09-28 13:09 ` 天狼
2026-09-28 19:12 ` David Hildenbrand (Arm)
2026-09-29 4:06 ` 天狼
2026-09-29 6:59 ` David Hildenbrand (Arm)
2026-09-29 8:59 ` Lorenzo Stoakes (ARM)
2026-09-30 10:27 ` 天狼
2026-09-30 11:38 ` David Hildenbrand (Arm)
2026-09-30 12:08 ` Lorenzo Stoakes (ARM)
2026-09-30 12:11 ` Lorenzo Stoakes (ARM)
2026-09-30 14:14 ` 天狼
2026-09-30 14:24 ` Lorenzo Stoakes (ARM)
2026-09-30 15:33 ` Lorenzo Stoakes (ARM)
2026-09-30 15:29 ` 天狼
2026-09-30 15:43 ` Lorenzo Stoakes (ARM)
2026-09-30 16:38 ` Jan Kara
2026-10-01 4:28 ` 天狼
2026-10-01 8:35 ` Lorenzo Stoakes (ARM)
2026-10-01 13:21 ` 天狼
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=7ebe4591-2306-4b5c-b83e-6a2e34b52bd8@kernel.org \
--to=david@kernel.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=rockeet@gmail.com \
--cc=vbabka@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