kexec: premit reduction of the reserved memory size
Implement shrinking the reserved memory for crash kernel, if it is more than enough. For example, if you have already reserved 128M, now you just want 100M, you can do: # echo $((100*1024*1024)) > /sys/kernel/kexec_crash_size Note, you can only do this before loading the crash kernel. Signed-off-by: WANG Cong <amwang@redhat.com> Cc: Neil Horman <nhorman@redhat.com> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
1f2c19f8c9
commit
06a7f71124
@@ -100,6 +100,26 @@ static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
|
||||
}
|
||||
KERNEL_ATTR_RO(kexec_crash_loaded);
|
||||
|
||||
static ssize_t kexec_crash_size_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%zu\n", crash_get_memory_size());
|
||||
}
|
||||
static ssize_t kexec_crash_size_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
unsigned long cnt;
|
||||
int ret;
|
||||
|
||||
if (strict_strtoul(buf, 0, &cnt))
|
||||
return -EINVAL;
|
||||
|
||||
ret = crash_shrink_memory(cnt);
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
KERNEL_ATTR_RW(kexec_crash_size);
|
||||
|
||||
static ssize_t vmcoreinfo_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
@@ -147,6 +167,7 @@ static struct attribute * kernel_attrs[] = {
|
||||
#ifdef CONFIG_KEXEC
|
||||
&kexec_loaded_attr.attr,
|
||||
&kexec_crash_loaded_attr.attr,
|
||||
&kexec_crash_size_attr.attr,
|
||||
&vmcoreinfo_attr.attr,
|
||||
#endif
|
||||
NULL
|
||||
|
Reference in New Issue
Block a user