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 92676217F2E for ; Thu, 12 Feb 2026 02:18:56 +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=1770862737; cv=none; b=eoazF1psWM6QBajtFGZmi4ckmt4QUnDoUkZnVng/xfdJ8Op95jPw4oO68P6OD/evNyE3jWfJnuRHsLz5qUttMl/wi3RpNRpari3nmKh+r5dxgD7xQ5g+0Rq4zCudiKZjOKzrNL1dx8/8S0qFhPM48TzyMeKWtpnDTmp3CVUVmtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770862737; c=relaxed/simple; bh=EBisGYPdVRRkNn1mzkyDYM/otWEwR6qgww2dlxbxgiY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gjm4i8DkAUQwQy7Yiq+LkOsrI0+yMaHyqY69/sBNc7HBE0e9V8uWRVXCA4Ovg7BhFom/LvXGXOPAzx5nxaL65U6h0yyRjJWG7a+zMfncS6jmQl2iA6/BA6ydMnEqMGLsAq5YcSz4e7dgFJC7MCJXc9zkf6QQOVkY1Fiq6xaLU3M= 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=GvKrZiQr; 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="GvKrZiQr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770862735; 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=7ZyboKdgs42pmLBAilt8Nx8nDtol8v/v25+THvNzqFM=; b=GvKrZiQrUBIZuEEC6TR4BMpUNF5v8yUWVLSiojogZSlKxZoqlY13vDM9/ZV9uMJxe5znWq Qb5CKIHxr7JkmjROH27hVQIdcTmnv8FGHL9xczHwjAKHANQMoHy09Tz7o2MvLASdimdQks l91vJsyEJO6/Y0YulWdedE1uYV+jZrs= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-IcE7HbWyNjOtgfMs97Qymw-1; Wed, 11 Feb 2026 21:18:52 -0500 X-MC-Unique: IcE7HbWyNjOtgfMs97Qymw-1 X-Mimecast-MFC-AGG-ID: IcE7HbWyNjOtgfMs97Qymw_1770862731 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50F931800366; Thu, 12 Feb 2026 02:18:51 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.91]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 87F011956053; Thu, 12 Feb 2026 02:18:37 +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 v1 0/5] mm: khugepaged cleanups and mTHP prerequisites Date: Wed, 11 Feb 2026 19:18:30 -0700 Message-ID: <20260212021835.17755-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 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: rename hpage_collapse to 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 V1 Changes (for patches coming from [1]): - Refactor do_anonymous_page() and add helpers for use in mthp series - moved is_pmd_order patch to this series [2] - added a define for HPAGE_PMD_NR - 1 - moved rename to this series [3] - Dropped acks/review-by on PATCH 5 given [4] - moved unification patch to this series [4]. I also had to make some modifications from my previous version which include moving the new madvise_collapse writeback retry logic into the collapse_single_pmd function. This prevents a potential UAF bug I introduced in my v14 when handling the conflict. [5][6] A big thanks to everyone that has reviewed, tested, and participated in the development process. Its been a great experience working with all of you on this endeavour. [1] - https://lore.kernel.org/all/20260122192841.128719-1-npache@redhat.com/ [2] - https://lore.kernel.org/all/20260122192841.128719-2-npache@redhat.com/ [3] - https://lore.kernel.org/all/20260122192841.128719-3-npache@redhat.com/ [4] - https://lore.kernel.org/all/20260122192841.128719-4-npache@redhat.com/ [5] - https://lore.kernel.org/all/65dcf7ab-1299-411f-9cbc-438ae72ff757@linux.dev/ [6] - https://lore.kernel.org/all/b824f131-3e51-422c-9e98-044b0a2928a6@redhat.com/ Nico Pache (5): mm: consolidate anonymous folio PTE mapping into helpers mm: introduce is_pmd_order helper mm/khugepaged: define COLLAPSE_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 | 194 +++++++++++++++++++++------------------- mm/memory.c | 56 ++++++++---- mm/mempolicy.c | 2 +- mm/mremap.c | 2 +- mm/page_alloc.c | 2 +- 8 files changed, 152 insertions(+), 115 deletions(-) -- 2.53.0