RE: [PATCH] makedumpfile/arm64: get SECTIONS_SIZE_BITS from sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Original Message-----
> On Tue, Jun 8, 2021 at 2:07 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx> 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@xxxxxxxxxx>
> > > Cc: Kazuhito Hagio <k-hagio-ab@xxxxxxx>
> > > To: kexec@xxxxxxxxxxxxxxxxxxx
> > > ---
> > >  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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux