Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796544830; b=1ezRimxZThfp1OujZuD7ThSJR9J4Zx0vNvvh5AXQ+4r1elXZjLMeFEUnrdip14P1vWnS 5ZSo+S75Vabh8lnmY+2ImdsQUSKVhz2RF5MnNIEcySjVEwMHgx0tuHduhdFSswRFP0bmu E4jxvqTxQh47J0crI3FrEOQDULqEHUo0YQR56avuHx2vQQSt99IDmC7rOxL7P4MW+8Zpr 2d8mOQxG2Bcwr5TiAbQEuW9mZF37tgBu1tzFe3L9IfLODjS2YjJR5LjkcAJfj2BRHRZIl LNAkvpvH7QK/aioNeK2bSSaXaUQvzupDXqIYKZ+ieKyC649jHcwKJyQBbnsMdyayrTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796544830; 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:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=1MFB37Oxkvo5MNKBtFFDqQLzKnBboBsOSRyjTPT5gJQ=; b=fux5dWA7h5jAd5T05ReLQ7M8gJPtUo5qBWYOOICaZ/ayut+GuhSeXo1MD3/P1ix06DTY 4LkJp4EqVihEl/OiYV7+1G/OJRSkUxs3Ljr7+pVobh27VU4wmGiwe52aDibWlNr4gPtf1 njdxWDCH4OfX0EkfZLDj6aR04T1KKwqoOFKxtVe+93TfLJcBMwwOqQ90/fTrn32tm1ZXD N+LZg03Yr3QRYuhb63NY7RSiITGyd++LL0xSk6ayt+xo4H/6r3KO7pp6LxzuyRjzDLJko QAhhscuCUdjaM2Tz+xcu8ZG3XqmJhxHWnIGo+bVWxY3pkDplPJkEgNUYisgpHmyOmcw== 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=cEmTxm1k; arc=none smtp.remote-ip=209.85.214.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 DCDF1606A31F for ; Sun, 6 Dec 2026 08:13:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DCDF1606A31F 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) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=cEmTxm1k Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f0918f9e6cso9234185ad.1 for ; Sun, 06 Dec 2026 00:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1796544829; x=1797149629; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1MFB37Oxkvo5MNKBtFFDqQLzKnBboBsOSRyjTPT5gJQ=; b=cEmTxm1k3SDYYrAj0BZ05V+pB/ZdMca+J94Fy2/jMEm7YZZnMG06f0m7rEnQI1Klf7 clFsubdaE5cAZbdSFPAwBAFZ4Za6YfpsPrMvUlwqFM/0+T69il38LNNovgFLYPWYujcv ApRU5stP4rlAfQOFPeEyeIjTsLA/zTmEPmBSMcCV4vhmQjq1sFkysnDPBNhNqm5jhTwd zAhN94F4xwkz4X5BdkGxm5Ddnmh5FmmCk7G5TEm1x50XK6o7vMT4yZTsEnKJPTjDKiUr pikmGUbJcZZmQoe1pfXxObHzMDKWrhZDfu+9CKHL15/GlHwLj/9PrwQYUa1ZVyow67H+ vS1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796544829; x=1797149629; h=content-transfer-encoding:mime-version:references:in-reply-to :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=1MFB37Oxkvo5MNKBtFFDqQLzKnBboBsOSRyjTPT5gJQ=; b=k6UcuWLPCjz0UcfFRqgZcC1h1J7MQUYBD9p9pJXfZZqbYxIO4VnIRIpXB+PjzHTGZx D/yQjGClcZD6EFKelb/sHOpF6y8XvxDv6YgI/3uDNCwR1oSjPJqCyzU0WsiAXHRoSyTq 6AUG1rhmxV1asXpqlrO9qnWK/uXQ3CTdO7yqx5eN3QBU6m00BFvXpFtVhb6TTGYTtZx5 P3ym6LLVg8JOamEUcHVo2Qd7wYnA1euWot7EF8VvF1xLIWk2hNt0FAc8L5bP+zSZ04Fi zp9gdkYvloaNbNGjP1iCrFUO2/FTu65876SotZFexciEOFtBsJzaFAM6rpHGRIAnrUH1 gBog== X-Forwarded-Encrypted: i=1; AL+hErFtVWsNuZ74FdGbNOsyEsGXr4t5qeuK8sZY7bou4F8BmCHyPuFNy3fhvl+47aQkmsk2RiHc0U1cWm8=@lists.linux.dev X-Gm-Message-State: AB4q+uE7yDWy3GampEfxNTDE7mP1Y0wkbXqVwDpeFnaxsxuj258FBQ0+ B1Vvvp3EtvRX0t+8E0IgPvg6SeRZc0wJMcM9vVWgPjhWL20h6uiaPC4qgUTAtkZsXbw= X-Gm-Gg: AZFdTZd0ZPk2KQLhHWRK1/yyUKxxhZxL5z78WanYsWenCNnDCFIj8Jci5mcmUdNigDp 2fRssLKY/8EQWDJH3n91yA5mQrEKseRs/VZWIb7X4akW56f14Tq1bcTTcov0qCT2Cf84s+v5bdt r2beN5ZEREwdjSdtDYYlGqfBTu6hHC0S5LRoAMVHTXfKIbSgaFKhH+OXTdiMgOGJSFslsmmELJ+ qi+08Yu5pUPkT2TOMrWW0vy4R4p5KtNgQ0RKaR+8qfz6dtfYQW5UDq5Qv82ZU+lfbiUY/b2MN4A pCIkVzcmm/jJRjspsG0Zm6tKTvfxuD3wQD5OnQZDFRgTTjwqukzQSZHAKo7ltSxWF6VwCdWCvco 4T4l49dhn3/BOE9KmCuLvCNkCP9HF5IHBVvzfI56wCMCDejGmVZYDyGTRp449clq57XYT2EPTdo 1CxZseOwfbsppWkFmR5OR/i/B/ECQF07ZkJHWpUSBVWb0r0g5sQygQ3XICY2mdFLHGE6Hj+97W2 ACj61bJr8o8NNQbxSh+i80shrAo+bXp5MUd0cQSQuJCykwdDug34m+bSbYTL/5gvqn3Pub+A9F8 xLV+354wDf1/YhEPlysEBIcNESrTAjVm041Llf4VsQxkYXIhnR2hq30= X-Received: by 2002:a17:903:3887:b0:2f0:8c3f:b59d with SMTP id d9443c01a7336-2f1ba19ef96mr61564575ad.62.1796544829179; Sun, 06 Dec 2026 00:13:49 -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.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 06 Dec 2026 00:13:48 -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 1/3] mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h Date: Sun, 6 Dec 2026 16:13:22 +0800 Message-ID: <20261206081324.8274-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261206081324.8274-1-songmuchun@bytedance.com> References: <20261206081324.8274-1-songmuchun@bytedance.com> 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 MAX_FOLIO_VMEMMAP_ALIGN is required by the mask-encoded compound_info, not by vmemmap optimization. compound_head() derives the head page from a tail page address by masking, which only works if the struct pages of every folio are naturally aligned with the folio size. The macro nevertheless lives in vmemmap-optimization.h and is gated on vmemmap_optimization_supported(), which is equivalent to compound_info_has_mask() today. Move it next to MAX_FOLIO_NR_PAGES in mmzone.h, which it is derived from, and gate it on compound_info_has_mask(). LoongArch's asm/pgtable.h includes vmemmap-optimization.h only for this macro. Drop the include as well, so that the next patch can include linux/mm.h from vmemmap-optimization.h without creating a circular include: asm/pgtable.h is reached from linux/mm.h through linux/pgtable.h. Signed-off-by: Muchun Song --- v2: - New patch --- arch/loongarch/include/asm/pgtable.h | 1 - include/linux/mmzone.h | 2 ++ include/linux/vmemmap-optimization.h | 9 --------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index f87603135131..cf29a4c8ac59 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -72,7 +72,6 @@ #include #include -#include #include #include diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d65c75f46562..3ce98bb398da 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -95,6 +95,8 @@ #endif #define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER) +#define MAX_FOLIO_VMEMMAP_ALIGN \ + (compound_info_has_mask() ? MAX_FOLIO_NR_PAGES * sizeof(struct page) : 0) enum migratetype { MIGRATE_UNMOVABLE, diff --git a/include/linux/vmemmap-optimization.h b/include/linux/vmemmap-optimization.h index 0ae8a96a0874..b77a3161419e 100644 --- a/include/linux/vmemmap-optimization.h +++ b/include/linux/vmemmap-optimization.h @@ -14,15 +14,6 @@ #include #include -/* - * HugeTLB Vmemmap Optimization (HVO) requires struct pages of the head page to - * be naturally aligned with regard to the folio size. - * - * HVO which is only active if the size of struct page is a power of 2. - */ -#define MAX_FOLIO_VMEMMAP_ALIGN \ - (vmemmap_optimization_supported() ? MAX_FOLIO_NR_PAGES * sizeof(struct page) : 0) - /* The number of retained vmemmap pages with HVO enabled. */ #define VMEMMAP_OPTIMIZATION_PAGES 1 #define VMEMMAP_OPTIMIZATION_SIZE (VMEMMAP_OPTIMIZATION_PAGES * PAGE_SIZE) -- 2.54.0