All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Sourabh Jain <sourabhjain@linux.ibm.com>,
	Aditya Gupta <adityag@linux.ibm.com>,
	Hari Bathini <hbathini@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size()
Date: Thu, 30 Jul 2026 16:45:37 +0200	[thread overview]
Message-ID: <amtjkfZgkvFACYzE@linux.dev> (raw)
In-Reply-To: <42ab7c21-25cd-4ed1-b43f-b155e82db1a0@kernel.org>

On Thu, Jul 30, 2026 at 04:33:18PM +0200, Christophe Leroy (CS GROUP) wrote:
> Le 30/07/2026 à 15:19, Thorsten Blum a écrit :
> > Return the size directly and drop the extra_sz variable to simplify
> > kdump_extra_elfcorehdr_size(). The two warning paths now fall through
> > to the existing return 0 at the end of the function.
> > 
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> >   arch/powerpc/kexec/file_load_64.c | 6 +-----
> >   1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> > index c3503d698428..d0c544079e03 100644
> > --- a/arch/powerpc/kexec/file_load_64.c
> > +++ b/arch/powerpc/kexec/file_load_64.c
> > @@ -377,16 +377,12 @@ static int load_backup_segment(struct kimage *image, struct kexec_buf *kbuf)
> >   static unsigned int kdump_extra_elfcorehdr_size(struct crash_mem *cmem)
> >   {
> >   #if defined(CONFIG_CRASH_HOTPLUG) && defined(CONFIG_MEMORY_HOTPLUG)
> > -	unsigned int extra_sz = 0;
> > -
> >   	if (CONFIG_CRASH_MAX_MEMORY_RANGES > (unsigned int)PN_XNUM)
> >   		pr_warn("Number of Phdrs %u exceeds max\n", CONFIG_CRASH_MAX_MEMORY_RANGES);
> >   	else if (cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES)
> >   		pr_warn("Configured crash mem ranges may not be enough\n");
> >   	else
> > -		extra_sz = (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr);
> > -
> > -	return extra_sz;
> > +		return (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr);
> 
> I don't understand.
> 
> Previously, when cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES you would
> return 0. Now you will return something different. For instance if
> cmem->nr_ranges is (CONFIG_CRASH_MAX_MEMORY_RANGES + 1) you will return
> (unsigned int)(-1 * sizeof(Elf64_Phdr))

It still returns 0.

When cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES, the else if
branch prints the warning and then falls through to the return 0 at the
end of the function. The final else branch is not entered in that case.

No functional changes are intended.

> >   #endif
> >   	return 0;
> >   }
> 

      reply	other threads:[~2026-07-30 14:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 13:19 [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size() Thorsten Blum
2026-07-30 14:33 ` Christophe Leroy (CS GROUP)
2026-07-30 14:45   ` Thorsten Blum [this message]

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=amtjkfZgkvFACYzE@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=adityag@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=hbathini@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=sourabhjain@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.