From nobody Tue Feb 10 00:22:28 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 C25991DED64 for ; Mon, 27 Jan 2025 23:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738020165; cv=none; b=g7HZLtRboMU/YE1OU+ZZVWgDSHq9ME3NgMm33m3+OzJ0WdZV+dXREyyFR8ffp+BzszAQc+BzD95Pw673w49oVlLSvzS0kjmFwynYKOQAqaiYonK/aZQZQcjegzYFB2LKlGhRjWlYAdpxunkn+jGkqcZ4TkIU9uYGittL/NJ0J/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738020165; c=relaxed/simple; bh=uOAbSbzxoGBfJmdHJDqI6LNFH3/WBzKLQGxmn3NDyQE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=srREKjB4d61d8AZoJE5XeoPHk4fXKUTb5FjTZFj9AlSKt5KsMJDT4Y2qv/H1tvdwRbIzG+2RkQ8DjLgK40vdoe8+me6iEghYjkf70g9/P70mtpg/do688z3MNLzImibW4G6/6zgZYmu3duORpLdc/vD9XF2UqSHlwYqZDPBhjMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--fvdl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lCodhrQt; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--fvdl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lCodhrQt" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef6ef9ba3fso10042505a91.2 for ; Mon, 27 Jan 2025 15:22:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738020163; x=1738624963; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ahGehxe7VKaUNIFIiK0DUduVLM+snH5y4prr1K+tq+0=; b=lCodhrQtKJe4H8I1liTy4jKegyBK7jCq5b+mKURuHxz8JstRXVLrVVxD+9xk5E5D7l alwblp6ePnYF7MDQwhZKOczSrSCDownt8qwdfZRwTy2QXqO0gAUJAWtyx9/Afi4u8bXN jdKXzjuqTqavOeoQO6YvTGlcF5BvX2rLTxUEEjpPk3zZO38yIfO0ZIdJuAI8fx0rmLoM MjQhfi6ycACF1K7ecQlc3bLR5BNAj+aF9XFnFFYjAnwsMYipfMbItMfFX1Ep1K0HDfce DRSnNy9Wiob9EI2NRJA1NGdvSbwDAq1OvAetCeGSFMz3KsvYLFM0GKJR6qyWr5EaBW1i Ky4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738020163; x=1738624963; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ahGehxe7VKaUNIFIiK0DUduVLM+snH5y4prr1K+tq+0=; b=s9ha+JISRPAI/lJ1HMeHq1vPoeDTolBxM1SInjyDW0JwDghGzFVYJBTg/fH5fzz8/X JFx4GqVJpOQRAquOsYAaKzOcpkqOMCYx/RjjJJgAkSD7vV/v89mQULb6iUswmGv/xPgc O9q1o65NmlzJynfD7W1OtMNGu6cY/thdZgGgj13d44R7JmhttzWB+NHHWmMbOBQ2bszu I/izsz63AdIcG6Y4I2PhgKX/+xiurYpwSz72ZzPHfWKnFOxwHImy6lBxEZ0urBLrH0Ai uccvo22r2QAOiXCAT7H3niO8WTsQDZw0ToOn9+qUDdkJ5bLJK8MUKpYXoZvog+MUTgDK Lemw== X-Forwarded-Encrypted: i=1; AJvYcCWKTjQY01e1aKb8+mZZTnE/hY17BGPxCfaO+qT1Xy7pocvlwKnba/u+8YyoVex2B1Txd7DsvtbUYFxO0MU=@vger.kernel.org X-Gm-Message-State: AOJu0YyqvIQ9uS9/0ov1iw0LyO380H2kVJFxEJVpTDRehrDpsqYcXzmN xuP3ApBLkE0L6Pf8jrnnSUYoWgYA5EE480wfNA9edzGyQMwUaBt/tj/mAzfDz5QBq8ZHlg== X-Google-Smtp-Source: AGHT+IGFs3VKcM0qeDQDow0P008CgDVW9Bc9HLj1xsHRZgddaRUVV0k4+E5fjCd5lGcKYV5Gkvrp4cQ/ X-Received: from pfbeg15.prod.google.com ([2002:a05:6a00:800f:b0:725:c72a:a28a]) (user=fvdl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:181f:b0:727:3cd0:1167 with SMTP id d2e1a72fcca58-72dafba0247mr63641686b3a.21.1738020163186; Mon, 27 Jan 2025 15:22:43 -0800 (PST) Date: Mon, 27 Jan 2025 23:21:52 +0000 In-Reply-To: <20250127232207.3888640-1-fvdl@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250127232207.3888640-1-fvdl@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127232207.3888640-13-fvdl@google.com> Subject: [PATCH 12/27] mm/hugetlb: set migratetype for bootmem folios From: Frank van der Linden To: akpm@linux-foundation.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: yuzhao@google.com, usama.arif@bytedance.com, joao.m.martins@oracle.com, roman.gushchin@linux.dev, Frank van der Linden Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The pageblocks that back memblock allocated hugetlb folios might not have the migrate type set, in the CONFIG_DEFERRED_STRUCT_PAGE_INIT case. memblock allocated hugetlb folios might be given to the buddy allocator eventually (if nr_hugepages is lowered), so make sure that the migrate type for the pageblocks contained in them is set when initializing them. Set it to the default that memmap init also uses (MIGRATE_MOVABLE). Signed-off-by: Frank van der Linden --- mm/hugetlb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a95ab44d5545..9969717b7dd8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -36,6 +36,7 @@ #include #include #include +#include =20 #include #include @@ -3258,6 +3259,26 @@ static void __init hugetlb_folio_init_vmemmap(struct= folio *folio, prep_compound_head((struct page *)folio, huge_page_order(h)); } =20 +/* + * memblock-allocated pageblocks might not have the migrate type set + * if marked with the 'noinit' flag. Set it to the default (MIGRATE_MOVABL= E) + * here. + * + * Note that this will not write the page struct, it is ok (and necessary) + * to do this on vmemmap optimized folios. + */ +static void __init hugetlb_bootmem_init_migratetype(struct folio *folio, + struct hstate *h) +{ + unsigned long nr_pages =3D pages_per_huge_page(h), i; + + WARN_ON_ONCE(!pageblock_aligned(folio_pfn(folio))); + + for (i =3D 0; i < nr_pages; i +=3D pageblock_nr_pages) + set_pageblock_migratetype(folio_page(folio, i), + MIGRATE_MOVABLE); +} + static void __init prep_and_add_bootmem_folios(struct hstate *h, struct list_head *folio_list) { @@ -3279,6 +3300,7 @@ static void __init prep_and_add_bootmem_folios(struct= hstate *h, HUGETLB_VMEMMAP_RESERVE_PAGES, pages_per_huge_page(h)); } + hugetlb_bootmem_init_migratetype(folio, h); /* Subdivide locks to achieve better parallel performance */ spin_lock_irqsave(&hugetlb_lock, flags); __prep_account_new_huge_page(h, folio_nid(folio)); --=20 2.48.1.262.g85cc9f2d1e-goog