From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794023623; b=K3EhMVUgcBDb2mxOZVP4UuUAuIeqD56FfQ410lFwv7Oz/QimzGkEDSWJdsHizlDEzT+D BHO5r6DljpCz6rNjeCOa59hCE/qY/1TQz3HZX0RM6+3p5HKq7xCnLGPWwsSQDjSHbHz0b j1XPJGTrp8Uq1iQPMbk9XTVlB4vpTr6HkfYN8wcmGTOKLorYpE1yXIyPUyFdOFuNLrAxA lso8lZVTa1z4NgDt40G2hs2+kyMGvLemqDIcjIDmv5HBfntnhBeeXEk6yVGv34d9aMNfY Fl+LFpdpQNrhrCKdEir4olVvysARddlkQxlQlm8HFggvyZYq7ISb17SKA3vn9a9JT1g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794023623; h=Received:DKIM-Signature:Date:To:From:Subject:Message-Id; bh=SmL6VgxMithCD/GGAtzvYTS8MsIGGzH2gcifu9Cp42o=; b=vNBmaR8qP8/D66gzLRIQtQhh/byFDDhJRkW1HIiJyES4m6s2v1UBryy4cE1n2Tc3/7v4 iSCuqvU4gb9kEbB/JSC7SaHckgHjChPwWfyoF3yzxuK/tQ8tc0A5ZQF9C0WNfdZq3eWV3 2tUWFxvUdUc5acrRImz4IAEB0yAZFUTIoxL/R91xTstyQG+3vjYlQw15Q0rs1+kWpipAr kW84Kt3W7//wKbu7BR54jyCTS6B59CJ+7TUjYO3L9OI/An7o9JHo6mxh9kdBQde0kkbJt dOpmpl4LzuLUXlXaFteiLv4Mp5/cXgo4wbusP2HiirGj4P55LigEszskzDLfkoB55OA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=N1YYwV+z; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76BF9606A32E for ; Sat, 7 Nov 2026 03:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=N1YYwV+z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41E631F0089F; Sat, 7 Nov 2026 03:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1794023623; bh=SmL6VgxMithCD/GGAtzvYTS8MsIGGzH2gcifu9Cp42o=; h=Date:To:From:Subject; b=N1YYwV+zq0ofw6lMRL9hmFfzBupy6K8RC7vs4AWUUp4rHL7CLNHnemLV5fXcKMhdN QBdTg6nB8+izRrQSfnjr9+6JegFfKtnxqLMSQkQkfPu3eoHbpzy0GgG4tpsXqAOuxY ssXYQQ/VnIgQ5CSAjhKcY6Tp1w0nV40e54GfFlyQ= Date: Fri, 06 Nov 2026 19:53:42 -0800 To: mm-commits@vger.kernel.org,muchun.song@linux.dev,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-hugetlb_vmemmap-unify-writable-vmemmap-page-preparation.patch added to mm-unstable branch Message-Id: <20261107035343.41E631F0089F@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm: hugetlb_vmemmap: unify writable vmemmap page preparation has been added to the -mm mm-unstable branch. Its filename is mm-hugetlb_vmemmap-unify-writable-vmemmap-page-preparation.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb_vmemmap-unify-writable-vmemmap-page-preparation.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Muchun Song Subject: mm: hugetlb_vmemmap: unify writable vmemmap page preparation Date: Sat, 07 Nov 2026 10:27:49 +0800 Installing a writable vmemmap page requires consuming a replacement page, copying the current contents into it and making the copy visible before publishing the new mapping. HVO currently splits this sequence between the page-table walker and its caller depending on the remap path. Centralize the sequence in the walker so all writable replacements follow the same copy-and-publish protocol. This keeps page preparation with the mapping update and removes path-specific handling from higher-level HVO code. No functional change intended. Link: https://lore.kernel.org/20261107022756.77731-7-songmuchun@bytedance.com Signed-off-by: Muchun Song Signed-off-by: Andrew Morton Reviewed-by: Lance Yang Reviewed-by: Qi Zheng Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Oscar Salvador Tested-by: Andrew Morton Cc: James Houghton Cc: David Hildenbrand Cc: Yili Zhang Cc: Kiryl Shutsemau Cc: "Oscar Salvador (SUSE)" Cc: Huacai Chen --- mm/hugetlb_vmemmap.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) --- a/mm/hugetlb_vmemmap.c~mm-hugetlb_vmemmap-unify-writable-vmemmap-page-preparation +++ a/mm/hugetlb_vmemmap.c @@ -199,6 +199,20 @@ static void free_vmemmap_page_list(struc free_vmemmap_page(page); } +static struct page *vmemmap_dup_page_from_list(const struct page *src, + struct list_head *vmemmap_pages) +{ + struct page *dst = list_first_entry(vmemmap_pages, struct page, lru); + + list_del(&dst->lru); + copy_page(page_address(dst), page_address(src)); + + /* Ensure updates to @dst page are visible before set_pte_at(). */ + smp_wmb(); + + return dst; +} + static void vmemmap_remap_pte(pte_t *pte, unsigned long addr, struct vmemmap_remap_walk *walk) { @@ -211,16 +225,7 @@ static void vmemmap_remap_pte(pte_t *pte VM_WARN_ON_ONCE(!PageHead((const struct page *)addr)); - head = list_first_entry(walk->vmemmap_pages, struct page, lru); - list_del(&head->lru); - - /* - * Makes sure that preceding stores to the page contents from - * vmemmap_remap_free() become visible before the set_pte_at() - * write. - */ - smp_wmb(); - + head = vmemmap_dup_page_from_list(page, walk->vmemmap_pages); entry = mk_pte(head, PAGE_KERNEL); } else { VM_WARN_ON_ONCE(!PageTail((const struct page *)addr)); @@ -253,15 +258,7 @@ static void vmemmap_restore_pte(pte_t *p VM_WARN_ON_ONCE(PageHead((const struct page *)addr)); - dst = list_first_entry(walk->vmemmap_pages, struct page, lru); - list_del(&dst->lru); - copy_page(page_to_virt(dst), page_to_virt(src)); - - /* - * Makes sure that preceding stores to the page contents become visible - * before the set_pte_at() write. - */ - smp_wmb(); + dst = vmemmap_dup_page_from_list(src, walk->vmemmap_pages); set_pte_at(&init_mm, addr, pte, mk_pte(dst, PAGE_KERNEL)); } @@ -501,7 +498,7 @@ static int __hugetlb_vmemmap_optimize_fo unsigned long flags) { unsigned long vmemmap_start, vmemmap_end; - struct page *vmemmap_head, *vmemmap_tail; + struct page *vmemmap_tail; gfp_t gfp_mask = GFP_KERNEL | __GFP_NOWARN; int nid, ret = 0; @@ -534,9 +531,6 @@ static int __hugetlb_vmemmap_optimize_fo if (ret) goto out; - vmemmap_head = list_first_entry(vmemmap_pages, struct page, lru); - copy_page(page_to_virt(vmemmap_head), folio); - vmemmap_start = (unsigned long)&folio->page; vmemmap_end = vmemmap_start + hugetlb_vmemmap_size(h); _ Patches currently in -mm which might be from muchun.song@linux.dev are mm-fix-missing-page-table-destructor-in-pagetable_free.patch riscv-mm-fix-hotplug-page-table-destructor-handling.patch riscv-mm-fix-missing-destructor-for-hotplug-pud-tables.patch arm64-mm-fix-destructor-for-unconstructed-hotplug-page-tables.patch mm-sparse-vmemmap-map-shared-vmemmap-tail-pages-as-read-only.patch powerpc-mm-map-shared-vmemmap-tail-pages-as-read-only.patch mm-hugetlb_vmemmap-remove-vmemmap_wrprotect_hvo.patch mm-hugetlb_vmemmap-remove-hugetlb_vmemmap_optimize_bootmem_folios.patch mm-generalize-kernel-pte-table-allocation.patch mm-generalize-pmd-page-table-allocation.patch mm-generalize-pud-page-table-allocation.patch mm-remove-pagetable_dtor_free.patch mm-remove-redundant-pagetable_dtor-calls.patch mm-hugetlb_vmemmap-remove-hugetlb-specific-vmemmap-optimization-macros.patch mm-hugetlb_vmemmap-unify-vmemmap_splitremap_no_tlb_flush.patch mm-hugetlb_vmemmap-simplify-vmemmap-head-page-handling.patch mm-hugetlb_vmemmap-generalize-vmemmap-page-allocation.patch mm-hugetlb_vmemmap-unify-writable-vmemmap-page-preparation.patch mm-hugetlb_vmemmap-rename-vmemmap_remap_pte-to-vmemmap_optimize_pte.patch mm-hugetlb_vmemmap-simplify-shared-tail-page-handling.patch mm-hugetlb_vmemmap-move-alloc_vmemmap_page_list-next-to-its-free-helper.patch mm-hugetlb_vmemmap-make-vmemmap-optimization-folio-oriented.patch mm-hugetlb_vmemmap-make-vmemmap-restoration-folio-oriented.patch mm-hugetlb_vmemmap-unify-vmemmap-range-restoration.patch mm-hugetlb_vmemmap-make-vmemmap-pte-conversion-folio-oriented.patch mm-hugetlb-fix-validation-of-unsupported-hugetlb-orders.patch