From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>, Peter Xu <peterx@redhat.com>
Cc: "Alex Williamson" <alex@shazbot.org>,
kvm@vger.kernel.org,
"Loïc Molinari" <loic.molinari@collabora.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org,
"Madhavan Srinivasan" <maddy@linux.ibm.com>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, "Jason Gunthorpe" <jgg@ziepe.ca>
Subject: Re: [PATCH v4 2/4] mm/huge_memory: copy file THPs at fork like copy_present_ptes() does
Date: Wed, 4 Nov 2026 12:40:21 +0100 [thread overview]
Message-ID: <dd966816-a83d-47ea-8faf-bf80d3b2642e@virtuozzo.com> (raw)
In-Reply-To: <8c164738-8025-482f-828a-3f919150a930@kernel.org>
On 10/27/26 15:39, David Hildenbrand (Arm) wrote:
> Any reason we're not adding the vma_is_cow_mapping() check on the
> softleaf_is_device_private_write() path as well?
>
> (I think they are all anonymous ... just for consistency)
No reason, copy_nonpresent_pte() has it there too. Will add in v5.
> Is the fallthrough:
>
> add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR)
>
> really expected?
Yes: copy_nonpresent_pte() counts migration and device private entries
in the child's RSS as well. File folios reach it now, so the hunk below
switches it to mm_counter(src_folio), as the PTE path does.
zap_huge_pmd_folio() subtracts a file folio from mm_counter_file(), so
MM_ANONPAGES there would leave the child's counters unbalanced.
>> + bool writable;
>
> Why do we need this variable?
It copies __copy_present_ptes(), which snapshots pte_write() before
the uffd-rwp branch. Looking at it again, that branch only rewrites an
RWP marker, which is PAGE_NONE and never writable, and vm_page_prot of
a CoW mapping has no write bit either. So the snapshot looks redundant
both here and in __copy_present_ptes().
I'd keep it in this series so the PMD path matches the PTE one, and
drop it from both in the cleanup together with the gotos.
Kiryl, does that match your understanding of the PTE path?
>> + goto copy_pmd;
>> }
>
> Likely we should clean this up later to avoid the gotos.
No problem, but let's do it later, on top of this series.
And on your stable question in 3/4: v5 will carry Cc: stable on patches
1-3.
The backport to 6.12 won't apply as is, so I'll do the backports once we
get a failure mail on stable re-apply attempt.
(or I need to do backports in advance? Need an advice here.)
Thanks for the review!
--
Konstantin Khorenko
next prev parent reply other threads:[~2026-11-04 11:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 20:35 [PATCH v4 0/4] mm/huge_memory: copy PMDs at fork like the PTE path does Konstantin Khorenko
2026-10-21 20:36 ` [PATCH v4 1/4] mm/rmap: duplicate a PMD mapping as one in folio_dup_file_rmap_pmd() Konstantin Khorenko
2026-10-21 20:43 ` Zi Yan
2026-10-22 10:34 ` Konstantin Khorenko
2026-10-22 8:07 ` Lorenzo Stoakes (ARM)
2026-10-22 10:44 ` Konstantin Khorenko
2026-10-22 12:11 ` Lorenzo Stoakes (ARM)
2026-10-22 14:16 ` Konstantin Khorenko
2026-10-27 14:06 ` David Hildenbrand (Arm)
2026-10-27 13:53 ` Kiryl Shutsemau
2026-10-27 14:06 ` David Hildenbrand (Arm)
2026-10-21 20:36 ` [PATCH v4 2/4] mm/huge_memory: copy file THPs at fork like copy_present_ptes() does Konstantin Khorenko
2026-10-27 14:08 ` Kiryl Shutsemau
2026-10-27 14:39 ` David Hildenbrand (Arm)
2026-11-04 11:40 ` Konstantin Khorenko [this message]
2026-10-21 20:36 ` [PATCH v4 3/4] mm/huge_memory: read a special PMD under the lock in copy_huge_pmd() Konstantin Khorenko
2026-10-27 14:24 ` Kiryl Shutsemau
2026-10-27 14:42 ` David Hildenbrand (Arm)
2026-10-21 20:36 ` [PATCH v4 4/4] selftests/mm: test fork of PMD-mapped shmem THPs Konstantin Khorenko
2026-10-27 14:51 ` Kiryl Shutsemau
2026-11-04 12:01 ` Konstantin Khorenko
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=dd966816-a83d-47ea-8faf-bf80d3b2642e@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljs@kernel.org \
--cc=loic.molinari@collabora.com \
--cc=maddy@linux.ibm.com \
--cc=nico.pache@linux.dev \
--cc=peterx@redhat.com \
--cc=ritesh.list@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=usama.arif@linux.dev \
--cc=ziy@nvidia.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