diff options
author | Michael Holzheu <holzheu@linux.vnet.ibm.com> | 2012-01-12 20:20:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-12 23:13:11 -0500 |
commit | 6480e5a0923756b500634d9777ec4189492fbbfe (patch) | |
tree | 0b1d26ce39f9b7cd28a9e82627ee837734f7c3ab | |
parent | a3dd3323058d281abd584b15ad4c5b65064d7a61 (diff) |
kdump: add missing RAM resource in crash_shrink_memory()
When shrinking crashkernel memory using /sys/kernel/kexec_crash_size for
the newly added memory no RAM resource is created at the moment.
Example:
$ cat /proc/iomem
00000000-bfffffff : System RAM
00000000-005b7ac3 : Kernel code
005b7ac4-009743bf : Kernel data
009bb000-00a85c33 : Kernel bss
c0000000-cfffffff : Crash kernel
d0000000-ffffffff : System RAM
$ echo 0 > /sys/kernel/kexec_crash_size
$ cat /proc/iomem
00000000-bfffffff : System RAM
00000000-005b7ac3 : Kernel code
005b7ac4-009743bf : Kernel data
009bb000-00a85c33 : Kernel bss
<<-- here is System RAM missing
d0000000-ffffffff : System RAM
One result of this bug is that the memory chunk can never be set offline
using memory hotplug. With this patch I insert a new "System RAM"
resource for the released memory. Then the upper example looks like the
following:
$ echo 0 > /sys/kernel/kexec_crash_size
$ cat /proc/iomem
00000000-bfffffff : System RAM
00000000-005b7ac3 : Kernel code
005b7ac4-009743bf : Kernel data
009bb000-00a85c33 : Kernel bss
c0000000-cfffffff : System RAM <<-- new rescoure
d0000000-ffffffff : System RAM
And now I can set chunk c0000000-cfffffff offline.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/kexec.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c index 20ed47ae252f..60bf181b3eae 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -1129,6 +1129,7 @@ int crash_shrink_memory(unsigned long new_size) | |||
1129 | { | 1129 | { |
1130 | int ret = 0; | 1130 | int ret = 0; |
1131 | unsigned long start, end; | 1131 | unsigned long start, end; |
1132 | struct resource *ram_res; | ||
1132 | 1133 | ||
1133 | mutex_lock(&kexec_mutex); | 1134 | mutex_lock(&kexec_mutex); |
1134 | 1135 | ||
@@ -1146,6 +1147,12 @@ int crash_shrink_memory(unsigned long new_size) | |||
1146 | goto unlock; | 1147 | goto unlock; |
1147 | } | 1148 | } |
1148 | 1149 | ||
1150 | ram_res = kzalloc(sizeof(*ram_res), GFP_KERNEL); | ||
1151 | if (!ram_res) { | ||
1152 | ret = -ENOMEM; | ||
1153 | goto unlock; | ||
1154 | } | ||
1155 | |||
1149 | start = roundup(start, KEXEC_CRASH_MEM_ALIGN); | 1156 | start = roundup(start, KEXEC_CRASH_MEM_ALIGN); |
1150 | end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN); | 1157 | end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN); |
1151 | 1158 | ||
@@ -1154,7 +1161,15 @@ int crash_shrink_memory(unsigned long new_size) | |||
1154 | 1161 | ||
1155 | if ((start == end) && (crashk_res.parent != NULL)) | 1162 | if ((start == end) && (crashk_res.parent != NULL)) |
1156 | release_resource(&crashk_res); | 1163 | release_resource(&crashk_res); |
1164 | |||
1165 | ram_res->start = end; | ||
1166 | ram_res->end = crashk_res.end; | ||
1167 | ram_res->flags = IORESOURCE_BUSY | IORESOURCE_MEM; | ||
1168 | ram_res->name = "System RAM"; | ||
1169 | |||
1157 | crashk_res.end = end - 1; | 1170 | crashk_res.end = end - 1; |
1171 | |||
1172 | insert_resource(&iomem_resource, ram_res); | ||
1158 | crash_unmap_reserved_pages(); | 1173 | crash_unmap_reserved_pages(); |
1159 | 1174 | ||
1160 | unlock: | 1175 | unlock: |