From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.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 956A4331EDA for ; Fri, 12 Jun 2026 04:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236843; cv=none; b=qS8G5zzfmTTcEJGoJESJNdVv8NmgsQyOCu6vu0jea5TkIvvFrAFWKdtf9hIJOZn92DJm3vn4zdBkNdhUQmQ1A/zfPWZfE6NOHBugGmkWtCbTG+DdxE9ugcFH/eVHhPe9CKsOJuRq4LCEccYF88HCR7SCcU1wEhrmzadww2g7Pv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236843; c=relaxed/simple; bh=mvF26/T9rxWL6gh5T3G9ZZmJfyPDp/tqoObDzsbdqjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q25zPmJAIawIvZCVXcMAzo9fBjdcQcQK9QcN9/1rS7Ya73/qYoi+ZxRvkKbTx5o2hy1xLivZcU0f3Mbd+6wEQWpaHmnJefCsCR70INKnzbEgbSxhLnQTMlzLtVAkHQU076fBvibc40Uf+lRSp1c59k2FYk3HAKPGHG6a5tbP6/s= 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=UN2WBqzX; arc=none smtp.client-ip=209.85.210.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="UN2WBqzX" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-842307472d4so251850b3a.0 for ; Thu, 11 Jun 2026 21:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1781236842; x=1781841642; 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; bh=3pqeOYOFlkduDfAEfXJoLwswwYJKmlexz4b6SAwRMuQ=; b=UN2WBqzXWdXpPFjW3DQFDKr3nAjNxEKOeJHObu2kVM2vffMaxkcLOyt9LcTs4Wac+B SMELw0u/gEfALmTTi1QJ9zO3a3QIekP15ij6aYj0t97y1HDqCpvyoTFquxNZ68Ct7lSe TMPFt0VOk39oUo7ugz9Xz4BjA9pwk+WbDHOOvx7Ppj5/DAcIQQz4UIH83FO29TvkiWGz Uo9k9FmdoPwM564CU9HMBsd8jD6eMxWKAELX+eMs24ZHOmC/tVC4hYvHJ0z67oY3vRru +IPR8ct3ba/Umf5K/QWy+/WlCiMms3SuYfbpGIoUMLVCFS9rH3OoSAAZUgvtB4q7rtFl X8zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781236842; x=1781841642; 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; bh=3pqeOYOFlkduDfAEfXJoLwswwYJKmlexz4b6SAwRMuQ=; b=k3k8VHHDBWZDwFe71p2iqAgvqTsC1mSXZBnInnSf/9s5Ncqxc7tQpce3HVFh+BShqX V4nd5+4eMv9p3oTwv1qsrjOrrZpUIdtNl5w5EuFyzWju0VG7lTffKaNIPJ5NOL2dn4vQ uXF2j+m23y2RyjRRsXxTDKazXzxm33uMlsZJkyIMOH3SPNn8hPRGTr8hcMpI1nQUO+x/ MXYktxP/TWOL9cPIAmmKAkcNr3hqtMtIxnFRPJk5DrEE3jD9mofpbowExNVw8iUxBfQC QDPsjR2FXRDMtxAdihaQQzOFQhufzpfY4LkLUK1Sf6wvgKp7MKk8p0V4L2NVpI33LBSq hhYg== X-Forwarded-Encrypted: i=1; AFNElJ9o/yK5yALlCDso1SxvAZ5HOYbnGxq90fET9TyrwRMgBPTZYQ7SJkjmsXXyV2GRkQ0YLGUXIfcFV3IIYpg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy83UhhkA9FUwC8vrs/cMoqfdrprbtwVdJ+xLX2TyqFFc7y94JR 7qQwzjxPq/VEYp97ia64k39ekZyszO8nnhZ5jvMElvTxlqMBuOszI3uhsDKNhPZGpeM= X-Gm-Gg: Acq92OF9ZnCkqskLZhLWjFpfyrdFRnE2sFrbyWM4OV83EXCef/YSgLQ3FJDpBnOQT1c 0OmQBaKkhhrrnqiAlJ4XWUY2REyNCW65JAI/AeYcpFtTad/qOXhe3capx49dk3IIJoJyoIYpxVB XeYQrh8SgOVRmVlIQvfB4IWPvq+yuYdZ3kit7lzouOUtGvRJ4rO43KM108lqPCMmK1a+vrTZh6m KqDyUy+/QmVZNKl6/hP7LSnChKs+r4vtpCCIkEaLwKKcU7W6y7PSb9sYHOOLOmmeD8b0IT2KwJU IdQ0ZYoI7NOSXZXTurdhFMffjGg5FPrvgtVccXDXw+g5QAHSYii0nvYkQXsR/VE38isqwypZ2RC 7JtEkssRB9jCkXwxWDFliizThFJdQ8vHUnR2q1jnylu/H4rutwHbI+wWB+wgYo4mhY+Un6bDzX9 83MWvuPHc/hQKNqCCpXT+85IcF+5z035Wfb2qmTv20LLI= X-Received: by 2002:a05:6a00:2d95:b0:841:dcbf:e82b with SMTP id d2e1a72fcca58-8434cea0464mr1038514b3a.12.1781236841705; Thu, 11 Jun 2026 21:00:41 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8434ad03fdcsm643352b3a.24.2026.06.11.21.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 21:00:41 -0700 (PDT) From: Muchun Song To: Oscar Salvador , David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman Cc: Muchun Song , Mike Rapoport , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nicholas Piggin , Christophe Leroy , Ritesh Harjani , "Aneesh Kumar K . V" , linuxppc-dev@lists.ozlabs.org, Mike Kravetz , Muchun Song Subject: [PATCH v4 18/19] mm/hugetlb: Remove unused bootmem cma field Date: Fri, 12 Jun 2026 11:59:02 +0800 Message-ID: <20260612035903.2468601-19-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260612035903.2468601-1-songmuchun@bytedance.com> References: <20260612035903.2468601-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 struct huge_bootmem_page no longer needs to keep the CMA pointer. The bootmem path only needs to remember whether a huge page came from CMA, which is already encoded in the flags field. Set HUGE_BOOTMEM_CMA when the page is allocated, drop the unused cma field together with the redundant assignments, and simplify the early CMA bootmem allocation fallback path now that the cma pointer no longer has to be stored in struct huge_bootmem_page. Signed-off-by: Muchun Song --- v3->v4: - Clarify in the changelog that the patch also refactors the early CMA bootmem allocation path (suggested by Mike Rapoport) --- mm/hugetlb.c | 5 +---- mm/hugetlb_cma.c | 29 +++++++++++------------------ mm/internal.h | 2 -- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 47c3d6d11c58..fb7ad2a4a26b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3076,10 +3076,7 @@ static bool __init alloc_bootmem_huge_page(struct hstate *h, int nid) */ INIT_LIST_HEAD(&m->list); m->hstate = h; - if (!hugetlb_early_cma(h)) { - m->cma = NULL; - m->flags = 0; - } + m->flags = hugetlb_early_cma(h) ? HUGE_BOOTMEM_CMA : 0; /* CMA pages: zone-crossing is validated in hugetlb_cma_reserve(). */ if (!hugetlb_early_cma(h) && diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c index e487d0ffffc0..4dfce68b354a 100644 --- a/mm/hugetlb_cma.c +++ b/mm/hugetlb_cma.c @@ -59,31 +59,24 @@ struct folio *hugetlb_cma_alloc_frozen_folio(int order, gfp_t gfp_mask, void * __init hugetlb_cma_alloc_bootmem(struct hstate *h, int nid, bool node_exact) { struct cma *cma; - struct huge_bootmem_page *m; + void *m; int node; cma = hugetlb_cma[nid]; m = cma_reserve_early(cma, huge_page_size(h)); - if (!m) { - if (node_exact) - return NULL; + if (m || node_exact) + return m; - for_each_node_mask(node, hugetlb_bootmem_nodes) { - cma = hugetlb_cma[node]; - if (!cma || node == nid) - continue; - m = cma_reserve_early(cma, huge_page_size(h)); - if (m) - break; - } - } - - if (m) { - m->flags = HUGE_BOOTMEM_CMA; - m->cma = cma; + for_each_node_mask(node, hugetlb_bootmem_nodes) { + cma = hugetlb_cma[node]; + if (!cma || node == nid) + continue; + m = cma_reserve_early(cma, huge_page_size(h)); + if (m) + return m; } - return m; + return NULL; } static int __init cmdline_parse_hugetlb_cma(char *p) diff --git a/mm/internal.h b/mm/internal.h index 3401759924d9..39c9564fba0e 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -24,13 +24,11 @@ struct folio_batch; struct hstate; -struct cma; struct huge_bootmem_page { struct list_head list; struct hstate *hstate; unsigned long flags; - struct cma *cma; }; /* -- 2.54.0