Linux s390 Architecture development
 help / color / mirror / Atom feed
* Re: [PATCH] crash: keep crashkernel CMA pages reserved if activation fails
       [not found] <20261104145600.3708886-1-usama.arif@linux.dev>
@ 2026-11-06 11:21 ` Mikhail Zaslonko
  2026-11-06 14:05   ` Usama Arif
  0 siblings, 1 reply; 3+ messages in thread
From: Mikhail Zaslonko @ 2026-11-06 11:21 UTC (permalink / raw)
  To: Usama Arif, Andrew Morton, baoquan.he, rppt, pasha.tatashin,
	pratyush, ruirui.yang, jbohac, david, hbathini, leitao, kexec,
	linux-mm, linux-kernel, kas, hannes, riel, shakeel.butt,
	kernel-team
  Cc: Vasily Gorbik, Heiko Carstens, Alexander Gordeev, linux-s390,
	Bradley Morgan



On 04-Nov-26 15:56, Usama Arif wrote:
> reserve_crashkernel_cma() adds each crashkernel CMA area to
> crashk_cma_ranges[] as soon as it is declared. If the area later fails
> activation, e.g. because movablecore= put the ZONE_MOVABLE boundary
> inside it, cma_activate_area() releases the pages to the buddy allocator
> as ordinary memory. The range is still handed to the crash kernel and
> excluded from the vmcore, so kernel data that lands there is overwritten
> by the crash kernel and missing from the dump.
> 
> Mark the areas with cma_reserve_pages_on_error(), so that a failed
> activation leaves the pages reserved: lost to the first kernel, but safe
> for the crash kernel to use.
> 
> Fixes: ab475510e042 ("kdump: implement reserve_crashkernel_cma")
> Signed-off-by: Usama Arif <usama.arif@linux.dev>
> ---
s390 hits this without movablecore= (adding the s390 maintainers and
linux-s390) since ZONE_DMA ends at 2G here.
CMA tries to reserve areas above 4G first, but falls back to lower
memory when it doesn't fit, so a cma area can end up across the 2G boundary.
I ran into this while adding crashkernel=,cma support for s390, which I
will post soon, and came up with the same fix.

About dropping the range instead, as you offered for v2: I'd keep this
version. With the range dropped, the kdump kernel gets less memory than
configured, and that only shows at crash time. With this patch, the
the first kernel 'loses' the memory as with a regular crashkernel= reservation
of the same size.

There is a second problem in the same loop: all areas are named
"crashkernel", which breaks the CMA sysfs and debugfs entries when
there are several. I've sent a separate fix for that:

https://lore.kernel.org/r/20261106104309.3669583-1-zaslonko@linux.ibm.com

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Tested-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crash: keep crashkernel CMA pages reserved if activation fails
  2026-11-06 11:21 ` [PATCH] crash: keep crashkernel CMA pages reserved if activation fails Mikhail Zaslonko
@ 2026-11-06 14:05   ` Usama Arif
  2026-11-06 14:16     ` Bradley Morgan
  0 siblings, 1 reply; 3+ messages in thread
From: Usama Arif @ 2026-11-06 14:05 UTC (permalink / raw)
  To: Mikhail Zaslonko
  Cc: Usama Arif, Andrew Morton, baoquan.he, rppt, pasha.tatashin,
	pratyush, ruirui.yang, jbohac, david, hbathini, leitao, kexec,
	linux-mm, linux-kernel, kas, hannes, riel, shakeel.butt,
	kernel-team, Vasily Gorbik, Heiko Carstens, Alexander Gordeev,
	linux-s390, Bradley Morgan

On Fri, 6 Nov 2026 12:21:12 +0100 Mikhail Zaslonko <zaslonko@linux.ibm.com> wrote:

> 
> 
> On 04-Nov-26 15:56, Usama Arif wrote:
> > reserve_crashkernel_cma() adds each crashkernel CMA area to
> > crashk_cma_ranges[] as soon as it is declared. If the area later fails
> > activation, e.g. because movablecore= put the ZONE_MOVABLE boundary
> > inside it, cma_activate_area() releases the pages to the buddy allocator
> > as ordinary memory. The range is still handed to the crash kernel and
> > excluded from the vmcore, so kernel data that lands there is overwritten
> > by the crash kernel and missing from the dump.
> > 
> > Mark the areas with cma_reserve_pages_on_error(), so that a failed
> > activation leaves the pages reserved: lost to the first kernel, but safe
> > for the crash kernel to use.
> > 
> > Fixes: ab475510e042 ("kdump: implement reserve_crashkernel_cma")
> > Signed-off-by: Usama Arif <usama.arif@linux.dev>
> > ---
> s390 hits this without movablecore= (adding the s390 maintainers and
> linux-s390) since ZONE_DMA ends at 2G here.
> CMA tries to reserve areas above 4G first, but falls back to lower
> memory when it doesn't fit, so a cma area can end up across the 2G boundary.
> I ran into this while adding crashkernel=,cma support for s390, which I
> will post soon, and came up with the same fix.
> 
> About dropping the range instead, as you offered for v2: I'd keep this
> version. With the range dropped, the kdump kernel gets less memory than
> configured, and that only shows at crash time. With this patch, the
> the first kernel 'loses' the memory as with a regular crashkernel= reservation
> of the same size.

Yes, I do agree with this. Losing memory in first kernel is preferrable
and it will then force someone to fix whatever is broken rather than
finding out when their kernel crashes.

> 
> There is a second problem in the same loop: all areas are named
> "crashkernel", which breaks the CMA sysfs and debugfs entries when
> there are several. I've sent a separate fix for that:
> 
> https://lore.kernel.org/r/20261106104309.3669583-1-zaslonko@linux.ibm.com
> 

Thanks! I reviewed this now.

> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
> Tested-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
> 

Thanks for testing and reviewing!

Usama

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crash: keep crashkernel CMA pages reserved if activation fails
  2026-11-06 14:05   ` Usama Arif
@ 2026-11-06 14:16     ` Bradley Morgan
  0 siblings, 0 replies; 3+ messages in thread
From: Bradley Morgan @ 2026-11-06 14:16 UTC (permalink / raw)
  To: Usama Arif, Mikhail Zaslonko
  Cc: Andrew Morton, baoquan.he, rppt, pasha.tatashin, pratyush,
	ruirui.yang, jbohac, david, hbathini, leitao, kexec, linux-mm,
	linux-kernel, kas, hannes, riel, shakeel.butt, kernel-team,
	Vasily Gorbik, Heiko Carstens, Alexander Gordeev, linux-s390

On 6 November 2026 14:05:54 GMT, Usama Arif <usama.arif@linux.dev> wrote:
>On Fri, 6 Nov 2026 12:21:12 +0100 Mikhail Zaslonko
><zaslonko@linux.ibm.com> wrote:
>
>> 
>> 
>> On 04-Nov-26 15:56, Usama Arif wrote:
>> > reserve_crashkernel_cma() adds each crashkernel CMA area to
>> > crashk_cma_ranges[] as soon as it is declared. If the area later fails
>> > activation, e.g. because movablecore= put the ZONE_MOVABLE boundary
>> > inside it, cma_activate_area() releases the pages to the buddy
>allocator
>> > as ordinary memory. The range is still handed to the crash kernel and
>> > excluded from the vmcore, so kernel data that lands there is
>overwritten
>> > by the crash kernel and missing from the dump.
>> > 
>> > Mark the areas with cma_reserve_pages_on_error(), so that a failed
>> > activation leaves the pages reserved: lost to the first kernel, but
>safe
>> > for the crash kernel to use.
>> > 
>> > Fixes: ab475510e042 ("kdump: implement reserve_crashkernel_cma")
>> > Signed-off-by: Usama Arif <usama.arif@linux.dev>
>> > ---
>> s390 hits this without movablecore= (adding the s390 maintainers and
>> linux-s390) since ZONE_DMA ends at 2G here.
>> CMA tries to reserve areas above 4G first, but falls back to lower
>> memory when it doesn't fit, so a cma area can end up across the 2G
>boundary.
>> I ran into this while adding crashkernel=,cma support for s390, which I
>> will post soon, and came up with the same fix.
>> 
>> About dropping the range instead, as you offered for v2: I'd keep this
>> version. With the range dropped, the kdump kernel gets less memory than
>> configured, and that only shows at crash time. With this patch, the
>> the first kernel 'loses' the memory as with a regular crashkernel=
>reservation
>> of the same size.
>
>Yes, I do agree with this. Losing memory in first kernel is preferrable
>and it will then force someone to fix whatever is broken rather than
>finding out when their kernel crashes.
>
>> 
>> There is a second problem in the same loop: all areas are named
>> "crashkernel", which breaks the CMA sysfs and debugfs entries when
>> there are several. I've sent a separate fix for that:
>> 
>>
>https://lore.kernel.org/r/20261106104309.3669583-1-zaslonko@linux.ibm.com
>> 
>
>Thanks! I reviewed this now.
>
>> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
>> Tested-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>

Well, now that that predicament arises, I see that this patch is a "hidden
gem" sort of thing

Reviewed-by: Bradley Morgan <brads@mainlining.org>

(Thanks for telling me about how you accounted for that bitmap_zalloc()
failure)

>> 
>
>Thanks for testing and reviewing!
>
>Usama

--- Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-06 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261104145600.3708886-1-usama.arif@linux.dev>
2026-11-06 11:21 ` [PATCH] crash: keep crashkernel CMA pages reserved if activation fails Mikhail Zaslonko
2026-11-06 14:05   ` Usama Arif
2026-11-06 14:16     ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox