From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EE2D230264 for ; Wed, 29 Apr 2026 13:39:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777469986; cv=none; b=Eio1TQRHcghptdceKVNhyiR2eQ1PvbPhKwdU6pjnuMvsFJdRLmzQ2XcKXqrgzMsnhGhuBC3N9b8hy/3Vqp65082QT+om+BCUar4e343f8ZPrU3EuQ8hxjBex1hM8QP6tBEQ5hZT7DgGiM/MYlYaLMOswNuatG4ldkLKwapGdt4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777469986; c=relaxed/simple; bh=w869zNKzhithGNRmRqp8WYig74dnCUUN98eSnQq4g4Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QpY2W3H2z8te9MRkdSLPgWByxGScCSjWC+mOHYF8hAE1xDxEpegvEFwYOkGA+KGiKxqruIOO51rKHuepsfj1l9sJHNbwQqMXlyLp1DBS0iIO+fTgn+B/vY3uxj+0xkXw+3x7X6rQhKN6vHygPgCrzCEJtVhMu6D9obh7GYKuoEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MJs6lfTE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MJs6lfTE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2195C19425; Wed, 29 Apr 2026 13:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777469984; bh=w869zNKzhithGNRmRqp8WYig74dnCUUN98eSnQq4g4Q=; h=From:To:Cc:Subject:Date:From; b=MJs6lfTE7V3kbascG1+hudy/89zmczFa5PxlZb5UB9FFDeycEMZORLHAl0r9HeTbG xqc3Gi0YqX51ek5zsuVTKbNZU/INQwG7AjqhtYWOg7E9FRvYtQM0Da8ZNgcTV67nCR kcuSTAj4LjOQ49eRp1hus4XCBUTq5/X9mJX03PiQ4ttbMrRAehATP2YYWKXE5dPdru VCsmOKouXvBl7J0S5gjrxRzqYFh+k778oF8861LTfFygHVLDtX/ZaJBwXUiKc69zK5 D0jKzuL4H3n57HWS3knDqaHryDPzba/sy0Ustoy6M9jDA/bDNZlPNRCSrHkTu8UFoU lAoK9K3AxOKHw== From: Pratyush Yadav To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Alexander Graf , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Jason Miu Cc: kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 00/12] kho: make boot time huge page allocation work nicely with KHO Date: Wed, 29 Apr 2026 15:39:02 +0200 Message-ID: <20260429133928.850721-1-pratyush@kernel.org> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pratyush Yadav (Google)" Hi, Gigantic huge page allocation is somewhat broken currently with KHO. First, they break scratch size accounting. Since they are allocated using the memblock alloc APIs, they count towards RSRV_KERN, and this scratch size when using scratch_scale. This means if huge pages take a large enough chunk of system memory scratch size will blow up and fail to allocate. Second, scratch can not contain preserved memory, and if hugepages are allocated from scratch, they will fail to be preserved with the upcoming hugetlb preservation series [0]. Fix this by introducing the concept of extended scratch areas. They are areas that the kernel discovers on boot by walking the radix tree and finding free memory ranges. See patch 10 for more details. Discovering the scratch areas needs some changes to the radix tree APIs and to memblock. Patches 1-8 do that. Patch 9 introduces extended scratch to memblock. Patch 10 adds the extended scratch discovery logic. Patch 11 cleans up the preserved memory map API. Finally, patch 12 puts all the pieces together and uses only extended scratch for hugepage allocation and does not count then towards RSRV_KERN. [0] https://lore.kernel.org/linux-mm/20251206230222.853493-1-pratyush@kernel.org/T/#u Regards, Pratyush Yadav Pratyush Yadav (Google) (12): kho: generalize radix tree APIs kho: store incoming radix tree in kho_in kho: add a struct for radix callbacks kho: add callback for table pages kho: add data argument to radix walk callback kho: allow early-boot usage of the KHO radix tree kho: allow destroying KHO radix tree kho: add kho_radix_init_tree() memblock: introduce MEMBLOCK_KHO_SCRATCH_EXT kho: extended scratch kho: return virtual address of mem_map mm/hugetlb: make bootmem allocation work with KHO include/linux/kexec_handover.h | 1 + include/linux/kho_radix_tree.h | 44 ++-- include/linux/memblock.h | 14 ++ kernel/liveupdate/kexec_handover.c | 389 ++++++++++++++++++++++------- mm/hugetlb.c | 19 +- mm/memblock.c | 177 ++++++++++--- mm/mm_init.c | 1 + 7 files changed, 489 insertions(+), 156 deletions(-) base-commit: eee13213401bafb7ffe3b447adffb1f570b9d813 -- 2.54.0.545.g6539524ca2-goog