From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299106; b=epdHBwPEI7VJ9kBr2cITSJMSwlyEptSW2+3mAphzmbuPfZewwPOOK3a2/GP8OJrdQ61p IEB8wrt75VccCc2IWiNzJ3RX8UhWODJCcUFaao1/K/wtA5qFZPOJX93JH+nMyMObf2Pmt w9ht1CaQkifek0+rdSeWPJg2EiIc6FIrFVYQKMnA4FjsnxZMFq0wwJ20XAHlqDoc04eL4 fbe8aCoCTBOx13Tp4zbQbhXy1XYFWehlm1NngbFZeIT3tMFLarqkYUyTlN86oso17SY1Q LJzlYjF+4IgNTJZwqX5mxxtVov2q1V/j9Q0nn1j6wPrzkfmjgtyzAadnd67sNJQFcog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299106; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=bzBRamRFllkCRz0gAO4DGuyud52GWwYzVAOlsIgqUZ8=; b=FxLdpkAa88bPLzUiFCTYhQ5XxiCgkItdW5zgPgebViFt+Sn+e2lc9AQRoCEbQhpg8Iwf LXgAeMwn9TDJjzm8AnEwK6H7rS1TjcWsAG5XFOWpoclDnsaWiTCaR54yndasO2VaLiui2 4sAzPMp65+dK83xaQ0nOqgndJ5XkZA+XRj+xfKk0Zk83tVMtVGSc3Ey+fn9nP8V5LtTDE J6GfH8hxBcqLd6drdP/PYb2u7rBA4lc9aQqknA0Iqx34QLQpVUPUo9qMSmCnVVVReq0g/ 0UtfmDzMNpv9U7EnOYZi2KMXPgCcfVEHgYNnHhmulgZxi4Qz3WU0zFdIwA3Jqtk9utw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k62U614h; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DA4E606A322 for ; Thu, 3 Dec 2026 11:58:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k62U614h Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26EF11F000C1; Thu, 3 Dec 2026 11:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299106; bh=bzBRamRFllkCRz0gAO4DGuyud52GWwYzVAOlsIgqUZ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=k62U614hL9JYqb19MrvOWCRYi1LzVh33alMwiMXf6E5x3+6aWVmym8YZbSWZcVk31 638NvRfbpgc/44WUaZfmOyKXDb+/s3k8yNvlzjAKGUbFp99mz6qqX+wwHifBRZZk9e KJ0GkBJ11YDOmDaLYYFLB+cjWJSKFCZcv+A+W2c7mxjALBqH+YrVfe6XfuCOSnxbgZ RCQIT8R8bIJwvr8hVBHd7oVXgFhVyK3R+Kus17+L/CwoqNcJiltDkkMC8LJ7vOHKZZ /SZ2eyVeF32e6etZC/LIYUYXzWrE1r6np1y9fvu+UWTuprD8hJXl1Y/g9/QxAPqA/6 AtxKRvNVUDZrg== Date: Thu, 3 Dec 2026 13:58:19 +0200 From: Mike Rapoport To: Chris Down Cc: pasha.tatashin@soleen.com, pratyush@kernel.org, graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 0/2] kho: handle failures to reserve preserved memory Message-ID: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Chris, On Wed, Dec 02, 2026 at 06:58:18PM -0800, Chris Down wrote: > Hi Mike, > > Mike Rapoport writes: > >If memblock_reserve() fails we are in a very unhappy place. > >Do you think we really should worry about KHO state when we won't pass > >through mm_core_init() anyway? > > I am not an expert in memblock for sure, but as far as I can see the > following can happen reasonably: > > 1. The memory map is allocated in mm_core_init_early(), so the walk has > its memory already. > 2. kho_memory_init() is the last thing before memblock_free_all(), so > nothing between the walk and memblock_free_all() allocates from > memblock. > 3. memblock_free_all() may have to grow the reserved array itself, but it > stops restricting allocations to bootmem before it does. Once it has > run, the kernel has plenty to work with, including whatever the walk > failed to reserve. > > Or am I missing something? > > I've now also managed to hit this without forcing the failure. I > preserved a memfd whose 140000 pages are interleaved with another > file's, so that each page is a range of its own, and used reserve_mem= > to fill most of the next kernel's bootmem. Without the series, that > kernel logs > > memblock: Failed to double reserved array from 131072 to 262144 entries ! We really don't want to get to 262144 and even 131072 entries in memblock.reserved :-D > for each range it can no longer reserve, and then boots to userspace as > usual. Retrieving the memfd there fails with -EIO, with > kho_restore_page() warning that the magic is gone. With the series, it > logs the failure once, drops the handover and boots. > > It's still unlikely, since it needs badly fragmented preserved memory > and a bootmem that's close to full, although it will get easier to hit > if we manage to shrink bootmem. But the kernel doesn't die when it > happens. It carries on with preserved memory in the page allocator, so > I think it's worth handling, but please do tell me if there's context > I'm missing here. Right, with limited bootmem and badly fragmented and spread all over the place preserved memory we can hit failure in memblock_reserve(). I'll take v3 with Pratyush's comments and my nit picks addressed. > Thanks, > > Chris -- Sincerely yours, Mike.