mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Aditya Gupta <adityag@linux.ibm.com>,
	Alexander Graf <graf@amazon.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Baoquan He <baoquan.he@linux.dev>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
	Hari Bathini <hbathini@linux.ibm.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Mahesh Salgaonkar <mahesh@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	Shivang Upadhyay <shivangu@linux.ibm.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Tarun Sahu <tarunsahu@google.com>
Subject: Re: [RFC PATCH 2/3] powerpc: add support for Kexec HandOver (KHO)
Date: Sun, 6 Sep 2026 13:47:24 +0300	[thread overview]
Message-ID: <ap1EvH00nKze9Kj4@kernel.org> (raw)
In-Reply-To: <2vxzwlt1vvet.fsf@kernel.org>

On Fri, Sep 04, 2026 at 06:22:18PM +0200, Pratyush Yadav wrote:
> On Fri, Sep 04 2026, Sourabh Jain wrote:
> > On 02/09/26 16:04, Pratyush Yadav wrote:
> >> On Sun, Aug 23 2026, Sourabh Jain wrote:
> >>
> >>> On 21/08/26 17:26, Pratyush Yadav wrote:
> >>>> On Fri, Aug 21 2026, Sourabh Jain wrote:
> [...]
> >>> I agree that this is one way to work around the low-memory reservation problem.
> >>> However, there are a few things that come into play here:
> >>>
> >>> 1. On powerpc, the crashkernel reservation can go up to 64 GB for kdump. With
> >>> the
> >>>     current default scratch memory reservation policy, this could result in
> >>> reserving
> >>>     up to 256 GB of scratch memory: 200% for the high-memory reservation and
> >>> another
> >>>     200% for per-node memory.
> >> That calculation looks off. It _should_ be 200% once not twice. So 128
> >> GB total. If the allocation came out via the global area, it should
> >> _only_ be accounted to the global scratch size. Similarly, only the
> >> allocations made specifically on that node should be counted for the
> >> per-node scratch size.
> >
> > For example, if a system has only one node and 64 GB is allocated from
> > that node before the kernel starts calculating the per-node and global
> > allocations for scratch memory, wouldn't the per-node allocation also be 64 GB?
> >
> > If so, wouldn't that result in 200% of 64 GB being allocated for the global
> > area and another 200% of 64 GB for the per-node area, resulting in 256 GB
> > of total scratch memory allocation? Or am I missing something here?
> 
> It shouldn't. If the 64 GB of allocation was done with NUMA_NO_NODE, and
> it _happened_ to land on node X, it should not be counted for per-node
> sizing. It should count towards the global pool. Only allocations that
> were explicitly requested with node X should be count for that node's
> scratch size.
> 
> So on a one node system where 64G of memory is allocated with
> NUMA_NO_NODE and 8G is allocated with node X, we should get 128G of
> global scratch and 16G of per-node scratch, giving us a total of 144G.
> 
> I took a quick look and it looks like the problem might be that the
> calculation for global scratch includes _all_ nodes in it. See
> memblock_reserved_kern_size():
> 
> 	for_each_reserved_mem_region(r) {
> 		...
>                 
> 		if (nid == memblock_get_region_node(r) || !numa_valid_node(nid))
> 			if (r->flags & MEMBLOCK_RSRV_KERN)
> 				total += size;
> 	}
> 
> And for global scratch we pass nid as NUMA_NO_NODE.
> 
> For KHO we could just drop the || !numa_valid_node(), but
> memblock_estimated_nr_free_pages() seems to depend on that behaviour. It
> wants to get _all_ allocations across all nodes. KHO only wants
> allocations explicitly made with NUMA_NO_NODE.
> 
> But disclaimer: all this is from reading the code for maybe 15 minutes.
> I didn't run anything and might be missing something. So please
> double-check what I am saying.

That sounds about right, although I didn't check anything at all :)
 
> > BTW, do you know the rationale behind the 200% value?
> >
> > I couldn't find any explanation for it in the commit message of
> > 3dc92c311498c ("kexec: add Kexec HandOver (KHO) generation helpers")
> 
> We need to ask Alex (or maybe Mike?; I forget who added this).
> 
> But if I were to guess, I don't think there is much science involved
> behind the number. Since the scratch lives across all kexecs, it needs
> to be large enough in case the next kernel uses more memory. 200% sounds
> "large enough".

Yeah, that was the rationale indeed :)

> -- 
> Regards,
> Pratyush Yadav

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2026-09-06 10:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 10:56 [RFC PATCH 0/3] powerpc: initial " Sourabh Jain
2026-08-21 10:56 ` [RFC PATCH 1/3] kernel/liveupdate: make KEXEC_HANDOVER depend on KEXEC_FILE instead of selecting it Sourabh Jain
2026-08-21 10:56 ` [RFC PATCH 2/3] powerpc: add support for Kexec HandOver (KHO) Sourabh Jain
2026-08-21 11:56   ` Pratyush Yadav
2026-08-23 15:41     ` Sourabh Jain
2026-09-02 10:34       ` Pratyush Yadav
2026-09-04 14:50         ` Sourabh Jain
2026-09-04 16:22           ` Pratyush Yadav
2026-09-06 10:47             ` Mike Rapoport [this message]
2026-09-06 15:32             ` Sourabh Jain
2026-08-26 13:33     ` Sourabh Jain
2026-08-21 10:56 ` [RFC PATCH 3/3] powerpc/kho: exclude THP and HUGETLB_PAGE Sourabh Jain
2026-08-21 11:34   ` Pratyush Yadav
2026-08-23 13:52     ` Sourabh Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ap1EvH00nKze9Kj4@kernel.org \
    --to=rppt@kernel.org \
    --cc=adityag@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=chleroy@kernel.org \
    --cc=graf@amazon.com \
    --cc=hbathini@linux.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mahesh@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=shivangu@linux.ibm.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --cc=tarunsahu@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®