From: Dave Hansen <dave.hansen@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Vernon Yang <yanglincheng@kylinos.cn>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Orson Peters <orsonpeters@gmail.com>
Subject: Re: [GIT PULL] x86/urgent for 7.4-rc4
Date: Sun, 13 Sep 2026 17:18:03 -0700 [thread overview]
Message-ID: <2a15ec49-7b83-4881-a9ec-a1193602eb4f@intel.com> (raw)
In-Reply-To: <CAHk-=wiSPMB4tZB4mngU5wUJ3qJj5HwKc7x2E1dj4YnxCGadeQ@mail.gmail.com>
On 9/13/26 16:10, Linus Torvalds wrote:
> On Sun, 13 Sept 2026 at 15:54, Dave Hansen <dave.hansen@linux.intel.com> wrote:
>> The MADV_FREE one is notable for silently losing user data and having
>> been around for a couple of years.
> That explanation rewards horribly badly.
>
> MADV_FREE itself is fine. It's *supposed* to drop dirty bits and lose
> user data. That is the whole -m and only - point of MADV_FREE in the
> first place.
>
> The bug seems to be elsewhere in non-MADV_FREE code that then just is
> confused about things. But both your pull request and that commit
> message seem to try to blame MADV_FREE. What's up?
Yeah, the explanation isn't great. Sorry about that.
My read on it is that problem shows up a bit *after* the actual
MADV_FREE. The manpage goes over this scenario:
After a successful MADV_FREE operation, any stale data
(i.e., dirty, unwritten pages) will be lost when the kernel
frees the pages. However, subsequent writes to pages in the
range will succeed and then kernel cannot free those dirtied
pages, so that the caller can always see just written data.
So the problem isn't with the data which was around at MADV_FREE time,
it's with the "subsequent writes" that the kernel frees. I _think_ the
main way the kernel tells if a "subsequent write" occurs is _PAGE_DIRTY.
So the scenario is something like this:
1. First set of data goes into the page
2. MADV_FREE performed, clears _PAGE_DIRTY. Page eligible for reclaim.
3. Second set of data is written, sets _PAGE_DIRTY. Page *in*eligible
for reclaim.
4. PMD is mprotect()'d which flows through pmd_modify(). _PAGE_DIRTY
is lost. Page now wrongly eligible for reclaim again.
5. Reclaim goes after the page, discards second set of data.
At least that was my read on it.
next prev parent reply other threads:[~2026-09-14 0:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 22:53 Dave Hansen
2026-09-13 23:10 ` Linus Torvalds
2026-09-13 23:23 ` Linus Torvalds
2026-09-14 0:18 ` Dave Hansen [this message]
2026-09-14 1:04 ` Linus Torvalds
2026-09-14 1:12 ` Dave Hansen
2026-09-14 10:12 ` Orson Peters
2026-09-14 16:36 ` Linus Torvalds
2026-09-14 1:09 ` pr-tracker-bot
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=2a15ec49-7b83-4881-a9ec-a1193602eb4f@intel.com \
--to=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonpeters@gmail.com \
--cc=rick.p.edgecombe@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=yanglincheng@kylinos.cn \
/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
all inboxes | Powered by JetHome®