From: Olaf Hering <olaf@aepfle.de>
To: kexec@lists.infradead.org
Subject: [PATCH 1/2] kexec_newkernel_phys and kexec_newkernel_memsz
Date: Fri, 18 Jan 2013 20:41:50 +0100 [thread overview]
Message-ID: <20130118194150.GA15372@aepfle.de> (raw)
In-Reply-To: <20130118163809.GA23530@aepfle.de>
This adds sysfs entries /sys/kernel/kexec_newkernel_phys and
/sys/kernel/kexec_newkernel_memsz. Both are supposed to be passed to a
balloon driver.
---
include/linux/kexec.h | 5 +++++
kernel/kexec.c | 24 ++++++++++++++++++++++++
kernel/ksysfs.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index d0b8458..3a317b6 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -203,6 +203,11 @@ int crash_shrink_memory(unsigned long new_size);
size_t crash_get_memory_size(void);
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
+unsigned long kexec_newkernel_get_phys(void);
+void kexec_newkernel_set_phys(unsigned long phys);
+unsigned long kexec_newkernel_get_memsz(void);
+void kexec_newkernel_set_memsz(unsigned long memsz);
+
#else /* !CONFIG_KEXEC */
struct pt_regs;
struct task_struct;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 5e4bd78..9e421a8 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -38,6 +38,9 @@
#include <asm/io.h>
#include <asm/sections.h>
+static unsigned long kexec_newkernel_phys;
+static unsigned long kexec_newkernel_memsz;
+
/* Per cpu memory for storing cpu states in case of system crash. */
note_buf_t __percpu *crash_notes;
@@ -62,6 +65,27 @@ int kexec_should_crash(struct task_struct *p)
return 0;
}
+unsigned long kexec_newkernel_get_phys(void)
+{
+ return kexec_newkernel_phys;
+}
+
+void kexec_newkernel_set_phys(unsigned long phys)
+{
+ printk("%s: kexec_newkernel_phys %lx -> %lx\n", __func__, kexec_newkernel_phys, phys);
+ kexec_newkernel_phys = phys;
+}
+
+unsigned long kexec_newkernel_get_memsz(void)
+{
+ return kexec_newkernel_memsz;
+}
+
+void kexec_newkernel_set_memsz(unsigned long memsz)
+{
+ printk("%s: kexec_newkernel_mensz %lx -> %lx\n", __func__, kexec_newkernel_memsz, memsz);
+ kexec_newkernel_memsz = memsz;
+}
/*
* When kexec transitions to the new kernel there is a one-to-one
* mapping between physical and virtual addresses. On processors
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 6ada93c..0660e40 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -121,6 +121,44 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj,
}
KERNEL_ATTR_RW(kexec_crash_size);
+static ssize_t kexec_newkernel_phys_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%zu\n", kexec_newkernel_get_phys());
+}
+static ssize_t kexec_newkernel_phys_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
+{
+ unsigned long phys;
+
+ if (strict_strtoul(buf, 0, &phys))
+ return -EINVAL;
+
+ kexec_newkernel_set_phys(phys);
+ return count;
+}
+KERNEL_ATTR_RW(kexec_newkernel_phys);
+
+static ssize_t kexec_newkernel_memsz_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%zu\n", kexec_newkernel_get_memsz());
+}
+static ssize_t kexec_newkernel_memsz_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
+{
+ unsigned long memsz;
+
+ if (strict_strtoul(buf, 0, &memsz))
+ return -EINVAL;
+
+ kexec_newkernel_set_memsz(memsz);
+ return count;
+}
+KERNEL_ATTR_RW(kexec_newkernel_memsz);
+
static ssize_t vmcoreinfo_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -194,6 +232,8 @@ static struct attribute * kernel_attrs[] = {
&kexec_loaded_attr.attr,
&kexec_crash_loaded_attr.attr,
&kexec_crash_size_attr.attr,
+ &kexec_newkernel_phys_attr.attr,
+ &kexec_newkernel_memsz_attr.attr,
&vmcoreinfo_attr.attr,
#endif
&rcu_expedited_attr.attr,
--
1.8.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2013-01-18 19:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-18 16:38 getting memory footprint of new kernel Olaf Hering
2013-01-18 19:41 ` Olaf Hering [this message]
2013-01-18 19:44 ` [PATCH 2/2] register_balloon_populate_range Olaf Hering
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=20130118194150.GA15372@aepfle.de \
--to=olaf@aepfle.de \
--cc=kexec@lists.infradead.org \
/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.