From: sashiko-bot@kernel.org
To: "Nico Pache (Red Hat)" <nico.pache@linux.dev>, linux-mm@kvack.org
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>, "Zi Yan" <ziy@nvidia.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
"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>, "Yu Zhao" <yuzhao@google.com>,
"Xu Xin" <xu.xin@linux.dev>,
"Chengming Zhou" <chengming.zhou@linux.dev>,
"Matthew Brost" <matthew.brost@intel.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Byungchul Park" <byungchul@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Ying Huang" <ying.huang@linux.alibaba.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Usama Arif" <usamaarif642@gmail.com>,
aarcange@redhat.com
Subject: Re: [PATCH v4] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits
Date: Sat, 05 Dec 2026 17:52:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-251782@kernel.org> (raw)
In-Reply-To: <20261204-b4-ksm_fixv2-v4-1-c5053d804e00@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm: reverse check order in try_to_map_unused_to_zeropage() per
v3 review
--
commit a53defdb23ee83f9b6a62a1f77e077bb1dd6d7de
Author: Nico Pache (Red Hat) <nico.pache@linux.dev>
mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits
This commit adds current_is_ksmd() and uses it in
try_to_map_unused_to_zeropage() to skip remapping zero-filled subpages to
the shared zeropage during ksmd-triggered THP splits, while still allowing
it during reclaim in ksmd's context.
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 7841968dd1f52..29cbb8aecc013 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -305,6 +305,14 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
> if (PageCompound(page) || PageHWPoison(page))
> return false;
>
> + /*
> + * When a split is triggered by KSM, let KSM take care of scanning for
> + * and deduplicating the shared zeropage. Reclaim in the ksmd context
> + * should still be able to reclaim zero-filled pages.
> + */
> + if (unlikely(current_is_ksmd() && !current->reclaim_state))
> + return false;
[Severity: Low]
As reported by David Hildenbrand (Arm) on v3 [1], should the checks be
reversed to test !current->reclaim_state before current_is_ksmd()?
On reclaim-triggered THP splits such as deferred_split_scan() via
shrink_slab(), current->reclaim_state is non-NULL. Checking
!current->reclaim_state first short-circuits on a single load from current
and avoids calling out-of-line current_is_ksmd() and kthread_func() on
every subpage.
Inlining current_is_ksmd() in a core-mm header such as mm/internal.h was
also suggested on v3 to drop the extra call layer when
!current->reclaim_state is true.
[1] https://lore.kernel.org/r/27c7a176-cd38-4e2c-b2e6-ad63b79ffc07@kernel.org
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-b4-ksm_fixv2-v4-1-c5053d804e00@linux.dev?part=1
prev parent reply other threads:[~2026-12-05 17:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 2:57 [PATCH v4] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits Nico Pache (Red Hat)
2026-12-05 17:46 ` David Hildenbrand (Arm)
2026-12-05 17:50 ` David Hildenbrand
2026-12-05 17:52 ` sashiko-bot [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=sashiko-outbox-251782@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=byungchul@sk.com \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=nico.pache@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.arif@linux.dev \
--cc=usamaarif642@gmail.com \
--cc=xu.xin@linux.dev \
--cc=ying.huang@linux.alibaba.com \
--cc=yuzhao@google.com \
--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