* [PATCH 0/2] makedumpfile/ppc64: enable the mem-usage option on ppc64 platform
@ 2017-08-15 7:21 Pingfan Liu
2017-08-15 7:21 ` [PATCH 1/2] makedumpfile/ppc64: set page_offset in get_versiondep_info_ppc64() Pingfan Liu
2017-08-15 7:21 ` [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel Pingfan Liu
0 siblings, 2 replies; 5+ messages in thread
From: Pingfan Liu @ 2017-08-15 7:21 UTC (permalink / raw)
To: kexec; +Cc: Hari Bathini, Atsushi Kumagai
Currently, -mem-usage option can work on x86 and arm, and enable it on ppc64
Pingfan Liu (2):
makedumpfile/ppc64: set page_offset in get_versiondep_info_ppc64()
makedumpfile/ppc64: get the info of mem reserved for crashkernel
arch/ppc64.c | 37 +++++++++++++++++++++++++++++++++++++
makedumpfile.c | 10 ++++++++++
makedumpfile.h | 4 ++++
3 files changed, 51 insertions(+)
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] makedumpfile/ppc64: set page_offset in get_versiondep_info_ppc64()
2017-08-15 7:21 [PATCH 0/2] makedumpfile/ppc64: enable the mem-usage option on ppc64 platform Pingfan Liu
@ 2017-08-15 7:21 ` Pingfan Liu
2017-08-15 7:21 ` [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel Pingfan Liu
1 sibling, 0 replies; 5+ messages in thread
From: Pingfan Liu @ 2017-08-15 7:21 UTC (permalink / raw)
To: kexec; +Cc: Hari Bathini, Atsushi Kumagai
Envalue info->page_offset in get_versiondep_info_ppc64() is a little
misleading. But since show_mem_usage->get_page_offset->get_versiondep_info
needs to get this info, so initialize it in get_versiondep_info_ppc64().
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
arch/ppc64.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/ppc64.c b/arch/ppc64.c
index 6aeab7e..3fd6002 100644
--- a/arch/ppc64.c
+++ b/arch/ppc64.c
@@ -576,6 +576,7 @@ get_versiondep_info_ppc64()
ERRMSG("Can't initialize for vmalloc translation\n");
return FALSE;
}
+ info->page_offset = __PAGE_OFFSET;
return TRUE;
}
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel
2017-08-15 7:21 [PATCH 0/2] makedumpfile/ppc64: enable the mem-usage option on ppc64 platform Pingfan Liu
2017-08-15 7:21 ` [PATCH 1/2] makedumpfile/ppc64: set page_offset in get_versiondep_info_ppc64() Pingfan Liu
@ 2017-08-15 7:21 ` Pingfan Liu
2017-08-17 8:22 ` Atsushi Kumagai
1 sibling, 1 reply; 5+ messages in thread
From: Pingfan Liu @ 2017-08-15 7:21 UTC (permalink / raw)
To: kexec; +Cc: Hari Bathini, Atsushi Kumagai
In kernel, ppc64 does not export the mem layout by ioresource. So we
need to get the mem info for crashkernel from device tree.
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
arch/ppc64.c | 36 ++++++++++++++++++++++++++++++++++++
makedumpfile.c | 10 ++++++++++
makedumpfile.h | 4 ++++
3 files changed, 50 insertions(+)
diff --git a/arch/ppc64.c b/arch/ppc64.c
index 3fd6002..360590e 100644
--- a/arch/ppc64.c
+++ b/arch/ppc64.c
@@ -617,4 +617,40 @@ vaddr_to_paddr_ppc64(unsigned long vaddr)
return ppc64_vtop_level4(vaddr);
}
+int arch_crashkernel_mem_size()
+{
+ const char f_crashsize[] = "/proc/device-tree/chosen/linux,crashkernel-size";
+ const char f_crashbase[] = "/proc/device-tree/chosen/linux,crashkernel-base";
+ unsigned long crashk_sz_be, crashk_sz;
+ unsigned long crashk_base_be, crashk_base;
+ uint swap;
+ FILE *fp, *fpb;
+
+ fp = fopen(f_crashsize, "r");
+ if (!fp) {
+ ERRMSG("Cannot open %s\n", f_crashsize);
+ return FALSE;
+ }
+ fpb = fopen(f_crashbase, "r");
+ if (!fp) {
+ ERRMSG("Cannot open %s\n", f_crashbase);
+ fclose(fp);
+ return FALSE;
+ }
+
+ fread(&crashk_sz_be, sizeof(crashk_sz_be), 1, fp);
+ fread(&crashk_base_be, sizeof(crashk_base_be), 1, fpb);
+ fclose(fp);
+ fclose(fpb);
+ /* dev tree is always big endian */
+ swap = !is_bigendian();
+ crashk_sz = swap64(crashk_sz_be, swap);
+ crashk_base = swap64(crashk_base_be, swap);
+ crash_reserved_mem_nr = 1;
+ crash_reserved_mem[0].start = crashk_base;
+ crash_reserved_mem[0].end = crashk_base + crashk_sz - 1;
+
+ return TRUE;
+}
+
#endif /* powerpc64 */
diff --git a/makedumpfile.c b/makedumpfile.c
index f85003a..c599b91 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -10921,10 +10921,20 @@ static int crashkernel_mem_callback(void *data, int nr,
return 0;
}
+#if !defined(HAVE_ARCH_CRASHKERNEL_MEM_SIZE)
+int arch_crashkernel_mem_size()
+{
+ return FALSE;
+}
+#endif
+
int is_crashkernel_mem_reserved(void)
{
int ret;
+ if (arch_crashkernel_mem_size())
+ return TRUE;
+
ret = iomem_for_each_line("Crash kernel\n",
crashkernel_mem_callback, NULL);
crash_reserved_mem_nr = ret;
diff --git a/makedumpfile.h b/makedumpfile.h
index 8a05794..48c1423 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -987,6 +987,8 @@ unsigned long long vaddr_to_paddr_ppc64(unsigned long vaddr);
#define get_kaslr_offset(X) stub_false()
#define vaddr_to_paddr(X) vaddr_to_paddr_ppc64(X)
#define is_phys_addr(X) stub_true_ul(X)
+
+#define HAVE_ARCH_CRASHKERNEL_MEM_SIZE
#endif /* powerpc64 */
#ifdef __powerpc32__ /* powerpc32 */
@@ -1939,6 +1941,8 @@ int iomem_for_each_line(char *match, int (*callback)(void *data, int nr,
unsigned long base,
unsigned long length),
void *data);
+int is_bigendian(void);
+int arch_crashkernel_mem_size(void);
/*
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel
2017-08-15 7:21 ` [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel Pingfan Liu
@ 2017-08-17 8:22 ` Atsushi Kumagai
2017-08-21 3:16 ` Pingfan Liu
0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Kumagai @ 2017-08-17 8:22 UTC (permalink / raw)
To: Pingfan Liu, kexec@lists.infradead.org; +Cc: Hari Bathini
Hello Pingfan,
>In kernel, ppc64 does not export the mem layout by ioresource. So we
>need to get the mem info for crashkernel from device tree.
>
>Signed-off-by: Pingfan Liu <piliu@redhat.com>
>---
> arch/ppc64.c | 36 ++++++++++++++++++++++++++++++++++++
> makedumpfile.c | 10 ++++++++++
> makedumpfile.h | 4 ++++
> 3 files changed, 50 insertions(+)
>
>diff --git a/arch/ppc64.c b/arch/ppc64.c
>index 3fd6002..360590e 100644
>--- a/arch/ppc64.c
>+++ b/arch/ppc64.c
>@@ -617,4 +617,40 @@ vaddr_to_paddr_ppc64(unsigned long vaddr)
> return ppc64_vtop_level4(vaddr);
> }
>
>+int arch_crashkernel_mem_size()
>+{
>+ const char f_crashsize[] = "/proc/device-tree/chosen/linux,crashkernel-size";
>+ const char f_crashbase[] = "/proc/device-tree/chosen/linux,crashkernel-base";
>+ unsigned long crashk_sz_be, crashk_sz;
>+ unsigned long crashk_base_be, crashk_base;
>+ uint swap;
>+ FILE *fp, *fpb;
>+
>+ fp = fopen(f_crashsize, "r");
>+ if (!fp) {
>+ ERRMSG("Cannot open %s\n", f_crashsize);
>+ return FALSE;
>+ }
>+ fpb = fopen(f_crashbase, "r");
>+ if (!fp) {
>+ ERRMSG("Cannot open %s\n", f_crashbase);
>+ fclose(fp);
>+ return FALSE;
>+ }
>+
>+ fread(&crashk_sz_be, sizeof(crashk_sz_be), 1, fp);
>+ fread(&crashk_base_be, sizeof(crashk_base_be), 1, fpb);
>+ fclose(fp);
>+ fclose(fpb);
>+ /* dev tree is always big endian */
>+ swap = !is_bigendian();
>+ crashk_sz = swap64(crashk_sz_be, swap);
>+ crashk_base = swap64(crashk_base_be, swap);
>+ crash_reserved_mem_nr = 1;
>+ crash_reserved_mem[0].start = crashk_base;
>+ crash_reserved_mem[0].end = crashk_base + crashk_sz - 1;
>+
>+ return TRUE;
>+}
>+
> #endif /* powerpc64 */
>diff --git a/makedumpfile.c b/makedumpfile.c
>index f85003a..c599b91 100644
>--- a/makedumpfile.c
>+++ b/makedumpfile.c
>@@ -10921,10 +10921,20 @@ static int crashkernel_mem_callback(void *data, int nr,
> return 0;
> }
>
>+#if !defined(HAVE_ARCH_CRASHKERNEL_MEM_SIZE)
>+int arch_crashkernel_mem_size()
>+{
>+ return FALSE;
>+}
>+#endif
>+
I hope you follow the scheme for arch dependent code like get_phys_base()
to get rid of such ifdef. Please see makedumpfile.h for details,
my idea is like below:
#ifdef __powerpc64__
#define arch_crashkernel_mem_size() arch_crashkernel_mem_size_ppc64()
#ifdef <others>
#define arch_crashkernel_mem_size() stub_false()
Thanks,
Atsushi Kumagai
> int is_crashkernel_mem_reserved(void)
> {
> int ret;
>
>+ if (arch_crashkernel_mem_size())
>+ return TRUE;
>+
> ret = iomem_for_each_line("Crash kernel\n",
> crashkernel_mem_callback, NULL);
> crash_reserved_mem_nr = ret;
>diff --git a/makedumpfile.h b/makedumpfile.h
>index 8a05794..48c1423 100644
>--- a/makedumpfile.h
>+++ b/makedumpfile.h
>@@ -987,6 +987,8 @@ unsigned long long vaddr_to_paddr_ppc64(unsigned long vaddr);
> #define get_kaslr_offset(X) stub_false()
> #define vaddr_to_paddr(X) vaddr_to_paddr_ppc64(X)
> #define is_phys_addr(X) stub_true_ul(X)
>+
>+#define HAVE_ARCH_CRASHKERNEL_MEM_SIZE
> #endif /* powerpc64 */
>
> #ifdef __powerpc32__ /* powerpc32 */
>@@ -1939,6 +1941,8 @@ int iomem_for_each_line(char *match, int (*callback)(void *data, int nr,
> unsigned long base,
> unsigned long length),
> void *data);
>+int is_bigendian(void);
>+int arch_crashkernel_mem_size(void);
>
>
> /*
>--
>2.7.4
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel
2017-08-17 8:22 ` Atsushi Kumagai
@ 2017-08-21 3:16 ` Pingfan Liu
0 siblings, 0 replies; 5+ messages in thread
From: Pingfan Liu @ 2017-08-21 3:16 UTC (permalink / raw)
To: Atsushi Kumagai; +Cc: Hari Bathini, kexec
----- Original Message -----
> From: "Atsushi Kumagai" <ats-kumagai@wm.jp.nec.com>
> To: "Pingfan Liu" <piliu@redhat.com>, kexec@lists.infradead.org
> Cc: "Hari Bathini" <hbathini@linux.vnet.ibm.com>
> Sent: Thursday, August 17, 2017 4:22:35 PM
> Subject: RE: [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel
>
> Hello Pingfan,
>
> >In kernel, ppc64 does not export the mem layout by ioresource. So we
> >need to get the mem info for crashkernel from device tree.
> >
> >Signed-off-by: Pingfan Liu <piliu@redhat.com>
> >---
> > arch/ppc64.c | 36 ++++++++++++++++++++++++++++++++++++
> > makedumpfile.c | 10 ++++++++++
> > makedumpfile.h | 4 ++++
> > 3 files changed, 50 insertions(+)
> >
> >diff --git a/arch/ppc64.c b/arch/ppc64.c
> >index 3fd6002..360590e 100644
> >--- a/arch/ppc64.c
> >+++ b/arch/ppc64.c
> >@@ -617,4 +617,40 @@ vaddr_to_paddr_ppc64(unsigned long vaddr)
> > return ppc64_vtop_level4(vaddr);
> > }
> >
> >+int arch_crashkernel_mem_size()
> >+{
> >+ const char f_crashsize[] =
> >"/proc/device-tree/chosen/linux,crashkernel-size";
> >+ const char f_crashbase[] =
> >"/proc/device-tree/chosen/linux,crashkernel-base";
> >+ unsigned long crashk_sz_be, crashk_sz;
> >+ unsigned long crashk_base_be, crashk_base;
> >+ uint swap;
> >+ FILE *fp, *fpb;
> >+
> >+ fp = fopen(f_crashsize, "r");
> >+ if (!fp) {
> >+ ERRMSG("Cannot open %s\n", f_crashsize);
> >+ return FALSE;
> >+ }
> >+ fpb = fopen(f_crashbase, "r");
> >+ if (!fp) {
> >+ ERRMSG("Cannot open %s\n", f_crashbase);
> >+ fclose(fp);
> >+ return FALSE;
> >+ }
> >+
> >+ fread(&crashk_sz_be, sizeof(crashk_sz_be), 1, fp);
> >+ fread(&crashk_base_be, sizeof(crashk_base_be), 1, fpb);
> >+ fclose(fp);
> >+ fclose(fpb);
> >+ /* dev tree is always big endian */
> >+ swap = !is_bigendian();
> >+ crashk_sz = swap64(crashk_sz_be, swap);
> >+ crashk_base = swap64(crashk_base_be, swap);
> >+ crash_reserved_mem_nr = 1;
> >+ crash_reserved_mem[0].start = crashk_base;
> >+ crash_reserved_mem[0].end = crashk_base + crashk_sz - 1;
> >+
> >+ return TRUE;
> >+}
> >+
> > #endif /* powerpc64 */
> >diff --git a/makedumpfile.c b/makedumpfile.c
> >index f85003a..c599b91 100644
> >--- a/makedumpfile.c
> >+++ b/makedumpfile.c
> >@@ -10921,10 +10921,20 @@ static int crashkernel_mem_callback(void *data,
> >int nr,
> > return 0;
> > }
> >
> >+#if !defined(HAVE_ARCH_CRASHKERNEL_MEM_SIZE)
> >+int arch_crashkernel_mem_size()
> >+{
> >+ return FALSE;
> >+}
> >+#endif
> >+
>
> I hope you follow the scheme for arch dependent code like get_phys_base()
> to get rid of such ifdef. Please see makedumpfile.h for details,
> my idea is like below:
>
> #ifdef __powerpc64__
> #define arch_crashkernel_mem_size() arch_crashkernel_mem_size_ppc64()
>
> #ifdef <others>
> #define arch_crashkernel_mem_size() stub_false()
>
>
Thanks for review., I will send out V2 to obey the schemem.
Regards,
Pingfan
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-21 3:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 7:21 [PATCH 0/2] makedumpfile/ppc64: enable the mem-usage option on ppc64 platform Pingfan Liu
2017-08-15 7:21 ` [PATCH 1/2] makedumpfile/ppc64: set page_offset in get_versiondep_info_ppc64() Pingfan Liu
2017-08-15 7:21 ` [PATCH 2/2] makedumpfile/ppc64: get the info of mem reserved for crashkernel Pingfan Liu
2017-08-17 8:22 ` Atsushi Kumagai
2017-08-21 3:16 ` Pingfan Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox