From: David Hildenbrand <david@redhat.com>
To: Harry Yoo <harry.yoo@oracle.com>,
Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [RFC] mm: Add MADV_NONZERO to skip redundant zeroing in MADV_DONTNEED
Date: Wed, 4 Jun 2025 13:27:51 +0200 [thread overview]
Message-ID: <85704ffa-6188-4b90-9455-8b9ce7b1b98e@redhat.com> (raw)
In-Reply-To: <aD-mJT6VCXPJfj7P@hyeyoo>
On 04.06.25 03:49, Harry Yoo wrote:
> On Wed, Jun 04, 2025 at 06:31:59AM +0530, Ayaan Mirza Baig wrote:
>> Hi Andrew,
>>
>> I've been looking at MADV_DONTNEED and noticed we always zero pages, even
>> when
>> it might not be necessary for cases like:
>>
>> - Media buffers (video/audio processing)
>> - Temporary compute workloads
>> - Pre-zeroed memory pools
>
> Hi Ayaan,
>
> I don't think this "skipping zeroing" is limited to MADV_DONTNEED at all?
>
> We don't zero pages during zapping (unless init_on_free is enabled),
> but zero pages when madvise(MADV_DONTNEED)'d area is accessed again
> (for anonymous mappings), because that's how faulting anonymous mappings
> works.
>
> And if you're suggesting that you want to skip zeroing (on some conditions)
> when faulting an anonymous mapping, we can't do that because applications
> rely on the guarantee that such pages are zeroed.
Yeah, no way we're adding something like that.
What we discussed last years at plumbers IIRC in Rik's session was
having a per-process cache of zapped pages. Essentially, during
MADV_DONTNEED we could move the pages to that cache, and on re-access
(if the process opted in) we could grab one of these pages from the
per-process cache without zeroing them out. On memory pressure we would
flush the cache.
There are some challenges (e.g., how to keep these pages
migratable/swappable etc).
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2025-06-04 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 1:01 Ayaan Mirza Baig
2025-06-04 1:49 ` Harry Yoo
2025-06-04 11:27 ` David Hildenbrand [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=85704ffa-6188-4b90-9455-8b9ce7b1b98e@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ayaanmirzabaig85@gmail.com \
--cc=harry.yoo@oracle.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