From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF117606A334 for ; Sun, 29 Nov 2026 05:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=YAljrDlw; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=ht8cybws DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version:Cc :To:Subject:From:Message-ID:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=lTcTf8QlBZFdLO8asxsqyWuFSo+zKaveNiDf46qGM2g=; b=YAljrDlw0CQq1d7RNrAjjzBe24 EgBjWEaRGeMQKH0LwSY+JSArlBtJqmLfUvwpviDodfScinqIvbqNgYux0asLZWjdc1gMSRhtfdHsV Lac50hvcyyMR0G08iM62KMV2bH7S9CwZ4FGWTZXCDwjG8MwkuqhMo5kvSiUBBRoXFqq7IpEqL9vm9 iE+NPTLba7QykjL5ZLDRKBveyqZ89VkHoCs1f4sGgfI/eHM6k+1JA7T6rU7ATft/g+6p7Xc8JLJhh 2Nz4glOF9az0oAJuujFApUNx8cls0oHQMZDI8S0O3gFpG0nK+U8KMRjFjOPHNAn75jmMrUz1Z9kXt 384ajrMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXX2x-00000001aPQ-1LnJ; Sun, 29 Nov 2026 05:01:55 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXX2u-00000001aOq-0tKA for kexec@lists.infradead.org; Sun, 29 Nov 2026 05:01:53 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-8b4d543b6b6so53980477b3.3 for ; Sat, 28 Nov 2026 21:01:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795928510; x=1796533310; darn=lists.infradead.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:from:to:cc:subject:date:message-id :reply-to:content-type; bh=lTcTf8QlBZFdLO8asxsqyWuFSo+zKaveNiDf46qGM2g=; b=ht8cybwsjbjxJKceVZ9lXYhzUaD7yeqtEUtMwQkDEjFhzdp9VNiyyYMoDeysNRB9El 4vk2ql8xr63/M9PVCvVOp22LIe0dvYKg0rlpV22zKhARyeyd8rLsA7NvP6ZFjBU96yay t1i27bqVveDMCve6ssUA4PjJrSlg3xclaLsHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795928510; x=1796533310; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=lTcTf8QlBZFdLO8asxsqyWuFSo+zKaveNiDf46qGM2g=; b=snI9PyF7qzoBnNGDZTjXjvtGD+Lu0KlDDR/stsS1yvZXhtx5j9Dcjndd9N3BcOo4jk 20e1+ADWMnzrblmBCW9LW3BBRqX01zRf5MrmBTPPLKWlJW+1AoRY27UA48Dki9ctyRzd u9LbHo9aCFJUn9adn5RiJtkzlWDGZq9X/vp/mlCgwjckXEG9xeD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NL/YZj8zzdkg0Uv XIlcLtYTk9kdsh21xdaTSUhd3u9mTjQmLdWVr+Ti04OQTMYgV3pIY1GlIh2DjcnlnOP836yrTlq PETnQt/0GdjGWtNaiOcoNh2MkWuQ9OoJtPlkoKhmjdogNa9WPNcvjOhpTlUoz5BLNjJ8ZQfgFCW e0VcfFaR9TQF/Wsg5H/T1BX X-Received: by 2002:a05:690c:698c:b0:8b0:acc6:8e81 with SMTP id 00721157ae682-8b52031d1c0mr107810327b3.1.1795928510088; Sat, 28 Nov 2026 21:01:50 -0800 (PST) Received: from [172.20.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b56fc6131fsm51652787b3.34.2026.11.28.21.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 21:01:49 -0800 (PST) Date: Sat, 28 Nov 2026 21:01:46 -0800 Message-ID: From: Chris Down Subject: [PATCH 0/2] mm, kho: count KHO bootmem in CmaTotal and in zoneinfo's cma To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: Alexander Graf , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261128_210152_295035_C3C84D80 X-CRM114-Status: UNSURE ( 7.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-12.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 KHO bootmem is handed to the buddy allocator in MIGRATE_CMA pageblocks, so its free pages show up in CmaFree, but two of the CMA counters leave it out. CmaTotal in /proc/meminfo never includes it, and the cma line in /proc/zoneinfo includes it after a cold boot but goes to 0 after a KHO kexec. Patch 1 counts bootmem in zone->cma_pages after a KHO kexec, as kho_init() already does on a cold boot. Patch 2 then adds bootmem to totalcma_pages after both kinds of boot. After a KHO kexec, part of bootmem is still held by early boot, like the kernel image and initrd that kexec loaded there and some of the memmap. Those pages are counted too, because they're still in MIGRATE_CMA pageblocks and some of them come back as free CMA pages later on, such as the init sections and memmap pages freed by hugetlb vmemmap optimisation. Leaving them out would let CmaFree overtake CmaTotal again. The bootmem added to both counters comes from kho_init(), which runs long after mem_init_print_info(), so the "Memory:" boot line doesn't change. This came up in the thread about making bootmem visible to monitoring [0]. [0]: https://lore.kernel.org/r/2vxz4id3wgu7.fsf@kernel.org Chris Down (2): kho: count bootmem in zoneinfo's cma after a KHO kexec kho: count bootmem in CmaTotal kernel/liveupdate/kexec_handover.c | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) base-commit: a8d435799f3c87231bca0c245fd9e60f31e45135 -- 2.56.1