mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karl Mehltretter <kmehltretter@gmail.com>
To: "Xu Xin (vivo)" <xu.xin@linux.dev>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	Donet Tom <donettom@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 1/3] mm/ksm: do not inherit ksm_zero_pages counter or PTE markers on fork
Date: Sat, 21 Nov 2026 16:37:51 +0100	[thread overview]
Message-ID: <20261121153751.90695-1-kmehltretter@gmail.com> (raw)
In-Reply-To: <20261120074359.41019-1-xu.xin@linux.dev>

On Fri, 20 Nov 2026 15:43:59 +0800, Xu Xin (vivo) wrote:
> With the marker cleared, ksm_might_unmap_zero_page() will not
> decrement the counters on child exit, MADV_UNMERGEABLE in the child
> will not unnecessarily unshare inherited zero pages, and the global
> counter remains untouched.

Confirmed on mm-everything 758802f13004 with the smart-scan v4 series.
A test merged 1024 zero pages with use_zero_pages=1 and forked. Without
this patch, the child started with ksm_zero_pages=1024, the global
counter doubled, and MADV_UNMERGEABLE in the child allocated new pages.
With it, none of this happens.

The new check from 3/3 fails without this patch and passes with it, at
the default ksmd settings. Both tests gave the same results on x86-64,
i386, arm64, arm, riscv64, s390x, ppc64le, ppc64, ppc32, mips64el,
mipsel, sparc64, alpha, parisc, m68k and sh4 in QEMU.

Tested-by: Karl Mehltretter <kmehltretter@gmail.com>

Thanks,
Karl

  parent reply	other threads:[~2026-11-21 15:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  7:42 [PATCH v2 0/3] mm/ksm: fix ksm_zero_pages accounting " Xu Xin (vivo)
2026-11-20  7:43 ` [PATCH v2 1/3] mm/ksm: do not inherit ksm_zero_pages counter or PTE markers " Xu Xin (vivo)
2026-11-21 12:58   ` David Hildenbrand (Arm)
2026-11-21 15:37   ` Karl Mehltretter [this message]
2026-11-20  7:44 ` [PATCH v2 2/3] selftests/mm: fix false-positive KSM fork test by dropping init_global_file_handles() Xu Xin (vivo)
2026-11-20  7:44 ` [PATCH v2 3/3] selftests/mm: verify ksm_zero_pages is not inherited on fork Xu Xin (vivo)

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=20261121153751.90695-1-kmehltretter@gmail.com \
    --to=kmehltretter@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=david@kernel.org \
    --cc=donettom@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stable@vger.kernel.org \
    --cc=xu.xin@linux.dev \
    /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®