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.133.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 15885175A73 for ; Wed, 11 Mar 2026 21:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773263730; cv=none; b=fsyim+fcvbK0YeoB4yVP8YSZA5awwtSKDmg9QHE01kqEd+HyTtNmtbmg9jIs2X59QoH6cEY9Bo8qbe/XvLXZkrEknBrM8WukEf/o3icMIx/pOO5rn7JZbnC8Rye+ja27/yLvevioA0zp8RqPie0cYAbVx+r9Ka0t2hpLC7lIE+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773263730; c=relaxed/simple; bh=epW2phhRZK/4wQvx607PvweAgaAHiYJDW6b+PgATzPk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VPkgh7GBQ3LeCtOjOfiiVFztyRzFiZRuranF+SlytV25XDNFSXWyrCVPG5HJpHBY9JxT3CSBgdQZQSDP0jawaqewJ7tmX4hTil9wSYKl6yo3hBFIRhR1lsNzfzz5mz7qr5eDObezkGDbJ1tp6DWjbV/ktUruOJ1bT3WlM4cVc8Y= 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=M/TR2TFy; arc=none smtp.client-ip=170.10.133.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="M/TR2TFy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773263728; 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=yOEFOtNoyJvnv+ypQm62swZPdPqWAjqNcltCueE8x/w=; b=M/TR2TFyITemWlCNbdNa4Cwu/c9bUxC9MRWh5qKTzQVmXBjhMZAVhl+3ivLLQWOHAa5NtJ 8tUkTH5aV3e30zTmbS6YW+aBDRhofjXrF3IjIkOPY+I82vrqL/UDC2ZO60aH9bTibd9m1c xvQZfCZ6xEFEF7BoWim5lub2wl2iVWU= Received: from mx-prod-mc-03.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-622-qYN_Au1hN96BEAevcyodJQ-1; Wed, 11 Mar 2026 17:15:25 -0400 X-MC-Unique: qYN_Au1hN96BEAevcyodJQ-1 X-Mimecast-MFC-AGG-ID: qYN_Au1hN96BEAevcyodJQ_1773263724 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCF0F1956050; Wed, 11 Mar 2026 21:15:23 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.89.69]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B9DE230002D2; Wed, 11 Mar 2026 21:15:08 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: aarcange@redhat.com, akpm@linux-foundation.org, anshuman.khandual@arm.com, apopple@nvidia.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, byungchul@sk.com, catalin.marinas@arm.com, cl@gentwo.org, corbet@lwn.net, dave.hansen@linux.intel.com, david@kernel.org, dev.jain@arm.com, gourry@gourry.net, hannes@cmpxchg.org, hughd@google.com, jackmanb@google.com, jack@suse.cz, jannh@google.com, jglisse@google.com, joshua.hahnjy@gmail.com, kas@kernel.org, lance.yang@linux.dev, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, mathieu.desnoyers@efficios.com, matthew.brost@intel.com, mhiramat@kernel.org, mhocko@suse.com, npache@redhat.com, peterx@redhat.com, pfalcato@suse.de, rakie.kim@sk.com, raquini@redhat.com, rdunlap@infradead.org, richard.weiyang@gmail.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, ryan.roberts@arm.com, shivankg@amd.com, sunnanyong@huawei.com, surenb@google.com, thomas.hellstrom@linux.intel.com, tiwai@suse.de, usamaarif642@gmail.com, vbabka@suse.cz, vishal.moola@gmail.com, wangkefeng.wang@huawei.com, will@kernel.org, willy@infradead.org, yang@os.amperecomputing.com, ying.huang@linux.alibaba.com, ziy@nvidia.com, zokeefe@google.com Subject: [PATCH mm-unstable v3 0/5] mm: khugepaged cleanups and mTHP prerequisites Date: Wed, 11 Mar 2026 15:13:10 -0600 Message-ID: <20260311211315.450947-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.4.1 on 10.30.177.4 The following series contains cleanups and prerequisites for my work on khugepaged mTHP support [1]. These have been separated out to ease review. The first patch in the series refactors the page fault folio to pte mapping and follows a similar convention as defined by map_anon_folio_pmd_(no)pf(). This not only cleans up the current implementation of do_anonymous_page(), but will allow for reuse later in the khugepaged mTHP implementation. The second patch adds a small is_pmd_order() helper to check if an order is the PMD order. This check is open-coded in a number of places. This patch aims to clean this up and will be used more in the khugepaged mTHP work. The third patch also adds a small DEFINE for (HPAGE_PMD_NR - 1) which is used often across the khugepaged code. The fourth and fifth patch come from the khugepaged mTHP patchset [1]. These two patches include the rename of function prefixes, and the unification of khugepaged and madvise_collapse via a new collapse_single_pmd function. Patch 1: refactor do_anonymous_page into map_anon_folio_pte_(no)pf Patch 2: add is_pmd_order helper Patch 3: Add define for (HPAGE_PMD_NR - 1) Patch 4: Refactor/rename hpage_collapse Patch 5: Refactoring to combine madvise_collapse and khugepaged Testing: - Built for x86_64, aarch64, ppc64le, and s390x - ran all arches on test suites provided by the kernel-tests project - selftests mm V3 Changes: - Patch1: leverage folio_order rather than passing nr_pages into map_anon_folio_pte_pf [2] - Patch 2: fixed conflict with is_pmd_order - Patch 3: Change COLLAPSE_MAX_PTES_LIMIT to KHUGEPAGED_MAX_PTES_LIMIT [3] - Patch 4: conflict resolution with other khugepaged patches - Patch 5: Drop lock_dropped unnecessary change, Dropped Lorenzos RB, !triggered_wb in if statement rather than triggered_wb, remove unnecessary mmap_locked flipping [4] V2 - https://lore.kernel.org/all/20260226012929.169479-1-npache@redhat.com/ V1 - https://lore.kernel.org/lkml/20260212021835.17755-1-npache@redhat.com/ A big thanks to everyone that has reviewed, tested, and participated in the development process. [1] - https://lore.kernel.org/all/20260122192841.128719-1-npache@redhat.com/ [2] - https://lore.kernel.org/all/7334b702-f6a0-4ccf-8ac6-8426a90d1846@kernel.org/ [3] - https://lore.kernel.org/all/25723c0f-c702-44ad-93e9-1056313680cd@kernel.org/ [4] - https://lore.kernel.org/all/81ff9caa-50f2-4951-8d82-2c8dcdf3db91@kernel.org/ Nico Pache (5): mm: consolidate anonymous folio PTE mapping into helpers mm: introduce is_pmd_order helper mm/khugepaged: define KHUGEPAGED_MAX_PTES_LIMIT as HPAGE_PMD_NR - 1 mm/khugepaged: rename hpage_collapse_* to collapse_* mm/khugepaged: unify khugepaged and madv_collapse with collapse_single_pmd() include/linux/huge_mm.h | 5 ++ include/linux/mm.h | 4 + mm/huge_memory.c | 2 +- mm/khugepaged.c | 187 +++++++++++++++++++++------------------- mm/memory.c | 62 ++++++++----- mm/mempolicy.c | 2 +- mm/mremap.c | 2 +- mm/page_alloc.c | 4 +- mm/shmem.c | 3 +- 9 files changed, 153 insertions(+), 118 deletions(-) -- 2.53.0