From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEFFD606A322 for ; Thu, 3 Dec 2026 11:58:30 +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 kanga.kvack.org (Postfix) id AB0F16B05CC; Thu, 3 Dec 2026 06:58:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A619B6B05CB; Thu, 3 Dec 2026 06:58:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 977986B05CE; Thu, 3 Dec 2026 06:58:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6E5E46B05CB for ; Thu, 3 Dec 2026 06:58:29 -0500 (EST) Received: from smtpin24.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E459B140658 for ; Thu, 3 Dec 2026 11:58:28 +0000 (UTC) X-FDA: 85502524296.24.208222B Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf22.hostedemail.com (Postfix) with ESMTP id 49970C000D for ; Thu, 3 Dec 2026 11:58:27 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=k62U614h; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796299107; b=uLlzP7j9drIGeO9pGxPMP4rwHExUzxFNwAqqp3yNkGt8+jOX5Hk9LiEGWGabMeRO6Qu+RF 2wUs2SuPwRuneMRBq0RDCRHzbXQEqPcthNs8CTmOSXsq/pVoze9ipw7co0L2fLx5zOO/4K YnBmBrdZYRbF0WGxjvhlC0HrGvnH/To= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796299107; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bzBRamRFllkCRz0gAO4DGuyud52GWwYzVAOlsIgqUZ8=; b=kjfefsrb16fuL8k9vJAQzHlsyhrc6ji66lfzFHkp1YK3JuJ/dYmAo2ybef3IIzf7AxG+LS ybLi361nhc/PoG7rzHZ90mUDAMRw+vNeeH9X4n0t2svyicr9OBGvANV++LZzJ+M47sOiDh TV48Lp22iPqkyWLDXwQoDMRehOBq/EA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=k62U614h; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 2CCA7417C7; Thu, 3 Dec 2026 11:58:26 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: imz7q18om7sekr3pbmqkog58rrerfzq8 X-Rspamd-Queue-Id: 49970C000D X-Rspamd-Server: rspam10 X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Rspam-User: X-HE-Tag: 1796299107-267638 X-HE-Meta: U2FsdGVkX1/HIbn2DqixkBgrffNwDoNJzItp3//tR8qBoxnI4JZJUi1wmlxnNR/k0Y5TvIgbUxP5xDj1nDPTXGgDnzu2xytkHmWIx3ttjQUVSaBzj/x+6tGYI5xSTzxkhtlqU9NZgacCxZOTlwgyetQUEk0UAxiW7m6eqGbi3O6K3YK8GkjaTApibeEeXoiqg01/d7cWVMvRGgoHtt5CdS+py8rvQMxAodlVm1XWyaO3pMo3GRaCH12Gy3OljvqNQDifpSbcWZTYTR3Ch4XlR7ChXNq7fQ0GgkyX/rmP7DB57B+UH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LbFnMYmyvcEBVlBJ/YUY1a2e4RvLKcuKV/x5MASVgzQxNWqoaxiqH1IjVCIm7K020qksoOMtnv Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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.