* [Patch v2 1/3] take the segment adding out of locate_mem_hole functions
@ 2014-09-09 11:36 Baoquan He
2014-09-09 11:36 ` [Patch v2 2/3] check if crashk_res_low exists when exclude it from crash mem ranges Baoquan He
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Baoquan He @ 2014-09-09 11:36 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, vgoyal, ebiederm, tglx, mingo, Baoquan He
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>
---
include/linux/kexec.h | 1 +
kernel/kexec.c | 29 ++++++++---------------------
2 files changed, 9 insertions(+), 21 deletions(-)
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 4b2a0e1..9d957b7 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -178,6 +178,7 @@ struct kexec_buf {
struct kimage *image;
char *buffer;
unsigned long bufsz;
+ unsigned long mem;
unsigned long memsz;
unsigned long buf_align;
unsigned long buf_min;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 2bee072..63bc3cd 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -2016,22 +2016,6 @@ static int __init crash_save_vmcoreinfo_init(void)
subsys_initcall(crash_save_vmcoreinfo_init);
#ifdef CONFIG_KEXEC_FILE
-static int __kexec_add_segment(struct kimage *image, char *buf,
- unsigned long bufsz, unsigned long mem,
- unsigned long memsz)
-{
- struct kexec_segment *ksegment;
-
- ksegment = &image->segment[image->nr_segments];
- ksegment->kbuf = buf;
- ksegment->bufsz = bufsz;
- ksegment->mem = mem;
- ksegment->memsz = memsz;
- image->nr_segments++;
-
- return 0;
-}
-
static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
struct kexec_buf *kbuf)
{
@@ -2064,8 +2048,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
} while (1);
/* If we are here, we found a suitable memory range */
- __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
- kbuf->memsz);
+ kbuf->mem = temp_start;
/* Success, stop navigating through remaining System RAM ranges */
return 1;
@@ -2099,8 +2082,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
} while (1);
/* If we are here, we found a suitable memory range */
- __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
- kbuf->memsz);
+ kbuf->mem = temp_start;
/* Success, stop navigating through remaining System RAM ranges */
return 1;
@@ -2187,7 +2169,12 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
}
/* Found a suitable memory range */
- ksegment = &image->segment[image->nr_segments - 1];
+ ksegment = &image->segment[image->nr_segments];
+ ksegment->kbuf = kbuf->buffer;
+ ksegment->bufsz = kbuf->bufsz;
+ ksegment->mem = kbuf->mem;
+ ksegment->memsz = kbuf->memsz;
+ image->nr_segments++;
*load_addr = ksegment->mem;
return 0;
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Patch v2 2/3] check if crashk_res_low exists when exclude it from crash mem ranges
2014-09-09 11:36 [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
@ 2014-09-09 11:36 ` Baoquan He
2014-09-09 11:36 ` [Patch v2 3/3] kexec: remove the unused function parameter Baoquan He
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2014-09-09 11:36 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, vgoyal, ebiederm, tglx, mingo, Baoquan He
Add a check if crashk_res_low exists just like GART region does. If
crashk_res_low doesn't exist, calling exclude_mem_range is unnecessary.
Meanwhile, since crashk_res_low has been initialized at definition, it's
safe just use "if (crashk_low_res.end)" to check if it's exist. And this
can make it consistent with other places of check.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
arch/x86/kernel/crash.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index a618fcd..f5ab56d 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -237,7 +237,7 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced,
ced->max_nr_ranges++;
/* If crashk_low_res is not 0, another range split possible */
- if (crashk_low_res.end != 0)
+ if (crashk_low_res.end)
ced->max_nr_ranges++;
}
@@ -335,9 +335,11 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced,
if (ret)
return ret;
- ret = exclude_mem_range(cmem, crashk_low_res.start, crashk_low_res.end);
- if (ret)
- return ret;
+ if (crashk_low_res.end) {
+ ret = exclude_mem_range(cmem, crashk_low_res.start, crashk_low_res.end);
+ if (ret)
+ return ret;
+ }
/* Exclude GART region */
if (ced->gart_end) {
--
1.8.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Patch v2 3/3] kexec: remove the unused function parameter
2014-09-09 11:36 [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
2014-09-09 11:36 ` [Patch v2 2/3] check if crashk_res_low exists when exclude it from crash mem ranges Baoquan He
@ 2014-09-09 11:36 ` Baoquan He
2014-09-10 8:44 ` [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
2014-09-10 15:20 ` Vivek Goyal
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2014-09-09 11:36 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, vgoyal, ebiederm, tglx, mingo, Baoquan He
This is a cleanup. In function parse_crashkernel_suffix, the
parameter crash_base is not used. So here remove it.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
kernel/kexec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 63bc3cd..2abf9f6 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1759,7 +1759,6 @@ static __initdata char *suffix_tbl[] = {
*/
static int __init parse_crashkernel_suffix(char *cmdline,
unsigned long long *crash_size,
- unsigned long long *crash_base,
const char *suffix)
{
char *cur = cmdline;
@@ -1848,7 +1847,7 @@ static int __init __parse_crashkernel(char *cmdline,
if (suffix)
return parse_crashkernel_suffix(ck_cmdline, crash_size,
- crash_base, suffix);
+ suffix);
/*
* if the commandline contains a ':', then that's the extended
* syntax -- if not, it must be the classic syntax
--
1.8.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Patch v2 1/3] take the segment adding out of locate_mem_hole functions
2014-09-09 11:36 [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
2014-09-09 11:36 ` [Patch v2 2/3] check if crashk_res_low exists when exclude it from crash mem ranges Baoquan He
2014-09-09 11:36 ` [Patch v2 3/3] kexec: remove the unused function parameter Baoquan He
@ 2014-09-10 8:44 ` Baoquan He
2014-09-10 15:20 ` Vivek Goyal
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2014-09-10 8:44 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, vgoyal, ebiederm, tglx, mingo, akpm
Sorry, CC this patchset to Andrew.
On 09/09/14 at 07:36pm, Baoquan He wrote:
> 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>
> ---
> include/linux/kexec.h | 1 +
> kernel/kexec.c | 29 ++++++++---------------------
> 2 files changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 4b2a0e1..9d957b7 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -178,6 +178,7 @@ struct kexec_buf {
> struct kimage *image;
> char *buffer;
> unsigned long bufsz;
> + unsigned long mem;
> unsigned long memsz;
> unsigned long buf_align;
> unsigned long buf_min;
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index 2bee072..63bc3cd 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -2016,22 +2016,6 @@ static int __init crash_save_vmcoreinfo_init(void)
> subsys_initcall(crash_save_vmcoreinfo_init);
>
> #ifdef CONFIG_KEXEC_FILE
> -static int __kexec_add_segment(struct kimage *image, char *buf,
> - unsigned long bufsz, unsigned long mem,
> - unsigned long memsz)
> -{
> - struct kexec_segment *ksegment;
> -
> - ksegment = &image->segment[image->nr_segments];
> - ksegment->kbuf = buf;
> - ksegment->bufsz = bufsz;
> - ksegment->mem = mem;
> - ksegment->memsz = memsz;
> - image->nr_segments++;
> -
> - return 0;
> -}
> -
> static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
> struct kexec_buf *kbuf)
> {
> @@ -2064,8 +2048,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
> } while (1);
>
> /* If we are here, we found a suitable memory range */
> - __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
> - kbuf->memsz);
> + kbuf->mem = temp_start;
>
> /* Success, stop navigating through remaining System RAM ranges */
> return 1;
> @@ -2099,8 +2082,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
> } while (1);
>
> /* If we are here, we found a suitable memory range */
> - __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
> - kbuf->memsz);
> + kbuf->mem = temp_start;
>
> /* Success, stop navigating through remaining System RAM ranges */
> return 1;
> @@ -2187,7 +2169,12 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
> }
>
> /* Found a suitable memory range */
> - ksegment = &image->segment[image->nr_segments - 1];
> + ksegment = &image->segment[image->nr_segments];
> + ksegment->kbuf = kbuf->buffer;
> + ksegment->bufsz = kbuf->bufsz;
> + ksegment->mem = kbuf->mem;
> + ksegment->memsz = kbuf->memsz;
> + image->nr_segments++;
> *load_addr = ksegment->mem;
> return 0;
> }
> --
> 1.8.5.3
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch v2 1/3] take the segment adding out of locate_mem_hole functions
2014-09-09 11:36 [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
` (2 preceding siblings ...)
2014-09-10 8:44 ` [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
@ 2014-09-10 15:20 ` Vivek Goyal
3 siblings, 0 replies; 5+ messages in thread
From: Vivek Goyal @ 2014-09-10 15:20 UTC (permalink / raw)
To: Baoquan He; +Cc: linux-kernel, hpa, ebiederm, tglx, mingo, Andrew Morton
On Tue, Sep 09, 2014 at 07:36:18PM +0800, Baoquan He wrote:
> 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>
Bao,
These 3 patches look good to me. I am assuming you have tested these
to make sure nothing is broken.
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Thanks
Vivek
> ---
> include/linux/kexec.h | 1 +
> kernel/kexec.c | 29 ++++++++---------------------
> 2 files changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 4b2a0e1..9d957b7 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -178,6 +178,7 @@ struct kexec_buf {
> struct kimage *image;
> char *buffer;
> unsigned long bufsz;
> + unsigned long mem;
> unsigned long memsz;
> unsigned long buf_align;
> unsigned long buf_min;
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index 2bee072..63bc3cd 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -2016,22 +2016,6 @@ static int __init crash_save_vmcoreinfo_init(void)
> subsys_initcall(crash_save_vmcoreinfo_init);
>
> #ifdef CONFIG_KEXEC_FILE
> -static int __kexec_add_segment(struct kimage *image, char *buf,
> - unsigned long bufsz, unsigned long mem,
> - unsigned long memsz)
> -{
> - struct kexec_segment *ksegment;
> -
> - ksegment = &image->segment[image->nr_segments];
> - ksegment->kbuf = buf;
> - ksegment->bufsz = bufsz;
> - ksegment->mem = mem;
> - ksegment->memsz = memsz;
> - image->nr_segments++;
> -
> - return 0;
> -}
> -
> static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
> struct kexec_buf *kbuf)
> {
> @@ -2064,8 +2048,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
> } while (1);
>
> /* If we are here, we found a suitable memory range */
> - __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
> - kbuf->memsz);
> + kbuf->mem = temp_start;
>
> /* Success, stop navigating through remaining System RAM ranges */
> return 1;
> @@ -2099,8 +2082,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
> } while (1);
>
> /* If we are here, we found a suitable memory range */
> - __kexec_add_segment(image, kbuf->buffer, kbuf->bufsz, temp_start,
> - kbuf->memsz);
> + kbuf->mem = temp_start;
>
> /* Success, stop navigating through remaining System RAM ranges */
> return 1;
> @@ -2187,7 +2169,12 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
> }
>
> /* Found a suitable memory range */
> - ksegment = &image->segment[image->nr_segments - 1];
> + ksegment = &image->segment[image->nr_segments];
> + ksegment->kbuf = kbuf->buffer;
> + ksegment->bufsz = kbuf->bufsz;
> + ksegment->mem = kbuf->mem;
> + ksegment->memsz = kbuf->memsz;
> + image->nr_segments++;
> *load_addr = ksegment->mem;
> return 0;
> }
> --
> 1.8.5.3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-10 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 11:36 [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
2014-09-09 11:36 ` [Patch v2 2/3] check if crashk_res_low exists when exclude it from crash mem ranges Baoquan He
2014-09-09 11:36 ` [Patch v2 3/3] kexec: remove the unused function parameter Baoquan He
2014-09-10 8:44 ` [Patch v2 1/3] take the segment adding out of locate_mem_hole functions Baoquan He
2014-09-10 15:20 ` Vivek Goyal
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).