aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaoquan He <bhe@redhat.com>2014-10-13 18:53:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 20:18:21 -0400
commit669280a152ce5144321c0e511498877383f34393 (patch)
treed8eb93dc6e5ab9f3efcaede3375c55e066b44a51
parent887f4f8666960dcf8c13d516ff3e4311353f3206 (diff)
kexec: take the segment adding out of locate_mem_hole functions
In locate_mem_hole functions, a memory hole is located and added as kexec_segment. But from the name of locate_mem_hole, it should only take responsibility of searching a available memory hole to contain data of a specified size. So in this patch add a new field 'mem' into kexec_buf, then take that kexec segment adding code out of locate_mem_hole_top_down and locate_mem_hole_bottom_up. This make clear of the functionality of locate_mem_hole just like it declars to do. And by this locate_mem_hole_callback chould be used later if anyone want to locate a memory hole for other use. Meanwhile Vivek suggested opening code function __kexec_add_segment(), that way we have to retreive ksegment pointer once and it is easy to read. So just do it in this patch and remove __kexec_add_segment() since no one use it anymore. Signed-off-by: Baoquan He <bhe@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/kexec.h1
-rw-r--r--kernel/kexec.c29
2 files changed, 9 insertions, 21 deletions
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 4b2a0e11cc5b..9d957b7ae095 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -178,6 +178,7 @@ struct kexec_buf {
178 struct kimage *image; 178 struct kimage *image;
179 char *buffer; 179 char *buffer;
180 unsigned long bufsz; 180 unsigned long bufsz;
181 unsigned long mem;
181 unsigned long memsz; 182 unsigned long memsz;
182 unsigned long buf_align; 183 unsigned long buf_align;
183 unsigned long buf_min; 184 unsigned long buf_min;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 2bee072268d9..63bc3cdfb629 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -2016,22 +2016,6 @@ static int __init crash_save_vmcoreinfo_init(void)
2016subsys_initcall(crash_save_vmcoreinfo_init); 2016subsys_initcall(crash_save_vmcoreinfo_init);
2017 2017
2018#ifdef CONFIG_KEXEC_FILE 2018#ifdef CONFIG_KEXEC_FILE
2019static int __kexec_add_segment(struct kimage *image, char *buf,
2020 unsigned long bufsz, unsigned long mem,
2021 unsigned long memsz)
2022{
2023 struct kexec_segment *ksegment;
2024
2025 ksegment = &image->segment[image->nr_segments];
2026 ksegment->kbuf = buf;
2027 ksegment->bufsz = bufsz;
2028 ksegment->mem = mem;
2029 ksegment->memsz = memsz;
2030 image->nr_segments++;
2031
2032 return 0;
2033}
2034
2035static int locate_mem_hole_top_down(unsigned long start, unsigned long end, 2019static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
2036 struct kexec_buf *kbuf) 2020 struct kexec_buf *kbuf)
2037{ 2021{
@@ -2064,8 +2048,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
2064 } while (1); 2048 } while (1);
2065 2049
2066 /* If we are here, we found a suitable memory range */ 2050 /* If we are here, we found a suitable memory range */
2067 __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start, 2051 kbuf->mem = temp_start;
2068 kbuf->memsz);
2069 2052
2070 /* Success, stop navigating through remaining System RAM ranges */ 2053 /* Success, stop navigating through remaining System RAM ranges */
2071 return 1; 2054 return 1;
@@ -2099,8 +2082,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
2099 } while (1); 2082 } while (1);
2100 2083
2101 /* If we are here, we found a suitable memory range */ 2084 /* If we are here, we found a suitable memory range */
2102 __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start, 2085 kbuf->mem = temp_start;
2103 kbuf->memsz);
2104 2086
2105 /* Success, stop navigating through remaining System RAM ranges */ 2087 /* Success, stop navigating through remaining System RAM ranges */
2106 return 1; 2088 return 1;
@@ -2187,7 +2169,12 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
2187 } 2169 }
2188 2170
2189 /* Found a suitable memory range */ 2171 /* Found a suitable memory range */
2190 ksegment = &image->segment[image->nr_segments - 1]; 2172 ksegment = &image->segment[image->nr_segments];
2173 ksegment->kbuf = kbuf->buffer;
2174 ksegment->bufsz = kbuf->bufsz;
2175 ksegment->mem = kbuf->mem;
2176 ksegment->memsz = kbuf->memsz;
2177 image->nr_segments++;
2191 *load_addr = ksegment->mem; 2178 *load_addr = ksegment->mem;
2192 return 0; 2179 return 0;
2193} 2180}