makedumpfile/arm64: Add '--mem-usage' support
Subsystems (2)
PATCH 1/1 makedumpfile/arm64: Add '--mem-usage' support
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.
Using this we can know how many pages are dumpable when different dump_level is specified.
Normally for x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.
We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like VA_BITS being determined from kernel symbol like _stext. This allows us to get the VA_BITS before 'set_kcore_vmcoreinfo()' is called.
Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on x86_64, but also on ppc64, s390x and arm64.
After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------
ZERO 49524 yes Pages filled with zeroNON_PRI_CACHE 15143 yes Cache pages without private flagPRI_CACHE 29147 yes Cache pages with private flag
USER 3684 yes User process pages
FREE 1450569 yes Free pagesKERN_DATA 14243 no Dumpable kernel data
page size: 65536
Total pages on system: 1562310
Total size on system: 102387548160 Byte
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)
arch/arm64.c +48 -3
@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))
@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {
@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);
@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }
makedumpfile.8 +9 -2
@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes
@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fR
makedumpfile.c +23 -2
@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},
@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;
makedumpfile.h +1 -0
@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void );
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel data
Quoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>
Ping. Any review comments on this?
Regards,
Bhupesh
Quoted 181 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +1
-1@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void ); --
Quoted 2 lines
2.7.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Bhupesh,
Sorry for the late reply.
I'll reply by the end the next week.
Thanks
tachibana
Quoted 236 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Tuesday, February 20, 2018 1:56 PM
To: [email protected]
Cc: Bhupesh Sharma <[email protected]>; TachibanaMasaki()<[email protected]>; NakayamaTakuya( )<[email protected]>; NishimuraDaisuke()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel dataQuoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>Ping. Any review comments on this?
Regards,
BhupeshQuoted 175 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +0
-0@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype.
Quoted 8 lines
Quoted 8 lines
makedumpfile.h +1
-1*/ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void ); --2.7.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Masaki Tachibana,
Quoted 4 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
I'll reply by the end the next week.
Sure. Thanks for your mail.
Regards,
Bhupesh
Quoted 244 lines
Thanks
tachibanaQuoted 241 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Tuesday, February 20, 2018 1:56 PM
To: [email protected]
Cc: Bhupesh Sharma <[email protected]>; TachibanaMasaki()<[email protected]>; NakayamaTakuya( )<[email protected]>; NishimuraDaisuke()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel dataQuoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>Ping. Any review comments on this?
Regards,
BhupeshQuoted 180 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +1
-0@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void );
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
--
2.7.4_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Bhupesh,
Sorry for the late reply.
And thank you for your patch.
I have some questions. Please answer me.
- Have you succeeded --mem-usage on ppc64, s390x ?
- By your patch, makedumpfile behaves like this;
1.Gets an address of _stext from a vmlinux file. 2.Checks how many upper bits are 1 in the address. 3.Determines va_bits and info->page_offset by the check. Isn't there any other method to get page_offset without a vmlinux ?
Thanks
Tachibana
Quoted 276 lines
-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Bhupesh SHARMA
Sent: Thursday, February 22, 2018 3:58 AM
To: TachibanaMasaki()<[email protected]>
Cc: [email protected]; Bhupesh Sharma <[email protected]>; HayashiMasahiko()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHi Masaki Tachibana,
Quoted 4 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
I'll reply by the end the next week.Sure. Thanks for your mail.
Regards,
BhupeshQuoted 244 lines
Thanks
tachibanaQuoted 241 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Tuesday, February 20, 2018 1:56 PM
To: [email protected]
Cc: Bhupesh Sharma <[email protected]>; TachibanaMasaki()<[email protected]>; NakayamaTakuya( )<[email protected]>; NishimuraDaisuke()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel dataQuoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>Ping. Any review comments on this?
Regards,
BhupeshQuoted 180 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +1
-0@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void );Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
--
2.7.4_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 4 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hello Masaki,
Thanks for your reply.
Quoted 6 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
And thank you for your patch.
I have some questions. Please answer me.
- Have you succeeded --mem-usage on ppc64, s390x ?
Yes, --mem-usage works fine on both ppc64 and s390x RHEL systems for me. I tested the same on several ppc64 and s390x machines.
Quoted 5 lines
- By your patch, makedumpfile behaves like this;
1.Gets an address of_stextfrom a vmlinux file. 2.Checks how many upper bits are 1 in the address. 3.Determinesva_bitsandinfo->page_offsetby the check. Isn't there any other method to getpage_offsetwithout a vmlinux ?
Ok, let me give some background here:
On ARM64 platforms the VA_BITS supported by a linux kernel run can be selected by setting 'ARM64_VA_BITS_*' (please see [1]) config options.
Now, to determine the 'info->page_offset' in arm64 makedumpfile context ('arch/arm64.c')
we need to determine the VA_BITS which was selected by the underlying linux kernel.
Now there are several ways to determine the VA_BITS:
(a). Read the CONFIG flags from the user space using something like:
- Create a 'running.config' which will contain the configuration of the running linux kernel
and grep the VA_BITS from 'running.config' :
# cat /proc/config.gz | gunzip > running.config - However this is only possible if running linux kernel was configured to have '/proc/config.gz'
So, this is probably not a good option.
(b). Read '_stext' symbol and calculate the 'va_bits' and 'info->page_offset' using the upper bits are 1 in the address. There are a couple of ways to do the same via makedumpfile code:
- Use the 'vmlinux' file, which this version of the patch does.
- Use the '/proc/kallsyms' file, which is also possible and I have a patch ready for this approach as well.
The '/proc/kallsyms' file approach is better in the following aspects:
- We don't need to pass the 'vmlinux' file path separately while invoking '--mem-usage' option for makedumpfile.
- It also helps the arm64 KASLR makedumpfile implementation (which I am currently working on and will send out a patch to address the same soon), as the '_stext' symbol will be randomized and hence cannot be properly read from the 'vmlinux' file.
If you agree, I can send a new version which reads the '_stext' symbol from '/proc/kallsyms' and works fine on the arm64 platforms I have tested it on (both with KASLR turned on and off)
[1]. https://elixir.bootlin.com/linux/v4.9/source/arch/arm64/Kconfig#L518
Regards,
Bhupesh
Quoted 285 lines
Thanks
TachibanaQuoted 280 lines
-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Bhupesh SHARMA
Sent: Thursday, February 22, 2018 3:58 AM
To: TachibanaMasaki()<[email protected]>
Cc: [email protected]; Bhupesh Sharma <[email protected]>; HayashiMasahiko()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHi Masaki Tachibana,
Quoted 4 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
I'll reply by the end the next week.Sure. Thanks for your mail.
Regards,
BhupeshQuoted 244 lines
Thanks
tachibanaQuoted 241 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Tuesday, February 20, 2018 1:56 PM
To: [email protected]
Cc: Bhupesh Sharma <[email protected]>; TachibanaMasaki()<[email protected]>; NakayamaTakuya( )<[email protected]>; NishimuraDaisuke()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel dataQuoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>Ping. Any review comments on this?
Regards,
BhupeshQuoted 180 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +1
-0@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void );Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
--
2.7.4_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Bhupesh,
Thank you for your explanation.
It sounds good.
I will wait for your new patch.
Thanks
Tachibana
Quoted 66 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Monday, March 05, 2018 12:41 PM
To: TachibanaMasaki()<[email protected]>
Cc: [email protected]; HayashiMasahiko()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello Masaki,
Thanks for your reply.
Quoted 6 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
And thank you for your patch.
I have some questions. Please answer me.
- Have you succeeded --mem-usage on ppc64, s390x ?Yes, --mem-usage works fine on both ppc64 and s390x RHEL systems for me. I tested the same on several ppc64 and s390x machines.
Quoted 5 lines
- By your patch, makedumpfile behaves like this;
1.Gets an address of_stextfrom a vmlinux file. 2.Checks how many upper bits are 1 in the address. 3.Determinesva_bitsandinfo->page_offsetby the check. Isn't there any other method to getpage_offsetwithout a vmlinux ?Ok, let me give some background here:
On ARM64 platforms the
VA_BITSsupported by a linux kernel run can be selected by setting 'ARM64_VA_BITS_*' (please see [1]) config options.Now, to determine the '
info->page_offset' in arm64 makedumpfile context ('arch/arm64.c')
we need to determine theVA_BITSwhich was selected by the underlying linux kernel.Now there are several ways to determine the
VA_BITS:(a). Read the CONFIG flags from the user space using something like:
- Create a 'running.config' which will contain the configuration of the running linux kernel
and grep theVA_BITSfrom 'running.config' :# cat /proc/config.gz | gunzip > running.config - However this is only possible if running linux kernel was configured to have '/proc/config.gz'So, this is probably not a good option.
(b). Read '
_stext' symbol and calculate the 'va_bits' and 'info->page_offset' using the upper bits are 1 in the address. There are a couple of ways to do the same via makedumpfile code:
- Use the 'vmlinux' file, which this version of the patch does.
- Use the '/proc/kallsyms' file, which is also possible and I have a patch ready for this approach as well.The '
/proc/kallsyms' file approach is better in the following aspects:
- We don't need to pass the 'vmlinux' file path separately while invoking '--mem-usage' option for makedumpfile.
- It also helps the arm64 KASLR makedumpfile implementation (which I am currently working on and will send out a patch to address the same soon), as the '_stext' symbol will be randomized and hence cannot be properly read from the 'vmlinux' file.
Quoted 294 lines
If you agree, I can send a new version which reads the '
_stext' symbol from '/proc/kallsyms' and works fine on the arm64 platforms I have tested it on (both with KASLR turned on and off)[1]. https://elixir.bootlin.com/linux/v4.9/source/arch/arm64/Kconfig#L518
Regards,
BhupeshQuoted 285 lines
Thanks
TachibanaQuoted 280 lines
-----Original Message-----
From: kexec [mailto:[email protected]] On Behalf Of Bhupesh SHARMA
Sent: Thursday, February 22, 2018 3:58 AM
To: TachibanaMasaki()<[email protected]>
Cc: [email protected]; Bhupesh Sharma <[email protected]>; HayashiMasahiko()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHi Masaki Tachibana,
Quoted 4 lines · Masaki Tachibana
Hi Bhupesh,
Sorry for the late reply.
I'll reply by the end the next week.Sure. Thanks for your mail.
Regards,
BhupeshQuoted 244 lines
Thanks
tachibanaQuoted 241 lines
-----Original Message-----
From: Bhupesh Sharma [mailto:[email protected]]
Sent: Tuesday, February 20, 2018 1:56 PM
To: [email protected]
Cc: Bhupesh Sharma <[email protected]>; TachibanaMasaki()<[email protected]>; NakayamaTakuya( )<[email protected]>; NishimuraDaisuke()<[email protected]>
Subject: Re: [PATCH] makedumpfile/arm64: Add '--mem-usage' supportHello,
Quoted 36 lines · Bhupesh Sharma
Its good to have the makedumpfile '--mem-usage' support
for arm64 architecture as well, as it allows one to see the page numbers of current system (1st kernel) in different use.Using this we can know how many pages are dumpable when different
dump_levelis specified.Normally for
x86_64, makedumpfile analyzes the 'System Ram' and 'kernel text' program segment of/proc/kcoreexcluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo.We use the similar logic for arm64, but in addition make the '--mem-usage' usage dependent on the VMLINUX file being passed. This is done to allow information like
VA_BITSbeing determined from kernel symbol like_stext. This allows us to get theVA_BITSbefore 'set_kcore_vmcoreinfo()' is called.Also I have validated the '--mem-usage' makedumpfile option on several ppc64/ppc64le and s390x machines, so update the makedumpfile.8 documentation to indicate that '--mem-usage' option is supported not only on
x86_64, but also on ppc64, s390x and arm64.After this patch, when using the '--mem-usage' option with makedumpfile, we get the correct information about the different pages. For e.g. here is an output from my arm64 board:
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------ZERO 49524 yes Pages filled with zero NON_PRI_CACHE 15143 yes Cache pages without private flag PRI_CACHE 29147 yes Cache pages with private flag USER 3684 yes User process pages FREE 1450569 yes Free pages KERN_DATA 14243 no Dumpable kernel dataQuoted 8 lines
page size: 65536 Total pages on system: 1562310 Total size on system: 102387548160 ByteCc Masaki Tachibana <[email protected]>Cc Takuya Nakayama <[email protected]>Cc Daisuke Nishimura <[email protected]>Signed-off-by Bhupesh Sharma <[email protected]>Ping. Any review comments on this?
Regards,
BhupeshQuoted 180 lines
--- arch/arm64.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.8 | 11 +++++++++-- makedumpfile.c | 25 +++++++++++++++++++++++-- makedumpfile.h | 1 + 4 files changed, 81 insertions(+), 7 deletions(-)arch/arm64.c +48
-3@@ -48,6 +48,12 @@ static unsigned long kimage_voffset;#define SZ_64K (64 * 1024)#define SZ_128M (128 * 1024 * 1024) +#define PAGE_OFFSET_36 ((0xffffffffffffffffUL) << 36) +#define PAGE_OFFSET_39 ((0xffffffffffffffffUL) << 39) +#define PAGE_OFFSET_42 ((0xffffffffffffffffUL) << 42) +#define PAGE_OFFSET_47 ((0xffffffffffffffffUL) << 47) +#define PAGE_OFFSET_48 ((0xffffffffffffffffUL) << 48) +#define pgd_val (x) ((x).pgd)#define pud_val (x) (pgd_val((x).pgd))#define pmd_val (x) (pud_val((x).pud))@@ -140,8 +146,6 @@ pud_offset(pgd_t *pgda, pgd_t *pgdv, unsigned long vaddr)static int calculate_plat_config (void ) { - va_bits =NUMBER (VA_BITS ); -/* derive pgtable_level as per arch/arm64/Kconfig */ if ((PAGESIZE () ==SZ_16K && va_bits ==36 ) || (PAGESIZE () ==SZ_64K && va_bits ==42 )) {@@ -188,7 +192,6 @@ get_machdep_info_arm64(void) kimage_voffset =NUMBER (kimage_voffset); info->max_physmem_bits =PHYS_MASK_SHIFT ; info->section_size_bits =SECTIONS_SIZE_BITS ; - info->page_offset =0xffffffffffffffffUL << (va_bits -1 );DEBUG_MSG ("kimage_voffset : %lx\n" , kimage_voffset);DEBUG_MSG ("max_physmem_bits : %lx\n" , info->max_physmem_bits);@@ -219,6 +222,48 @@ get_xen_info_arm64(void)int get_versiondep_info_arm64 (void ) { +unsigned long long stext; + +/* We can read the _stext symbol from vmlinux and determine the +* VA_BITS and page_offset. +*/ + +/* Open the vmlinux file */ +open_kernel_file (); +set_dwarf_debuginfo ("vmlinux" ,NULL , + info->name_vmlinux, info->fd_vmlinux); + +if (!get_symbol_info ()) +return FALSE; + +/* Get the '_stext' symbol */ +if (SYMBOL (_stext) ==NOT_FOUND_SYMBOL ) { +ERRMSG ("Can't get the symbol of _stext.\n" ); +return FALSE; + }else { + stext =SYMBOL (_stext); + } + +/* Derive va_bits as per arch/arm64/Kconfig */ +if ((stext &PAGE_OFFSET_36 ) ==PAGE_OFFSET_36 ) { + va_bits =36 ; + }else if ((stext &PAGE_OFFSET_39 ) ==PAGE_OFFSET_39 ) { + va_bits =39 ; + }else if ((stext &PAGE_OFFSET_42 ) ==PAGE_OFFSET_42 ) { + va_bits =42 ; + }else if ((stext &PAGE_OFFSET_47 ) ==PAGE_OFFSET_47 ) { + va_bits =47 ; + }else if ((stext &PAGE_OFFSET_48 ) ==PAGE_OFFSET_48 ) { + va_bits =48 ; + }else { +ERRMSG ("Cannot find a proper _stext for calculating VA_BITS\n" ); +return FALSE; + } + + info->page_offset = (0xffffffffffffffffUL ) << (va_bits -1 ); + +DEBUG_MSG ("page_offset=%lx, va_bits=%d\n" , info->page_offset, va_bits); +return TRUE; }makedumpfile.8 +9
-2@@ -593,7 +593,7 @@ last cleared on the crashed kernel, through "dmesg --clear" for example. .TP \fB\-\-mem-usage\fR -This option is only for x86_64. +This option is currently supported on x86_64, arm64, ppc64 and s390x. This option is used to show the page numbers of current system in different use. It should be executed in 1st kernel. By the help of this, user can know how many pages is dumpable when different dump_level is specified. It analyzes@@ -601,12 +601,19 @@ the 'System Ram' and 'kernel text' program segment of /proc/kcore excluding the crashkernel range, then calculates the page number of different kind per vmcoreinfo. So currently /proc/kcore need be specified explicitly. +For arm64, path to vmlinux file should be specified as well. + .br -.B Example: +.B Example (for architectures other than arm64): .br # makedumpfile \-\-mem-usage /proc/kcore + +.br +.B Example (for arm64 architecture): .br +# makedumpfile \-\-mem-usage vmlinux /proc/kcore +.br .TP \fB\-\-diskset=VMCORE\fRmakedumpfile.c +23
-2@@ -11090,7 +11090,14 @@ static struct option longopts[] = { {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, {"eppic", required_argument, NULL, OPT_EPPIC}, {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits. +*/ + {"mem-usage", required_argument, NULL, OPT_MEM_USAGE}, +#else {"mem-usage", no_argument, NULL, OPT_MEM_USAGE}, +#endif {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS},@@ -11201,8 +11208,22 @@ main(int argc, char *argv[]) info->flag_partial_dmesg =1 ;break ;case OPT_MEM_USAGE : - info->flag_mem_usage =1 ; -break ; + info->flag_mem_usage =1 ; +#ifdef __aarch64__ +/* VMLINUX file is required for aarch64 for get +* the symbols required to calculate va_bits and +* it should be the 1st command parameter being +* specified. +*/ +if (strcmp (optarg,"/proc/kcore" ) ==0 ) { +MSG ("vmlinux path should be 1st commandline parameter with --mem-usage option.\n" ); + goto out; + } +else { + info->name_vmlinux = optarg; + } +#endif +break ;case OPT_COMPRESS_SNAPPY : info->flag_compress =DUMP_DH_COMPRESSED_SNAPPY ;break ;makedumpfile.h +1
-0@@ -2308,6 +2308,7 @@ struct elf_prstatus {/* * Function Prototype. */ +int open_kernel_file (void );mdf_pfn_t get_num_dumpable_cyclic (void );mdf_pfn_t get_num_dumpable_cyclic_withsplit (void );int get_loads_dumpfile_cyclic (void );Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
--
2.7.4_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec