Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1461202
| From | Ronit Halder <ronit.crj@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC 4/4] Enable memory allocation through sysfs interface |
| Date | 2016-08-12 16:30 +0200 |
| Message-ID | <s5lDc-2Nj-25@gated-at.bofh.it> (permalink) |
| References | <s5ltv-2Ka-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Modify the sysfs entry "kernel/kexec_crash_size" to allocate or
release memory at run time. The memory size will be written to
the entry in MB. If the user uses high memory (in x86_64). Then
size will be only set for high memory. The low memory will be
allocated automatically. If the size set is zero, the both the
allocated region in low and high memory will be released.
Signed-off-by: Ronit Halder <ronit.crj@gmail.com>
---
kernel/ksysfs.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index e83b264..4cc286d 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -116,10 +116,31 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj,
{
unsigned long cnt;
int ret;
+ int size;
if (kstrtoul(buf, 0, &cnt))
return -EINVAL;
-
+#ifdef CONFIG_KEXEC_CMA
+#ifdef CONFIG_X86
+ size = cnt << 20;
+ if (cnt == 0) {
+ crash_free_memory_low();
+ ret = crash_free_memory(crash_get_memory_size());
+ } else if (cnt > 0) {
+ if (!crash_get_memory_size_low() && crash_alloc_memory_low())
+ return -ENOMEM;
+ ret = crash_free_memory(crash_get_memory_size());
+ if (ret)
+ return ret;
+ ret = crash_alloc_memory(size);
+ if (ret)
+ return ret;
+ } else {
+ return -EINVAL;
+ }
+ return count;
+#endif
+#endif
ret = crash_shrink_memory(cnt);
return ret < 0 ? ret : count;
}
--
2.9.0.GIT
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC 0/4] Kexec: Enable run time memory resrvation of crash kernel Ronit Halder <ronit.crj@gmail.com> - 2016-08-12 16:20 +0200
[RFC 2/4] Functions for memory reservation and release Ronit Halder <ronit.crj@gmail.com> - 2016-08-12 16:30 +0200
[RFC 1/4] Creating one or two CMA area at Boot time Ronit Halder <ronit.crj@gmail.com> - 2016-08-12 16:30 +0200
[RFC 4/4] Enable memory allocation through sysfs interface Ronit Halder <ronit.crj@gmail.com> - 2016-08-12 16:30 +0200
[RFC 3/4] Adding a new kernel configuration to enable the feature Ronit Halder <ronit.crj@gmail.com> - 2016-08-12 16:30 +0200
Re: [RFC 0/4] Kexec: Enable run time memory resrvation of crash kernel Pratyush Anand <panand@redhat.com> - 2016-08-22 13:00 +0200
Re: [RFC 0/4] Kexec: Enable run time memory resrvation of crash kernel Xunlei Pang <xpang@redhat.com> - 2016-08-23 09:20 +0200
csiph-web