From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E56A3FFFB5 for ; Tue, 9 Jun 2026 11:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781005558; cv=none; b=vFBujVBmU/aTSTXMbS425AzCxFW4Rx21rbg4ZFTn1UwvkxUmThfzwkd2S3AVtHRIyOhSmuCn7Vgn1BQUCEXJmkH54/OYHp19j7lZckwgQzTPlX8JlQAmYr+kJaug5JliVjktnfazVnrROvZI9dlYJr/IMhrj7bibpVPbJD1yzmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781005558; c=relaxed/simple; bh=NtnXLXCCsYZRFV69kd2YAfaWeV+Z6uuKxZtxX8dUqZ0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ho40cPRxBs6b3envbgXlTHyLaaQRuK5q+Fkv0/BIFECW1+9TnDy+romf1QjZasy7ICpn9lXr0W0On2BfpKEbG6Qlo+1eHGzdyN+k2FGxbB8FRC+gMerkds+MYb+m6u6FR31eI/B2qm818mEAC5+iqTdexn2WI/jtBsNE4ZjcwJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SN9CPREA; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SN9CPREA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781005556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ysr2Lr9gLOb2elxHpNEW7Abno5MCuUNT7Ueh/hUfyEc=; b=SN9CPREAdpBVaCgXZ+/zbJbWQ3Z4TIAj9PpghivryTWZ2VSgfbORwZXScMXe+jyVyDx4HB KoQnpjniu9yg+ELK5OZACw/mnwSBTEx71HKkGKB15/+E+DLALOT6VN75Z/Cw4vfuBkGdyQ UAMAgcxgDtNI9NqZOt5lCa1VhChURP8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-zd-4kSrpPcW3WWUP4yqqOQ-1; Tue, 09 Jun 2026 07:45:51 -0400 X-MC-Unique: zd-4kSrpPcW3WWUP4yqqOQ-1 X-Mimecast-MFC-AGG-ID: zd-4kSrpPcW3WWUP4yqqOQ_1781005548 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D330A195DE13; Tue, 9 Jun 2026 11:45:46 +0000 (UTC) Received: from p1.redhat.com (unknown [10.44.22.33]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 35CB11955DC9; Tue, 9 Jun 2026 11:45:36 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Usama Arif , Yu Zhao Cc: aarcange@redhat.com, Nico Pache , Andrew Morton , David Hildenbrand , Xu Xin , Chengming Zhou , Lorenzo Stoakes , Zi Yan , Baolin Wang , "Liam R. Howlett" , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple Subject: [PATCH mm-unstable v1 0/3] MM: Tighten control over zero-page remapping Date: Tue, 9 Jun 2026 05:46:12 -0600 Message-ID: <20260609114619.144416-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 This patch series fixes a bug in KSM where the pages_to_scan limit is bypassed and the policy (use_zero_pages) is ignored. It also gives users further control of the zero-page remapping that occurs when a folio is split. Commit b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp") added unconditional zero-page remapping when a folio is split. This was sold as part of the underutilized shrinker, but has a larger effect. Since this commit, all splits do this zero-page scanning and remapping, even if the user has the underutilized shrinker disabled. This unconditional zero-page remapping was also problematic for KSM, as when KSM would try to merge a page, it would split the folio and the zero-page remapping would remap all zero-filled pages to the shared zero-page bypassing the use_zero_pages policy. When the user had this feature disabled, KSM would then waste cycles scanning these already freed pages, causing little progress to be made, and KSMs performance to degrade. In this series we also gate the zero-page remapping behind split_underused_thp (the sysfs for the underutilized shrinker). This provides users with more control over this behavior, while also preventing the KSM bug when it is enabled. RFC: https://lore.kernel.org/all/20260508170509.640851-1-npache@redhat.com/ Nico Pache (3): mm/ksm: export ksm_is_running() to check KSM merge state mm/migrate.c: Prevent folio splitting from interacting with KSM mm/huge_memory.c: Skip zero-page remapping when underused THP shrinker is disabled include/linux/ksm.h | 6 ++++++ mm/huge_memory.c | 2 +- mm/ksm.c | 6 ++++++ mm/migrate.c | 9 +++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) base-commit: be18cf77e1e749c6469ff44df00eb026f7c0a365 -- 2.54.0