LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size()
@ 2026-07-30 13:19 Thorsten Blum
  2026-07-30 14:33 ` Christophe Leroy (CS GROUP)
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-07-30 13:19 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Sourabh Jain, Aditya Gupta,
	Hari Bathini
  Cc: Thorsten Blum, linuxppc-dev, linux-kernel

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);
 #endif
 	return 0;
 }


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

* Re: [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size()
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-07-30 14:33 UTC (permalink / raw)
  To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Sourabh Jain, Aditya Gupta, Hari Bathini
  Cc: linuxppc-dev, linux-kernel



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))

>   #endif
>   	return 0;
>   }



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

* Re: [PATCH] powerpc/kexec: Simplify kdump_extra_elfcorehdr_size()
  2026-07-30 14:33 ` Christophe Leroy (CS GROUP)
@ 2026-07-30 14:45   ` Thorsten Blum
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-07-30 14:45 UTC (permalink / raw)
  To: Christophe Leroy (CS GROUP)
  Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Sourabh Jain, Aditya Gupta, Hari Bathini, linuxppc-dev,
	linux-kernel

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;
> >   }
> 


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

end of thread, other threads:[~2026-07-30 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox