From: Wei Gao via ltp <ltp@lists.linux.it>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] mmap21.c: Test for new MAP_DROPPABLE flag for mmap
Date: Thu, 2 Jan 2025 20:42:56 -0500 [thread overview]
Message-ID: <Z3dAoOp560iQBheO@wegao1> (raw)
In-Reply-To: <CAEemH2cdZ1fJHma3xDF1r-wPycbLqXRXT0Q4smqivuAZcWC9GQ@mail.gmail.com>
On Tue, Dec 31, 2024 at 06:04:54PM +0800, Li Wang wrote:
> On Sat, Dec 28, 2024 at 9:32 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:
>
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > ---
>
> + for (size_t i = 0; i < alloc_size; i += page_size) {
> > + if (!*(uint8_t *)(alloc + i)) {
> > + *shared_var = 1;
> > + break;
> > + }
> > + }
> > + }
> > +
> > + TST_EXP_EQ_LI((*shared_var), 1);
> >
>
> The test assumes that reclaimed MAP_DROPPABLE pages will be
> zeroed out when accessed. While this behavior is plausible, it depends
> on how MAP_DROPPABLE is implemented in the kernel.
>
> Do you have any clue (documents or code) that indicates this is true?
Thanks for your quick feedback , i will try to give clue for this:
1) Base the kernel commit message indicate memory will be zero.
commit 9651fcedf7b92d3f7f1ab179e8ab55b85ee10fc1
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date: Thu Dec 8 17:55:04 2022 +0100
These characteristics mean that we can introduce VM_DROPPABLE, which
has the following semantics:
a) It never is written out to swap.
b) Under memory pressure, mm can just drop the pages (so that they're
zero when read back again). <<<<<<<<<<<<<<<<<
c) It is inherited by fork.
d) It doesn't count against the mlock budget, since nothing is locked.
e) If there's not enough memory to service a page fault, it's not fatal,
and no signal is sent.
2) When kernel read back the dropped anonymous memory will trigger do_page_fault(),
finally it will reach do_anonymous_page() and hit following line:
https://elixir.bootlin.com/linux/v4.6/source/mm/memory.c#L2750
So normally you will read zeroed memory.
Call stack happen when read back:
do_page_fault()
↓
handle_mm_fault()
↓
__handle_mm_fault()
↓
handle_pte_fault()
↓
do_pte_missing()
↓
do_anonymous_page()
>
> --
> Regards,
> Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-01-03 1:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-28 13:32 [LTP] [PATCH v1] mmap21.c: Test for new MAP_DROPPABLE flag for mmap Wei Gao via ltp
2024-12-31 10:04 ` Li Wang
2025-01-02 9:38 ` Cyril Hrubis
2025-01-03 1:42 ` Wei Gao via ltp [this message]
2025-01-03 13:54 ` Wei Gao via ltp
2025-01-03 13:56 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-03-10 16:18 ` Cyril Hrubis
2025-04-16 19:16 ` [LTP] [PATCH v3] mmap22.c: " Wei Gao via ltp
2025-04-25 11:40 ` Cyril Hrubis
2025-04-28 16:04 ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-05-07 15:25 ` Cyril Hrubis
2025-05-12 8:43 ` Jan Stancek via ltp
2025-05-13 15:44 ` Wei Gao via ltp
2025-05-14 8:51 ` Jan Stancek via ltp
2025-05-14 9:04 ` Li Wang via ltp
2025-05-14 9:10 ` Jan Stancek via ltp
2025-05-14 9:14 ` Li Wang via ltp
2025-05-14 11:15 ` Jan Stancek via ltp
2025-05-14 12:44 ` Li Wang via ltp
2025-05-14 12:54 ` Jan Stancek via ltp
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=Z3dAoOp560iQBheO@wegao1 \
--to=ltp@lists.linux.it \
--cc=liwang@redhat.com \
--cc=wegao@suse.com \
/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