linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ronit Halder <ronit.crj@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, bp@suse.de,
	dyoung@redhat.com, jroedel@suse.de, krzysiek@podlesie.net,
	msalter@redhat.com, ebiederm@xmission.com,
	akpm@linux-foundation.org, bhe@redhat.com, vgoyal@redhat.com,
	mnfhuang@gmail.com, kexec@lists.infradead.org,
	kirill.shutemov@linux.intel.com, mchehab@osg.samsung.com,
	aarcange@redhat.com, vdavydov@parallels.com,
	dan.j.williams@intel.com, jack@suse.cz, linux-mm@kvack.org,
	Ronit Halder <ronit.crj@gmail.com>
Subject: [RFC 4/4] Enable memory allocation through sysfs interface
Date: Fri, 12 Aug 2016 19:56:52 +0530	[thread overview]
Message-ID: <20160812142652.6299-1-ronit.crj@gmail.com> (raw)
In-Reply-To: <20160812141838.5973-1-ronit.crj@gmail.com>

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2016-08-12 14:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 14:18 [RFC 0/4] Kexec: Enable run time memory resrvation of crash kernel Ronit Halder
2016-08-12 14:20 ` [RFC 1/4] Creating one or two CMA area at Boot time Ronit Halder
2016-08-12 14:21 ` [RFC 2/4] Functions for memory reservation and release Ronit Halder
2016-08-12 14:25 ` [RFC 3/4] Adding a new kernel configuration to enable the feature Ronit Halder
2016-08-12 14:26 ` Ronit Halder [this message]
2016-08-22 10:59 ` [RFC 0/4] Kexec: Enable run time memory resrvation of crash kernel Pratyush Anand
2016-08-23  7:08   ` Xunlei Pang

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=20160812142652.6299-1-ronit.crj@gmail.com \
    --to=ronit.crj@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=bp@suse.de \
    --cc=dan.j.williams@intel.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=jack@suse.cz \
    --cc=jroedel@suse.de \
    --cc=kexec@lists.infradead.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=krzysiek@podlesie.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mchehab@osg.samsung.com \
    --cc=mingo@redhat.com \
    --cc=mnfhuang@gmail.com \
    --cc=msalter@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vdavydov@parallels.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 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).