From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B6E3D812C for ; Mon, 20 Jul 2026 09:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784539929; cv=none; b=uZUzgfvEGY/WUQ+N1tvwi/i0jHs5ighIBpbMSn8yjhnuHllewBFoXfUx7eksMLCic5+iwWUqRWf1a9S5Ux/POWNIg2uwkvL1gQ5ExWvY5SGENgjm8+xquIKhJvlQD6OorEzbwUeIfAUHRjY7EOY4pKNZOWqvbMf9cD7nie+OL8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784539929; c=relaxed/simple; bh=owQ+Elu7FhHy0RmBaGNrJ1F4/GpIAVuOEqAZSW69+JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pptPN5okqjYGRBWJhlXDG74QfSICSuNH+iDdcuJwduSl+VBRXSb3rUrPrndSqTijb+8jRc3Ls/F7NlzbzMtHqS7qGiDAoBYZQ7p4g43NTlKsDZbyBEu2JbJ5Um1ZbQN9185ANkqyZ7vBumBkHpbaUDKwyjaA6k8XKoNLryEGfck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=RKDYNREl; arc=none smtp.client-ip=209.85.214.179 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.b="RKDYNREl" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2cc7e86e7aeso70230535ad.2 for ; Mon, 20 Jul 2026 02:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1784539927; x=1785144727; darn=vger.kernel.org; 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=bOzdkIPPNoupexe8+AVOrQT3DBRmXPJ6Kybkle+RLi4=; b=RKDYNREla1uG37/wf44pFvvzb2W/jzJpro7wPYewaJDT8M6mgu0NTEKP159QkbVwKa NEzmwInMn88rWTE7pxHAAzPc+Aq3rphoJPBqqprir9kBgdjx7ezpcfYfUvs+hHSaMqJV e0HOOcKaIzPVHih93OZiIyeH95QDwZzfevYgrL7dlQdoA2FxRO3Eiff1WQ3zAAh/eofh 6AENa/5MwpAqHWZ+yCt6gYN+mQlmuTrUB9jCXczwllGHlv3CQFUmhdSlcy0MdIuxbyVm iqcg02IrnU3Rr0xeLYtn+QNfGM4c6Vyz/IaoexIVKyCgTO1nB8zHfx1pu0a0y1jLKqit WQfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784539927; x=1785144727; 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=bOzdkIPPNoupexe8+AVOrQT3DBRmXPJ6Kybkle+RLi4=; b=tJM3R36UU8C4wpAKA2HiC5aPoAEo/GOQiGMedd7zIp07n9uzG1UaQhg4Xjb3EuFpfb 2KNb9oCgCCFnzOS0b53qkIxoeapbNsOYaCgPUmK8owphR/10FfB4AkBH7KJ0FhHwd+sx kiqr7nyOYLNdp5wV91aW+U2LDJ7v5+Enio19ktGC4HrpQ6THiprhOL5fGE6DokDuCZtY ZHJeWbzbsxt/qDWSBbqaRP6Dz5wQ6KBlhym5O3sPsZYbKUtfdRuWB/PAQi4AYWwJp3UR a/hsjinvW2AogBgGpI+UOaAKdEBjwAllgsueLn7DkOzDmrnB6trH5GLzbKeCGexvpOo2 5/ew== X-Forwarded-Encrypted: i=1; AHgh+RpMLk/H2sBtyTJwETRIJRZ11VYPRpVQic9H49dkbwn6NvadLUIdkbanBJ8TNgGoXNIA+4sOzfVQz1tMhZs=@vger.kernel.org X-Gm-Message-State: AOJu0YzGzG6UxENgazz2tGZ53g92IHzowRBUJbxU8GE2fMnF0ty5YC9j AsN8soIsqDlToawsN5bh/gZzLG4rTO9ZjvxzJjYFoUNNOJ2rB6HChQqueWfcNBR2pH0= X-Gm-Gg: AfdE7cm0nWZL5UneXw6ManDQj3NIM2i91A7biO5mBhOoSs6d46Zqvs79sHCO9gylfwY qJRe6QMV4qsjrFWu/oP9tN6EOoFM3+fNqHYV/KxrxKNFOGPGAKoledZjmzocBrkEKoTlG/Y930k vEEOjzdeqRoTrUDBoP3lW5lkj+9/uCyS+JYjbnZ2wbceq7P/gdvx03vaux69mrfJ75DQcWuqp+m WjxqCSoLAzqq6Z+WYWWcaNkDAVYPYSveF44Z4Tf7gLwoYFoeQidRDNk3U1jczkURwl9BgVgoomS zTZqiLOLO/Jn7qKH7yrhcJKDGrOkWAy+KtmVruvznzpEaW+fV7NExQvBX13j9GuYXX33eambl3j 9QfMMvT+JGWeblRaiCh5SQarmapyiFQZXlmt5r9w0DNvsdUe1GXdHk9A/w94eZg8Ji1y3H4Tv0F 5/y4boP8tHNKNuRXWPc80yGxw= X-Received: by 2002:a17:903:2a8b:b0:2ca:ddbd:a19b with SMTP id d9443c01a7336-2cf34997827mr147416145ad.28.1784539927267; Mon, 20 Jul 2026 02:32:07 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.101]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf347a7c9fsm53136455ad.84.2026.07.20.02.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 02:32:06 -0700 (PDT) From: Muchun Song To: Andrew Morton , Oscar Salvador , David Hildenbrand Cc: Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Michal Hocko , David Laight , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , Muchun Song Subject: [PATCH v2 04/17] mm/sparse-vmemmap: initialize shared tail vmemmap pages on allocation Date: Mon, 20 Jul 2026 17:31:14 +0800 Message-ID: <20260720093127.540540-5-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720093127.540540-1-songmuchun@bytedance.com> References: <20260720093127.540540-1-songmuchun@bytedance.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 The shared tail vmemmap page allocated in vmemmap_get_tail() used to be left uninitialized, because memmap_init_range() would later overwrite it. That forced users such as HugeTLB to defer the initialization to their own setup paths. Now that memmap_init_range() skips shared tail vmemmap pages, initialize them immediately in vmemmap_get_tail() with init_compound_tail() instead. This moves the initialization to the point where the shared tail page is allocated and avoids relying on deferred handling in individual users. The remaining deferred initialization in HugeTLB will be removed once it switches to the section-based vmemmap optimization mechanism. Signed-off-by: Muchun Song --- mm/sparse-vmemmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index aa6a4a2fae98..107215cf8488 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -338,19 +338,11 @@ static __meminit struct page *vmemmap_get_tail(unsigned int order, struct zone * tail = zone->vmemmap_tails[idx]; if (tail) return tail; - - /* - * Only allocate the page, but do not initialize it. - * - * Any initialization done here will be overwritten by memmap_init(). - * - * hugetlb_bootmem_struct_page_init() will take care of initialization - * after memmap_init(). - */ - p = vmemmap_alloc_block_zero(PAGE_SIZE, node); if (!p) return NULL; + for (int i = 0; i < PAGE_SIZE / sizeof(struct page); i++) + init_compound_tail(p + i, NULL, order, zone); tail = virt_to_page(p); zone->vmemmap_tails[idx] = tail; -- 2.54.0