Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796544824; b=ML8fwX6H9QxJ0LYbc78Bp9lVkdFEKm/7/gvBgUefDNz2Ua08q/KWP9eZ4qWpKxOgevvW p6S6ZrIdiyr4IsShyTWolFjsFMo3qPjLDeEaI4JaZfGJpBQl94nYr3jcWHZ3QLf+vYfEc arXehB9CbWz4DHPexWeQB+0vY20zdvag9bdDhFVy6AWS58kA596tw09jIhJmgSihBn0LB /cCjuf35Q/WHgqi4SuD4xMOj6MYzQqIVYg/3jPY8hEbQTCcAMhFLsVBB56FqppT1FG2Lj VGTOzlWdSRALZkIdCOGQ1Yy4Fknmg63APZP+p/6KAY3x3b1Joe4DlQcvbfNMiIaWhfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796544824; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=u/MA1kEpE+iTs7Wh7lTRY5bUJB1+TXVWeeraUkcqtPY=; b=48mcQYlHofJFwH8Y7zInuBNZe+baqSZje/2f3L1CULSz1+MCkvYClIlkD2PcTouC4h26 jAEBLWBp5SwCSh5nSbJGd67jfV65AVl/gG7fv9SrHR2JgMrv+I72nx6UnDtuMwq7rWL8B JgeqcKfUGhWZrS7gpHQsWDRn2Jc7xIOdDTi1qM/eBZezS1Yuvza0NBF+vbYJbm04l50Ec 4YFYunw8x7neW7sRX6j+B5HrkPgZnvcrSI1dg+S/j3X8bOkvxH8c8X+wXLiTky+O0xUvV E3vmnujGTiLFOKL0ZJR9zQ7CbDdssCzHtKAFXbyfx/eJUAM7uR+m7SPOw5V5MgjlbNg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Zf3zTkuV; arc=none smtp.remote-ip=209.85.214.179 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 668AC606A31F for ; Sun, 6 Dec 2026 08:13:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 668AC606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Zf3zTkuV Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2f03eeda984so13535845ad.2 for ; Sun, 06 Dec 2026 00:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1796544823; x=1797149623; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=u/MA1kEpE+iTs7Wh7lTRY5bUJB1+TXVWeeraUkcqtPY=; b=Zf3zTkuVTk4dt3Dm6bYOfKnhoO0B8JTZpGjW5hO4ksXVVzlNwqC2bvZcIj9WERbrGp bRZe/mrzoKRV373wpJqX40t8LVcD1kFDyDRwAw8LG67k/HN5OcIdjSDOXbQ1B3aR7wC9 PcS3V9xQo4R4NwteGSRywF1MqX7DGOXrig/M+xSa3yT4kxEG2EOqxGwKKbks3+DC7pbA pIeQO7I/azafSs6KNGELK66hXeu2yJyQJvavMbFVmIJuY3gl2EY28N7mSd6YVFi6gRqc +SyEYD0XLb/6V6RiPuZknQvw6rUZkyYzn+nFVybvk2oPS3bGx1vEO6zKm1e7evAD4reR qETg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796544823; x=1797149623; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u/MA1kEpE+iTs7Wh7lTRY5bUJB1+TXVWeeraUkcqtPY=; b=0Xm863fp2QtcY/rJUooC0mzsKIepDABAXUVQMf44NP12tMxGD0y4kMJBXjWDZAm+0m 0LvR7mvsV1dAEfMz+4us9TbCCtZRGZABFJrciwVZrzMeVm0ess6BdMC2r7NqTaTFqh4q +ZMusuKpzeHa58FbMypwO/t4UugTd178Co2KLpXY2Ojej/5cHe2mJYdra+2mNSZ+LHHl W7jSWqp353Dz4zuhiiGzbJfQneb+qZA4ny2EgwWy3lbTIcvI/BWRVWfllC2RRZu9h3Y2 gY8fjmNZaNNiMGRXPPxH1lgeCAK3eSMF7Nsg6elWrG9l1V7Lb8/YY6uCVjd51+zsPV2V m99A== X-Forwarded-Encrypted: i=1; AL+hErEbEIGodzUvu0CWTum7uhg7jultEhyr+e1o7syrMToaQIz29uBuz8XYQX7xTSqgjR7+O76x/oET8KA=@lists.linux.dev X-Gm-Message-State: AB4q+uFYM/o5UNjZ2FYtf1lUKgi83RJSuQCAc5l4ed3667dpwexfMu6J x5Dc5kprRLfUaIOsRc1G3hzbmzhY6OzH8Aljke4AuelDYSXOZPUd6Fs+3jOqisNUb50= X-Gm-Gg: AZFdTZdH2rZuVLH/q99ZDfSm6uh68jJbr1br9/2ZmhEPaoYngQWr4feOVVmAc224WaC W2D0OWKLhhVhd7YkCtYxQwG8kUFmNUbXHAmrJnH71Hj2/365zzPbSt6zVhrJ/CTdRJ2rYcEoHj8 LvvIAw3h5brAqN1CYHOVdC24lA0/Vy3e2LSs/Cq+2AXc7NQUEU/LnA2kd7ZVrC+kw2bD2Ao6WQJ ZgfbndsWZavFhX73Ua1/4qYypXC6V87JWze0pYQ1wI9mYymZ9NULox0quV6e/UyipTD9uqGPi4H NT+HT/hEFLKSW8hFxh3dDcevDhQVtpZrKNFmi77wlBokhTGjxDoa9UxpW9ZQ101RmLf1yPuc3EH w+STPpcigto71N3nsTTXmwUnZ53nuWh152eqbD2fCFIfkaTS1N/qXbUZpNwdjAzjR1YT5cwx2Hv tcnr5ZOqvVXnkQAklwynbfmpjtVAaAwiYH4SFk/GeYLS8qDwkr/gmh2p/J9ziUGqvQK8XIx/7rj F4aTlFem4QGbIU8rGU9493iLuBxcQi/NSFoC6tABTtn4nwY4+4JReTJvtWYnuuACybWAkBNZ4sS nBMn7Ae+l8neSQTTIr9fgWYLRusa6p/8bRKVBddTztYEp+Stsu8Yo1em X-Received: by 2002:a17:902:f54c:b0:2ed:1ef3:9ec with SMTP id d9443c01a7336-2f1ba1483b8mr72562535ad.14.1796544822557; Sun, 06 Dec 2026 00:13:42 -0800 (PST) Received: from G6L4RL2QG9 ([2409:8a00:1832:6900:b956:4650:9531:d810]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f1b791d29dsm33968655ad.37.2026.12.06.00.13.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 06 Dec 2026 00:13:41 -0800 (PST) From: Muchun Song To: Oscar Salvador , David Hildenbrand , Mike Rapoport , Andrew Morton Cc: Muchun Song , "Liam R . Howlett" , Vlastimil Babka , Michal Hocko , Miaohe Lin , Naoya Horiguchi , Lance Yang , Qi Zheng , linux-mm@kvack.org, loongarch@lists.linux.dev, Huacai Chen , Muchun Song Subject: [PATCH v2 0/3] mm: Track vmemmap optimization state in shared backing pages Date: Sun, 6 Dec 2026 16:13:21 +0800 Message-ID: <20261206081324.8274-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Folio-based vmemmap optimization currently requires HugeTLB to maintain HPG_vmemmap_optimized separately from the vmemmap mapping. The runtime update is counterintuitive: when TLB flushing is deferred, the flag must be set before remapping so that it is copied to the replacement head page, then cleared if optimization fails. Boot-time HugeTLB setup also needs an explicit transfer from section metadata into the flag. The same representation is useful to future shared-vmemmap users [1]. The FS-DAX prototype currently determines whether a metadata page still uses shared backing by looking up its vmemmap PTE and comparing the mapped backing page with the shared template. A future revision can instead test the common flag directly through the vmemmap address, avoiding page-table identity as the state representation for shared metadata. Reuse PG_owner_priv_1 in the first struct page slot of each shared backing page, and provide folio_vmemmap_optimized() as the common query. Patch 1 moves MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h, which lets vmemmap-optimization.h include linux/mm.h. Patch 2 introduces the generic state representation and query. Patch 3 switches HugeTLB to it and removes the private flag and its explicit state updates. [1] https://lore.kernel.org/20260903122128.12264-4-songmuchun@bytedance.com/ [2] https://lore.kernel.org/20261205121205.83068-1-songmuchun@bytedance.com/ v2: - Patch 1 is new. It moves MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h and drops the LoongArch include of vmemmap-optimization.h, fixing the circular include that broke the LoongArch build (reported by sashiko-bot and kernel test robot) - Patch 2: Move PG_vmemmap_optimized to PG_owner_priv_1, since PG_owner_2 aliases PG_anon_exclusive on THP tail pages (reported by sashiko-bot) - Patch 2: Document that folio_vmemmap_optimized() returns true only after the TLB flush has completed (suggested by sashiko-bot) - Patch 3: No change. The race between folio_vmemmap_optimized() and vmemmap_restore_folio() reported by sashiko-bot is fixed by [2]. v1: https://lore.kernel.org/20261204065009.1392156-1-songmuchun@bytedance.com/ Muchun Song (3): mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h mm/vmemmap-optimization: track optimization state in shared vmemmap pages mm/hugetlb_vmemmap: remove HPG_vmemmap_optimized arch/loongarch/include/asm/pgtable.h | 1 - include/linux/hugetlb.h | 3 -- include/linux/mmzone.h | 2 ++ include/linux/page-flags.h | 6 ++++ include/linux/vmemmap-optimization.h | 21 +++++++------ mm/hugetlb.c | 15 ++++----- mm/hugetlb_vmemmap.c | 47 ++++++---------------------- mm/memory-failure.c | 4 +-- mm/sparse-vmemmap.c | 1 + 9 files changed, 38 insertions(+), 62 deletions(-) base-commit: 6855c02e7d65a8539dc3f8a24946c1ff9bd81361 -- 2.54.0