From: Harry Yoo <harry.yoo@oracle.com>
To: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, david@redhat.com
Subject: Re: [RFC] mm: Add MADV_NONZERO to skip redundant zeroing in MADV_DONTNEED
Date: Wed, 4 Jun 2025 10:49:25 +0900 [thread overview]
Message-ID: <aD-mJT6VCXPJfj7P@hyeyoo> (raw)
In-Reply-To: <ed44f504-64a5-4c64-ba99-7533e027e4c1@gmail.com>
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.
Or am I missing something?
> This causes measurable overhead - in some synthetic tests I'm seeing ~40%
> extra
> latency from the zeroing. I'm thinking of adding a MADV_NONZERO flag that
> would
> let us skip the zeroing when:
>
> 1. It's explicitly requested (MADV_DONTNEED|MADV_NONZERO)
> 2. We're confident it's safe (VM_IO, VM_HUGETLB, etc)
> 3. The user has explicitly marked the region as non-sensitive
>
> Before I go deeper on patches, I wanted to check:
> - Does this sound reasonable?
> - Any obvious security holes I'm missing?
> - Would you prefer a new flag or a separate advice type?
>
> Early prototype numbers look promising, but I want to make sure I'm not
> missing
> something fundamental. If the concept seems viable, I'll work up proper
> benchmarks
> and formal patches.
...and I'm wondering what does the informal patches do?
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2025-06-04 1:49 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 [this message]
2025-06-04 11:27 ` David Hildenbrand
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=aD-mJT6VCXPJfj7P@hyeyoo \
--to=harry.yoo@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ayaanmirzabaig85@gmail.com \
--cc=david@redhat.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