linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails
@ 2023-06-08  9:22 Sourabh Jain
  2023-07-03  6:55 ` Sourabh Jain
  0 siblings, 1 reply; 4+ messages in thread
From: Sourabh Jain @ 2023-06-08  9:22 UTC (permalink / raw)
  To: linuxppc-dev, mpe; +Cc: mahesh, Mahesh Salgaonkar, hbathini

If the memory reservation process (memblock_reserve) fails to reserve
the memory, the reserve dump variable retains the dump area size.
Consequently, the size of the dump area calculated for reservation
is displayed in /sys/kernel/fadump/mem_reserved.

To resolve this issue, the reserve dump area size variable is set to 0
if the memblock_reserve fails to reserve memory.

Fixes: 8255da95e545 ("powerpc/fadump: release all the memory above boot memory size")
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
---
 arch/powerpc/kernel/fadump.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index ea0a073abd96..a8f2c3b2fa1e 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -641,6 +641,7 @@ int __init fadump_reserve_mem(void)
 			goto error_out;
 
 		if (memblock_reserve(base, size)) {
+			fw_dump.reserve_dump_area_size = 0;
 			pr_err("Failed to reserve memory!\n");
 			goto error_out;
 		}
-- 
2.40.1


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

* Re: [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails
  2023-06-08  9:22 [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails Sourabh Jain
@ 2023-07-03  6:55 ` Sourabh Jain
  2023-07-03 11:29   ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Sourabh Jain @ 2023-07-03  6:55 UTC (permalink / raw)
  To: linuxppc-dev, mpe; +Cc: mahesh, Mahesh Salgaonkar, hbathini

Hello Michael,

Do you have any feedback or comments regarding this patch?

Thanks,
Sourabh

On 08/06/23 14:52, Sourabh Jain wrote:
> If the memory reservation process (memblock_reserve) fails to reserve
> the memory, the reserve dump variable retains the dump area size.
> Consequently, the size of the dump area calculated for reservation
> is displayed in /sys/kernel/fadump/mem_reserved.
>
> To resolve this issue, the reserve dump area size variable is set to 0
> if the memblock_reserve fails to reserve memory.
>
> Fixes: 8255da95e545 ("powerpc/fadump: release all the memory above boot memory size")
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> ---
>   arch/powerpc/kernel/fadump.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index ea0a073abd96..a8f2c3b2fa1e 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -641,6 +641,7 @@ int __init fadump_reserve_mem(void)
>   			goto error_out;
>   
>   		if (memblock_reserve(base, size)) {
> +			fw_dump.reserve_dump_area_size = 0;
>   			pr_err("Failed to reserve memory!\n");
>   			goto error_out;
>   		}

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

* Re: [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails
  2023-07-03  6:55 ` Sourabh Jain
@ 2023-07-03 11:29   ` Michael Ellerman
  2023-07-03 12:28     ` Sourabh Jain
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2023-07-03 11:29 UTC (permalink / raw)
  To: Sourabh Jain, linuxppc-dev; +Cc: mahesh, Mahesh Salgaonkar, hbathini

Sourabh Jain <sourabhjain@linux.ibm.com> writes:
> Hello Michael,
>
> Do you have any feedback or comments regarding this patch?
>
> Thanks,
> Sourabh
>
> On 08/06/23 14:52, Sourabh Jain wrote:
>> If the memory reservation process (memblock_reserve) fails to reserve
>> the memory, the reserve dump variable retains the dump area size.
>> Consequently, the size of the dump area calculated for reservation
>> is displayed in /sys/kernel/fadump/mem_reserved.
>>
>> To resolve this issue, the reserve dump area size variable is set to 0
>> if the memblock_reserve fails to reserve memory.
>>
>> Fixes: 8255da95e545 ("powerpc/fadump: release all the memory above boot memory size")
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
>> ---
>>   arch/powerpc/kernel/fadump.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
>> index ea0a073abd96..a8f2c3b2fa1e 100644
>> --- a/arch/powerpc/kernel/fadump.c
>> +++ b/arch/powerpc/kernel/fadump.c
>> @@ -641,6 +641,7 @@ int __init fadump_reserve_mem(void)
>>   			goto error_out;
>>   
>>   		if (memblock_reserve(base, size)) {
>> +			fw_dump.reserve_dump_area_size = 0;
>>   			pr_err("Failed to reserve memory!\n");
>>   			goto error_out;
>>   		}

Shouldn't reserve_dump_area_size be set to zero at error_out, which
already clears fadump_enabled?

	return ret;
error_out:
	fw_dump.fadump_enabled = 0;
	return 0;
}


Otherwise the code immediately above will suffer from the same issue
won't it?

		if (fw_dump.ops->fadump_setup_metadata &&
		    (fw_dump.ops->fadump_setup_metadata(&fw_dump) < 0))
			goto error_out;

cheers

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

* Re: [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails
  2023-07-03 11:29   ` Michael Ellerman
@ 2023-07-03 12:28     ` Sourabh Jain
  0 siblings, 0 replies; 4+ messages in thread
From: Sourabh Jain @ 2023-07-03 12:28 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: mahesh, Mahesh Salgaonkar, hbathini


On 03/07/23 16:59, Michael Ellerman wrote:
> Sourabh Jain <sourabhjain@linux.ibm.com> writes:
>> Hello Michael,
>>
>> Do you have any feedback or comments regarding this patch?
>>
>> Thanks,
>> Sourabh
>>
>> On 08/06/23 14:52, Sourabh Jain wrote:
>>> If the memory reservation process (memblock_reserve) fails to reserve
>>> the memory, the reserve dump variable retains the dump area size.
>>> Consequently, the size of the dump area calculated for reservation
>>> is displayed in /sys/kernel/fadump/mem_reserved.
>>>
>>> To resolve this issue, the reserve dump area size variable is set to 0
>>> if the memblock_reserve fails to reserve memory.
>>>
>>> Fixes: 8255da95e545 ("powerpc/fadump: release all the memory above boot memory size")
>>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>>> Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
>>> ---
>>>    arch/powerpc/kernel/fadump.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
>>> index ea0a073abd96..a8f2c3b2fa1e 100644
>>> --- a/arch/powerpc/kernel/fadump.c
>>> +++ b/arch/powerpc/kernel/fadump.c
>>> @@ -641,6 +641,7 @@ int __init fadump_reserve_mem(void)
>>>    			goto error_out;
>>>    
>>>    		if (memblock_reserve(base, size)) {
>>> +			fw_dump.reserve_dump_area_size = 0;
>>>    			pr_err("Failed to reserve memory!\n");
>>>    			goto error_out;
>>>    		}
> Shouldn't reserve_dump_area_size be set to zero at error_out, which
> already clears fadump_enabled?
>
> 	return ret;
> error_out:
> 	fw_dump.fadump_enabled = 0;
> 	return 0;
> }
>
>
> Otherwise the code immediately above will suffer from the same issue
> won't it?
>
> 		if (fw_dump.ops->fadump_setup_metadata &&
> 		    (fw_dump.ops->fadump_setup_metadata(&fw_dump) < 0))
> 			goto error_out;

Agree, resetting fw_dump.reserve_dump_area_size below error_out label is 
better.

Thanks for the review. I will send v2.

Sourabh Jain

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

end of thread, other threads:[~2023-07-03 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08  9:22 [PATCH] powerpc/fadump: reset dump area size variable if memblock reserve fails Sourabh Jain
2023-07-03  6:55 ` Sourabh Jain
2023-07-03 11:29   ` Michael Ellerman
2023-07-03 12:28     ` Sourabh Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).