From: Dave Young <dyoung@redhat.com>
To: holzheu@linux.vnet.ibm.com
Cc: heiko.carstens@de.ibm.com, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, Simon Horman <horms@verge.net.au>,
"Eric W. Biederman" <ebiederm@xmission.com>,
schwidefsky@de.ibm.com, akpm@linux-foundation.org,
Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH v2] kdump: crashk_res init check for /sys/kernel/kexec_crash_size
Date: Wed, 23 Nov 2011 22:03:10 +0800 [thread overview]
Message-ID: <4ECCFD1E.4030908@redhat.com> (raw)
In-Reply-To: <1322055976.10119.17.camel@br98xy6r>
On 11/23/2011 09:46 PM, Michael Holzheu wrote:
> Hi Dave,
>
> On Wed, 2011-11-23 at 21:34 +0800, Dave Young wrote:
>> On 11/23/2011 09:18 PM, Michael Holzheu wrote:
>>
>>> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>>>
>>> Currently it is possible to set the crash_size via the sysfs
>>> /sys/kernel/kexec_crash_size even if no crash kernel memory has
>>> been defined with the "crashkernel" parameter. In this case
>>> "crashk_res" is not initialized and crashk_res.start = crashk_res.end = 0.
>>> Unfortunately resource_size(&crashk_res) returns 1 in this case.
>>> This breaks the s390 implementation of crash_(un)map_reserved_pages().
>>>
>>> To fix the problem the correct "old_size" is now calculated in
>>> crash_shrink_memory(). "old_size is set to "0" if crashk_res is
>>> not initialized. With this change crash_shrink_memory() will do nothing,
>>> when "crashk_res" is not initialized. It will return "0" for
>>> "echo 0 > /sys/kernel/kexec_crash_size" and -EINVAL for
>>> "echo [not zero] > /sys/kernel/kexec_crash_size".
>>>
>>> In addition to that this patch also simplifies the "ret = -EINVAL"
>>> vs. "ret = 0" logic as suggested by Simon Horman.
>>>
>>> Cc: Simon Horman <horms@verge.net.au>
>>> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>>> ---
>>> kernel/kexec.c | 10 ++++------
>>> 1 file changed, 4 insertions(+), 6 deletions(-)
>>>
>>> --- a/kernel/kexec.c
>>> +++ b/kernel/kexec.c
>>> @@ -1131,7 +1131,7 @@ void __weak crash_free_reserved_phys_ran
>>> int crash_shrink_memory(unsigned long new_size)
>>> {
>>> int ret = 0;
>>> - unsigned long start, end;
>>> + unsigned long start, end, old_size;
>>
>>
>> Sorry for jump in a little late, instead of introduce a new variable,
>> why not add something like:
>>
>> if (!end)
>> return -EINVAL;
>
> If the crashkernel parameter is not set, "/sys/kernel/kexec_crash_size"
> returns zero:
>
> cat /sys/kernel/kexec_crash_size
> 0
>
> So I think if we set it again to zero we should *not* return -EINVAL:
Thanks, I missed this case. fair enough.
Reviewed-by: Dave Young <dyoung@redhat.com>
>
> echo 0 > /sys/kernel/kexec_crash_size
> --> Exit code should be zero in this case
>
> Otherwise we would change the current behavior.
>
> And besides of that, I think introducing the "old_size" variable makes
> the code more readable.
>
> Michael
>
>
--
Thanks
Dave
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
WARNING: multiple messages have this Message-ID (diff)
From: Dave Young <dyoung@redhat.com>
To: holzheu@linux.vnet.ibm.com
Cc: heiko.carstens@de.ibm.com, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, Simon Horman <horms@verge.net.au>,
"Eric W. Biederman" <ebiederm@xmission.com>,
schwidefsky@de.ibm.com, akpm@linux-foundation.org,
Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH v2] kdump: crashk_res init check for /sys/kernel/kexec_crash_size
Date: Wed, 23 Nov 2011 22:03:10 +0800 [thread overview]
Message-ID: <4ECCFD1E.4030908@redhat.com> (raw)
In-Reply-To: <1322055976.10119.17.camel@br98xy6r>
On 11/23/2011 09:46 PM, Michael Holzheu wrote:
> Hi Dave,
>
> On Wed, 2011-11-23 at 21:34 +0800, Dave Young wrote:
>> On 11/23/2011 09:18 PM, Michael Holzheu wrote:
>>
>>> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>>>
>>> Currently it is possible to set the crash_size via the sysfs
>>> /sys/kernel/kexec_crash_size even if no crash kernel memory has
>>> been defined with the "crashkernel" parameter. In this case
>>> "crashk_res" is not initialized and crashk_res.start = crashk_res.end = 0.
>>> Unfortunately resource_size(&crashk_res) returns 1 in this case.
>>> This breaks the s390 implementation of crash_(un)map_reserved_pages().
>>>
>>> To fix the problem the correct "old_size" is now calculated in
>>> crash_shrink_memory(). "old_size is set to "0" if crashk_res is
>>> not initialized. With this change crash_shrink_memory() will do nothing,
>>> when "crashk_res" is not initialized. It will return "0" for
>>> "echo 0 > /sys/kernel/kexec_crash_size" and -EINVAL for
>>> "echo [not zero] > /sys/kernel/kexec_crash_size".
>>>
>>> In addition to that this patch also simplifies the "ret = -EINVAL"
>>> vs. "ret = 0" logic as suggested by Simon Horman.
>>>
>>> Cc: Simon Horman <horms@verge.net.au>
>>> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>>> ---
>>> kernel/kexec.c | 10 ++++------
>>> 1 file changed, 4 insertions(+), 6 deletions(-)
>>>
>>> --- a/kernel/kexec.c
>>> +++ b/kernel/kexec.c
>>> @@ -1131,7 +1131,7 @@ void __weak crash_free_reserved_phys_ran
>>> int crash_shrink_memory(unsigned long new_size)
>>> {
>>> int ret = 0;
>>> - unsigned long start, end;
>>> + unsigned long start, end, old_size;
>>
>>
>> Sorry for jump in a little late, instead of introduce a new variable,
>> why not add something like:
>>
>> if (!end)
>> return -EINVAL;
>
> If the crashkernel parameter is not set, "/sys/kernel/kexec_crash_size"
> returns zero:
>
> cat /sys/kernel/kexec_crash_size
> 0
>
> So I think if we set it again to zero we should *not* return -EINVAL:
Thanks, I missed this case. fair enough.
Reviewed-by: Dave Young <dyoung@redhat.com>
>
> echo 0 > /sys/kernel/kexec_crash_size
> --> Exit code should be zero in this case
>
> Otherwise we would change the current behavior.
>
> And besides of that, I think introducing the "old_size" variable makes
> the code more readable.
>
> Michael
>
>
--
Thanks
Dave
next prev parent reply other threads:[~2011-11-23 14:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-23 10:11 [PATCH] kdump: crashk_res init check for /sys/kernel/kexec_crash_size Michael Holzheu
2011-11-23 10:11 ` Michael Holzheu
2011-11-23 10:22 ` Simon Horman
2011-11-23 10:22 ` Simon Horman
2011-11-23 13:18 ` [PATCH v2] " Michael Holzheu
2011-11-23 13:18 ` Michael Holzheu
2011-11-23 13:34 ` Dave Young
2011-11-23 13:34 ` Dave Young
2011-11-23 13:46 ` Michael Holzheu
2011-11-23 13:46 ` Michael Holzheu
2011-11-23 14:03 ` Dave Young [this message]
2011-11-23 14:03 ` Dave Young
2011-11-23 15:01 ` Cong Wang
2011-11-23 15:01 ` Cong Wang
2011-11-24 0:10 ` Simon Horman
2011-11-24 0:10 ` Simon Horman
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=4ECCFD1E.4030908@redhat.com \
--to=dyoung@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=heiko.carstens@de.ibm.com \
--cc=holzheu@linux.vnet.ibm.com \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=vgoyal@redhat.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.