mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Kelvin Zhang <zhangxp1998@gmail.com>
Cc: linux-mm@kvack.org, "Liam R . Howlett" <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
	Pedro Falcato <pfalcato@suse.de>,
	Kalesh Singh <kaleshsingh@google.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] fs/proc/task_mmu: check THP exclusivity for each subpage
Date: Mon, 2 Nov 2026 08:01:11 +0100	[thread overview]
Message-ID: <6b69aa22-f392-4cc8-9f7e-d9077e951cc4@kernel.org> (raw)
In-Reply-To: <20261101110247.95a03a5601f235ffb39c54c1@linux-foundation.org>

On 11/1/26 20:02, Andrew Morton wrote:
> On Sun,  1 Nov 2026 09:01:00 -0800 Kelvin Zhang <zhangxp1998@gmail.com> wrote:
> 
>> A PMD-mapped THP can contain subpages with different mapcounts. For
>> example, after fork(), the child can unmap only part of the THP. The
>> parent retains its PMD mapping, while the remaining child mappings
>> are PTE mappings.
>>
>> pagemap_pmd_range_thp() passes the same initial page to
>> __folio_page_mapped_exclusively() for every pagemap entry. With
>> CONFIG_PAGE_MAPCOUNT=y, this applies the first subpage's exclusivity
>> to all entries, falsely setting or clearing PM_MMAP_EXCLUSIVE for
>> subpages with different sharing.
>>
>> Pass page + idx to check the subpage corresponding to each entry, as
>> was done before converting to __folio_page_mapped_exclusively(). The
>> index already accounts for reads starting partway through the PMD.
>> The conservative whole-folio check without CONFIG_PAGE_MAPCOUNT is
>> unchanged.
> 
> Thanks.
> 
> I don't want to pick on you at all, but this is a classic changelog - I
> see this pattern so often.
> 
> 	a) here's what the code does
> 
> 	b) here's why that's wrong
> 
> 	c) here's how I fixed it.
> 
> But that's missing a very important bullet point:
> 
> 	a) here's what the code does
> 
> 	b) here's why that's wrong
> 
> 	c) here's how this affects users
> 
> 	d) here's how I fixed it.
> 
> see?  This omission is so common!  And I might have sent one or two
> emails asking people for the missing info.
> 
> For the missing c), how does this sound?
> 
> : With transparent huge pages, /proc/PID/pagemap can incorrectly
> : report shared pages as exclusive, or vice versa, after fork() and
> : partial unmapping.  This can mislead memory-analysis and
> : checkpoint/restore tools.  Actual mappings and copy-on-write behavior
> : are unaffected.
> 
> And now that we have our statement of userspace impact, busy non-mm
> downstream readers of this patch can easily see why your proposed
> cc:stable is justified.
> 
> 
> Also, it would be helpful to show brief before-and-after excerpts from
> /proc/PID/pagemap to help others understand the impact of the change. 
> But I don't think we need a v2 just for this.

See my reply. I'm not sure what to best do here, but I want to use this as an
opportunity to say "see, nobody noticed in 1.5 years; and it was found be code
analysis then, so let's simplify it".

So it's either straight to [1] or a "let's do i first the old way" followed by
[1]. I would just do [1] immediately.

Because nobody cares about that flag.


[1] https://lore.kernel.org/linux-mm/20260412-mapcount-v1-4-05e8dfab52e0@kernel.org/

-- 
Cheers,

David

      reply	other threads:[~2026-11-02  7:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 17:01 Kelvin Zhang
2026-11-01 18:07 ` David Hildenbrand (Arm)
2026-11-01 18:18   ` David Hildenbrand (Arm)
2026-11-01 18:27     ` Kelvin Zhang
2026-11-01 19:02 ` Andrew Morton
2026-11-02  7:01   ` David Hildenbrand (Arm) [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=6b69aa22-f392-4cc8-9f7e-d9077e951cc4@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=jannh@google.com \
    --cc=kaleshsingh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=pfalcato@suse.de \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@kernel.org \
    --cc=zhangxp1998@gmail.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

all inboxes | Powered by JetHome®