All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs
@ 2021-06-08  3:15 Pingfan Liu
  2021-06-08  6:06 ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 5+ messages in thread
From: Pingfan Liu @ 2021-06-08  3:15 UTC (permalink / raw)
  To: kexec; +Cc: Pingfan Liu, Kazuhito Hagio

On arm64, memory section size changes due to the kernel commit
f0b13ee23241 ("arm64/sparsemem: reduce SECTION_SIZE_BITS")

To tackle the compatibility, it is safe to read this info from sysfs
"/sys/devices/system/memory/block_size_bytes"

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Cc: Kazuhito Hagio <k-hagio-ab@nec.com>
To: kexec@lists.infradead.org
---
 arch/arm64.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm64.c b/arch/arm64.c
index 1072178..2f6f5cf 100644
--- a/arch/arm64.c
+++ b/arch/arm64.c
@@ -424,6 +424,11 @@ get_page_offset_arm64(void)
 int
 get_machdep_info_arm64(void)
 {
+	const char sys_path_section_sz[] = "/sys/devices/system/memory/block_size_bytes";
+	char memsection_sz_str[64] = { 0 };
+	unsigned long memsection_sz = 0;
+	FILE *fp;
+
 	/* Check if va_bits is still not initialized. If still 0, call
 	 * get_versiondep_info() to initialize the same.
 	 */
@@ -451,7 +456,21 @@ get_machdep_info_arm64(void)
 	}
 
 	kimage_voffset = NUMBER(kimage_voffset);
-	info->section_size_bits = SECTIONS_SIZE_BITS;
+
+	fp = fopen(sys_path_section_sz, "r");
+	if (fp) {
+		int i;
+
+		fread(&memsection_sz_str, 64, 1, fp);
+		fclose(fp);
+		memsection_sz = strtol(memsection_sz_str, NULL, 16);
+		for (i = -1; memsection_sz != 0; i++)
+			memsection_sz >>= 1;
+		info->section_size_bits = i;
+	}
+	else {
+		info->section_size_bits = SECTIONS_SIZE_BITS;
+	}
 
 	DEBUG_MSG("kimage_voffset   : %lx\n", kimage_voffset);
 	DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits);
-- 
2.29.2


_______________________________________________
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] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs
  2021-06-08  3:15 [PATCH] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs Pingfan Liu
@ 2021-06-08  6:06 ` HAGIO KAZUHITO(萩尾 一仁)
  2021-06-08  6:36   ` Pingfan Liu
  0 siblings, 1 reply; 5+ messages in thread
From: HAGIO KAZUHITO(萩尾 一仁) @ 2021-06-08  6:06 UTC (permalink / raw)
  To: Pingfan Liu, kexec

-----Original Message-----
> On arm64, memory section size changes due to the kernel commit
> f0b13ee23241 ("arm64/sparsemem: reduce SECTION_SIZE_BITS")
> 
> To tackle the compatibility, it is safe to read this info from sysfs
> "/sys/devices/system/memory/block_size_bytes"

Thanks for the patch, but the place where we should put/get such
necessary information first is vmcoreinfo, which exists for that.
Can we add an entry for the SECTIONS_SIZE_BITS there?

If we use information from a runtime environment, makedumpfile cannot
process vmcores/dumpfiles generated from other kernels than one that
makedumpfile is running.

Thanks,
Kazu

> 
> Signed-off-by: Pingfan Liu <piliu@redhat.com>
> Cc: Kazuhito Hagio <k-hagio-ab@nec.com>
> To: kexec@lists.infradead.org
> ---
>  arch/arm64.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64.c b/arch/arm64.c
> index 1072178..2f6f5cf 100644
> --- a/arch/arm64.c
> +++ b/arch/arm64.c
> @@ -424,6 +424,11 @@ get_page_offset_arm64(void)
>  int
>  get_machdep_info_arm64(void)
>  {
> +	const char sys_path_section_sz[] = "/sys/devices/system/memory/block_size_bytes";
> +	char memsection_sz_str[64] = { 0 };
> +	unsigned long memsection_sz = 0;
> +	FILE *fp;
> +
>  	/* Check if va_bits is still not initialized. If still 0, call
>  	 * get_versiondep_info() to initialize the same.
>  	 */
> @@ -451,7 +456,21 @@ get_machdep_info_arm64(void)
>  	}
> 
>  	kimage_voffset = NUMBER(kimage_voffset);
> -	info->section_size_bits = SECTIONS_SIZE_BITS;
> +
> +	fp = fopen(sys_path_section_sz, "r");
> +	if (fp) {
> +		int i;
> +
> +		fread(&memsection_sz_str, 64, 1, fp);
> +		fclose(fp);
> +		memsection_sz = strtol(memsection_sz_str, NULL, 16);
> +		for (i = -1; memsection_sz != 0; i++)
> +			memsection_sz >>= 1;
> +		info->section_size_bits = i;
> +	}
> +	else {
> +		info->section_size_bits = SECTIONS_SIZE_BITS;
> +	}
> 
>  	DEBUG_MSG("kimage_voffset   : %lx\n", kimage_voffset);
>  	DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits);
> --
> 2.29.2


_______________________________________________
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] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs
  2021-06-08  6:06 ` HAGIO KAZUHITO(萩尾 一仁)
@ 2021-06-08  6:36   ` Pingfan Liu
  2021-06-08  7:16     ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 5+ messages in thread
From: Pingfan Liu @ 2021-06-08  6:36 UTC (permalink / raw)
  To: HAGIO KAZUHITO(萩尾 一仁); +Cc: kexec

On Tue, Jun 8, 2021 at 2:07 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
>
> -----Original Message-----
> > On arm64, memory section size changes due to the kernel commit
> > f0b13ee23241 ("arm64/sparsemem: reduce SECTION_SIZE_BITS")
> >
> > To tackle the compatibility, it is safe to read this info from sysfs
> > "/sys/devices/system/memory/block_size_bytes"
>
> Thanks for the patch, but the place where we should put/get such
> necessary information first is vmcoreinfo, which exists for that.
> Can we add an entry for the SECTIONS_SIZE_BITS there?
>
OK, I will send a patch to kernel for it.

Thanks,
Pingfan

> If we use information from a runtime environment, makedumpfile cannot
> process vmcores/dumpfiles generated from other kernels than one that
> makedumpfile is running.
>
> Thanks,
> Kazu
>
> >
> > Signed-off-by: Pingfan Liu <piliu@redhat.com>
> > Cc: Kazuhito Hagio <k-hagio-ab@nec.com>
> > To: kexec@lists.infradead.org
> > ---
> >  arch/arm64.c | 21 ++++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64.c b/arch/arm64.c
> > index 1072178..2f6f5cf 100644
> > --- a/arch/arm64.c
> > +++ b/arch/arm64.c
> > @@ -424,6 +424,11 @@ get_page_offset_arm64(void)
> >  int
> >  get_machdep_info_arm64(void)
> >  {
> > +     const char sys_path_section_sz[] = "/sys/devices/system/memory/block_size_bytes";
> > +     char memsection_sz_str[64] = { 0 };
> > +     unsigned long memsection_sz = 0;
> > +     FILE *fp;
> > +
> >       /* Check if va_bits is still not initialized. If still 0, call
> >        * get_versiondep_info() to initialize the same.
> >        */
> > @@ -451,7 +456,21 @@ get_machdep_info_arm64(void)
> >       }
> >
> >       kimage_voffset = NUMBER(kimage_voffset);
> > -     info->section_size_bits = SECTIONS_SIZE_BITS;
> > +
> > +     fp = fopen(sys_path_section_sz, "r");
> > +     if (fp) {
> > +             int i;
> > +
> > +             fread(&memsection_sz_str, 64, 1, fp);
> > +             fclose(fp);
> > +             memsection_sz = strtol(memsection_sz_str, NULL, 16);
> > +             for (i = -1; memsection_sz != 0; i++)
> > +                     memsection_sz >>= 1;
> > +             info->section_size_bits = i;
> > +     }
> > +     else {
> > +             info->section_size_bits = SECTIONS_SIZE_BITS;
> > +     }
> >
> >       DEBUG_MSG("kimage_voffset   : %lx\n", kimage_voffset);
> >       DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits);
> > --
> > 2.29.2
>


_______________________________________________
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] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs
  2021-06-08  6:36   ` Pingfan Liu
@ 2021-06-08  7:16     ` HAGIO KAZUHITO(萩尾 一仁)
  2021-06-08  9:29       ` Pingfan Liu
  0 siblings, 1 reply; 5+ messages in thread
From: HAGIO KAZUHITO(萩尾 一仁) @ 2021-06-08  7:16 UTC (permalink / raw)
  To: Pingfan Liu; +Cc: kexec

-----Original Message-----
> On Tue, Jun 8, 2021 at 2:07 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
> >
> > -----Original Message-----
> > > On arm64, memory section size changes due to the kernel commit
> > > f0b13ee23241 ("arm64/sparsemem: reduce SECTION_SIZE_BITS")
> > >
> > > To tackle the compatibility, it is safe to read this info from sysfs
> > > "/sys/devices/system/memory/block_size_bytes"
> >
> > Thanks for the patch, but the place where we should put/get such
> > necessary information first is vmcoreinfo, which exists for that.
> > Can we add an entry for the SECTIONS_SIZE_BITS there?
> >
> OK, I will send a patch to kernel for it.

FWIW, my expectation is that it will be added to kernel/crash_core.c, i.e.
not only for arm64, because some architectures like arm and mips also have
multiple values like arm64 and that will help use makedumpfile, and also
will make it adaptable to future changes on all architectures.

$ git grep SECTION_SIZE_BITS arch/

arch/arm/include/asm/sparsemem.h:#define SECTION_SIZE_BITS      28
arch/arm/mach-rpc/include/mach/memory.h:#define SECTION_SIZE_BITS       26
arch/arm/mach-sa1100/include/mach/memory.h:#define SECTION_SIZE_BITS    27

arch/mips/include/asm/sparsemem.h:# define SECTION_SIZE_BITS    29
arch/mips/include/asm/sparsemem.h:# define SECTION_SIZE_BITS    28

Thanks,
Kazu

> 
> Thanks,
> Pingfan
> 
> > If we use information from a runtime environment, makedumpfile cannot
> > process vmcores/dumpfiles generated from other kernels than one that
> > makedumpfile is running.
> >
> > Thanks,
> > Kazu
> >
> > >
> > > Signed-off-by: Pingfan Liu <piliu@redhat.com>
> > > Cc: Kazuhito Hagio <k-hagio-ab@nec.com>
> > > To: kexec@lists.infradead.org
> > > ---
> > >  arch/arm64.c | 21 ++++++++++++++++++++-
> > >  1 file changed, 20 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arm64.c b/arch/arm64.c
> > > index 1072178..2f6f5cf 100644
> > > --- a/arch/arm64.c
> > > +++ b/arch/arm64.c
> > > @@ -424,6 +424,11 @@ get_page_offset_arm64(void)
> > >  int
> > >  get_machdep_info_arm64(void)
> > >  {
> > > +     const char sys_path_section_sz[] = "/sys/devices/system/memory/block_size_bytes";
> > > +     char memsection_sz_str[64] = { 0 };
> > > +     unsigned long memsection_sz = 0;
> > > +     FILE *fp;
> > > +
> > >       /* Check if va_bits is still not initialized. If still 0, call
> > >        * get_versiondep_info() to initialize the same.
> > >        */
> > > @@ -451,7 +456,21 @@ get_machdep_info_arm64(void)
> > >       }
> > >
> > >       kimage_voffset = NUMBER(kimage_voffset);
> > > -     info->section_size_bits = SECTIONS_SIZE_BITS;
> > > +
> > > +     fp = fopen(sys_path_section_sz, "r");
> > > +     if (fp) {
> > > +             int i;
> > > +
> > > +             fread(&memsection_sz_str, 64, 1, fp);
> > > +             fclose(fp);
> > > +             memsection_sz = strtol(memsection_sz_str, NULL, 16);
> > > +             for (i = -1; memsection_sz != 0; i++)
> > > +                     memsection_sz >>= 1;
> > > +             info->section_size_bits = i;
> > > +     }
> > > +     else {
> > > +             info->section_size_bits = SECTIONS_SIZE_BITS;
> > > +     }
> > >
> > >       DEBUG_MSG("kimage_voffset   : %lx\n", kimage_voffset);
> > >       DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits);
> > > --
> > > 2.29.2
> >

_______________________________________________
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] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs
  2021-06-08  7:16     ` HAGIO KAZUHITO(萩尾 一仁)
@ 2021-06-08  9:29       ` Pingfan Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Pingfan Liu @ 2021-06-08  9:29 UTC (permalink / raw)
  To: HAGIO KAZUHITO(萩尾 一仁); +Cc: kexec

On Tue, Jun 8, 2021 at 3:17 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
>
> -----Original Message-----
> > On Tue, Jun 8, 2021 at 2:07 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
> > >
> > > -----Original Message-----
> > > > On arm64, memory section size changes due to the kernel commit
> > > > f0b13ee23241 ("arm64/sparsemem: reduce SECTION_SIZE_BITS")
> > > >
> > > > To tackle the compatibility, it is safe to read this info from sysfs
> > > > "/sys/devices/system/memory/block_size_bytes"
> > >
> > > Thanks for the patch, but the place where we should put/get such
> > > necessary information first is vmcoreinfo, which exists for that.
> > > Can we add an entry for the SECTIONS_SIZE_BITS there?
> > >
> > OK, I will send a patch to kernel for it.
>
> FWIW, my expectation is that it will be added to kernel/crash_core.c, i.e.
> not only for arm64, because some architectures like arm and mips also have
> multiple values like arm64 and that will help use makedumpfile, and also
> will make it adaptable to future changes on all architectures.
>
Thanks for your suggestion. I have composed one and run some test now.

Will cc you when sending it.

Thanks,
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:[~2021-06-08  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  3:15 [PATCH] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs Pingfan Liu
2021-06-08  6:06 ` HAGIO KAZUHITO(萩尾 一仁)
2021-06-08  6:36   ` Pingfan Liu
2021-06-08  7:16     ` HAGIO KAZUHITO(萩尾 一仁)
2021-06-08  9:29       ` Pingfan Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.