From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B6D9B3BD63C for ; Thu, 16 Jul 2026 21:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784235990; cv=none; b=Hw5Jez+PZ1QT88qJee3b9GWMoKneCrmdl7O+wGVCJkUck4guj6yNtW05CKrpVoOUANVYb+QErx+/qbWZnDm0fkzqv/EVWw/Z0FeUXo7TZN4x1ApxoRlP17Q8xcd86ZJ4yXpYDlunhi/xq1XN6hdXrj2ZShVrhHreRfxW30WIOvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784235990; c=relaxed/simple; bh=BO+v6xNYzGWAHgw7KJzrQdLWQLfLY2R7Vv9GKcYlr5A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ae/z2ZgQwSFd6VVpYtayNiq90/uG7aMCHVplrJs/e2FJMcxaYyEp6jPRExeTqCnF6VzjfGLQsW7iBntxmIR70gdr7xnwBOmRDIKgppqiDvlyZU2GyDkQYD88Fb92wuc/adzTiNtDjv3mTVdFgixm7o65byFtMWp4Tj6JzRnt2uw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mOC8CeGi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mOC8CeGi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859721F000E9; Thu, 16 Jul 2026 21:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784235989; bh=oucStQnRyawORtPI7Wj+qEZX9FA99Twpl/PrB1SpiMs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=mOC8CeGi42U+SdUKidcJPeWP6ZY4+ga7NyPiOUDh79HKDJUjX0/fAvYuU4zHGvfR5 HQCjCcs8mYgluWNtJzcWXoGF996LfTAFtzmJ5jFHo63T7NRCIw9CxmGePcNdTPdEMR OMaak/ENhnvrB1SlY/b+v/QVqL3/mxpe0HG+pb2j17Y+j198b2SRNxecu3PWemJuXe yWYrK66ibJzgTJdjdJq+7dUWCs57xiGlurrXoJkgWIJQA6/J1Jfh20qQs+81U22lEe 29I0zLtHNmMyabxgk6lApS7oubGAZvAiAn9D3VXdFj705DLbr+H4zKIbd5oibckO5A hlYWVxCVcMH4A== Date: Fri, 17 Jul 2026 00:06:22 +0300 From: Mike Rapoport To: Pasha Tatashin Cc: Michal Clapinski , Pratyush Yadav , Alexander Graf , Evangelos Petrongonas , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kho: align kho_scratch to MAX_ORDER_NR_PAGES pages Message-ID: References: <20260714205111.2497151-1-mclapinski@google.com> <178409777790.255896.16691338963510282908.b4-review@b4> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jul 16, 2026 at 11:04:31AM -0400, Pasha Tatashin wrote: > On 07-15 09:42, Mike Rapoport wrote: > > Hi Michal, > > > > > I caught this crash: > > > BUG: unable to handle page fault for address: ff19164fffff8328 > > > RIP: 0010:__free_one_page+0x1a1/0x6b0 > > > Call Trace: > > > > > > [] free_one_page+0xaf/0x240 > > > [] deferred_free_pages+0xa8/0xd0 > > > [] deferred_init_memmap_chunk+0x10f/0x1b0 > > > [] padata_mt_helper+0x65/0xa0 > > > [] process_scheduled_works+0x202/0x410 > > > [] worker_thread+0x1f9/0x2d0 > > > [] kthread+0x27d/0x2f0 > > > [] ? __pfx_worker_thread+0x10/0x10 > > > [] ? __pfx_kthread+0x10/0x10 > > > [] ret_from_fork+0x145/0x280 > > > [] ? __pfx_kthread+0x10/0x10 > > > [] ret_from_fork_asm+0x1a/0x30 > > > > > > > > > deferred_init_memmap_chunk() works fine without KHO because free > > > regions will never be neighbors. However, with KHO, free memory > > > will be split into (free && scratch) and (free && !scratch). > > > KHO scratch is aligned to CMA_MIN_ALIGNMENT_BYTES (which on my setup > > > is equal to 1 << 9 pages) but buddy can look at the neighborhood of > > > MAX_ORDER_NR_PAGES pages (which is equal to 1 << 10 pages). > > > This sometimes crashes when one half of the neighborhood is being > > > initialized but the other part is yet to be initialized. > > > > > > To fix this, let's just align KHO scratch to MAX_ORDER_NR_PAGES pages. > > > > > > Fixes: c6073743d0c7 ("kho: make preserved pages compatible with deferred struct page init") > > > Signed-off-by: Michal Clapinski > > > > > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > > > index 4834a809985ab..50928aaa33710 100644 > > > --- a/kernel/liveupdate/kexec_handover.c > > > +++ b/kernel/liveupdate/kexec_handover.c > > > @@ -38,6 +38,16 @@ > > > #include "../kexec_internal.h" > > > #include "kexec_handover_internal.h" > > > > > > +/* > > > + * This is the minimal alignment required by deferred struct page init. > > > + * deferred_init_memmap_chunk frees memory to the buddy allocator, which looks > > > + * at the neighboring pages (up to MAX_PAGE_ORDER) to merge them. > > > + * If KHO scratch is not aligned to that value, buddy can access uninitialized > > > + * struct pages, which can cause a crash. > > > + */ > > > +#define SCRATCH_ALIGNMENT_BYTES (1 << (PAGE_SHIFT + MAX_PAGE_ORDER)) > > > +static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES); > > > > Maybe make it a variable and set it at runtime? > > We won't need to worry about different confugurations that override > > MAX_ORDER and potentail divergence of pageblock size from MAX_ORDER in > > Do those architectures reduce MAX_ORDER when they override it? I would > hope we could set the alignment once and make it large enough to work > everywhere, rather than depending on dynamic changes even during boot... They could, e.g. arm64 has this: config ARCH_FORCE_MAX_ORDER int default "13" if ARM64_64K_PAGES default "11" if ARM64_16K_PAGES default "10" > > the future. > > > > -- > > Sincerely yours, > > Mike. > > -- Sincerely yours, Mike.