From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Vivek Goyal <vgoyal@redhat.com>, Haren Myneni <hbabu@us.ibm.com>,
Eric Biederman <ebiederm@xmission.com>,
Neil Horman <nhorman@tuxdriver.com>,
Cong Wang <amwang@redhat.com>,
kexec@lists.infradead.org
Subject: [PATCH 3/5] Support second memory region in crash_shrink_memory()
Date: Thu, 22 Apr 2010 18:23:10 +0200 [thread overview]
Message-ID: <1271953392-6324-4-git-send-email-v.mayatskih@gmail.com> (raw)
In-Reply-To: <1271953392-6324-1-git-send-email-v.mayatskih@gmail.com>
This patch changes crash_shrink_memory() to work with previosly added
memory region also. When shrink occurs, second region is shrunk first.
Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>
---
kernel/kexec.c | 55 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index b8fd6eb..dfaa01e 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1117,10 +1117,36 @@ static void free_reserved_phys_range(unsigned long begin, unsigned long end)
}
}
+int crash_shrink_region(struct resource *crashk, unsigned long new_size)
+{
+ unsigned long start, end, size;
+
+ start = crashk->start;
+ end = crashk->end;
+ size = end - start + 1;
+
+ if (!size || new_size == size) /* Nothing to free */
+ return 0;
+
+ if (new_size > size)
+ return -EINVAL;
+
+ start = roundup(start, PAGE_SIZE);
+ end = roundup(start + new_size, PAGE_SIZE);
+
+ free_reserved_phys_range(end, crashk->end);
+
+ if (start == end)
+ release_resource(crashk);
+ crashk->end = end - 1;
+
+ return 0;
+}
+
int crash_shrink_memory(unsigned long new_size)
{
int ret = 0;
- unsigned long start, end;
+ unsigned long crash_size, low_size;
mutex_lock(&kexec_mutex);
@@ -1128,26 +1154,25 @@ int crash_shrink_memory(unsigned long new_size)
ret = -ENOENT;
goto unlock;
}
- start = crashk_res.start;
- end = crashk_res.end;
- if (new_size >= end - start + 1) {
+ crash_size = low_size = crashk_res.end - crashk_res.start + 1;
+ crash_size += crashk_res_hi.end - crashk_res_hi.start + 1;
+
+ if (crash_size == new_size)
+ goto unlock;
+ if (crash_size < new_size) {
ret = -EINVAL;
- if (new_size == end - start + 1)
- ret = 0;
goto unlock;
}
- start = roundup(start, PAGE_SIZE);
- end = roundup(start + new_size, PAGE_SIZE);
-
- free_reserved_phys_range(end, crashk_res.end);
-
- if (start == end) {
- crashk_res.end = end;
- release_resource(&crashk_res);
+ if (new_size < low_size) {
+ /* Reap crashk_res_hi */
+ ret = crash_shrink_region(&crashk_res_hi, 0);
+ if (ret)
+ goto unlock;
+ ret = crash_shrink_region(&crashk_res, new_size);
} else
- crashk_res.end = end - 1;
+ ret = crash_shrink_region(&crashk_res_hi, new_size - low_size);
unlock:
mutex_unlock(&kexec_mutex);
--
1.7.0.1
next prev parent reply other threads:[~2010-04-22 16:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 16:23 [PATCH 0/5] Add second memory region for crash kernel Vitaly Mayatskikh
2010-04-22 16:23 ` [PATCH 1/5] Introduce second memory resource " Vitaly Mayatskikh
2010-04-22 16:23 ` [PATCH 2/5] Modify parse_crashkernel* for new syntax Vitaly Mayatskikh
2010-04-22 16:23 ` Vitaly Mayatskikh [this message]
2010-04-22 16:23 ` [PATCH 4/5] x86: use second memory region for dump-capture kernel Vitaly Mayatskikh
2010-04-22 16:23 ` [PATCH 5/5] kexec: update documentation Vitaly Mayatskikh
2010-04-22 22:07 ` [PATCH 0/5] Add second memory region for crash kernel Eric W. Biederman
2010-04-22 22:37 ` H. Peter Anvin
2010-04-22 22:45 ` Vivek Goyal
2010-04-23 0:48 ` Eric W. Biederman
2010-04-23 5:21 ` Cong Wang
2010-04-23 5:42 ` Eric W. Biederman
2010-04-23 6:43 ` Vitaly Mayatskikh
2010-04-23 14:44 ` Vivek Goyal
2010-04-23 7:08 ` Vitaly Mayatskikh
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=1271953392-6324-4-git-send-email-v.mayatskih@gmail.com \
--to=v.mayatskih@gmail.com \
--cc=amwang@redhat.com \
--cc=ebiederm@xmission.com \
--cc=hbabu@us.ibm.com \
--cc=hpa@zytor.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nhorman@tuxdriver.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®