Get stats without writing dumpfile
Subsystems (2)
cover Get stats without writing dumpfile
Hi,
This series is a follow up to the --vmcore-size proposal[1].
The goal is to be able to obtain informations about the dumpfile without actually generating it. Instead of the --vmcore-size approach, we add two different options, one allowing to run makedumpfil without writting the dumpfile, and another to explicitly enable stat displaying.
[1] https://www.spinics.net/lists/kexec/msg26058.html
Cheers,
Julien
-->
Julien Thierry (2):
Add option to prevent writing the dumpfile
Add shorthand option to show report stats
makedumpfile.8 | 10 ++++++++++ makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- makedumpfile.h | 3 +++ print_info.c | 6 ++++++ 4 files changed, 61 insertions(+), 3 deletions(-)
--
2.25.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/2 Add option to prevent writing the dumpfile
Add a --dry-run option to run all operations without writing the dump to the output file.
--- makedumpfile.8 | 5 +++++ makedumpfile.c | 33 +++++++++++++++++++++++++++++++-- makedumpfile.h | 2 ++ print_info.c | 3 +++ 4 files changed, 41 insertions(+), 2 deletions(-)
makedumpfile.8 +5 -0
@@ -637,6 +637,11 @@ Show the version of makedumpfile. Only check whether the command-line parameters are valid or not, and exit. Preferable to be given as the first parameter. +.TP +\fB\-\-dry-run\fR +Do not write the output dump file while still performing operations specified +by other options. + .SH ENVIRONMENT VARIABLES .TP 8
makedumpfile.c +31 -2
@@ -1366,7 +1366,9 @@ open_dump_file(void)if (!info->flag_force) open_flags |=O_EXCL ; -if (info->flag_flatten) { +if (info->flag_dry_run) { + fd =-1 ; + }else if (info->flag_flatten) { fd =STDOUT_FILENO ; info->name_dumpfile = filename_stdout; } else if ((fd = open(info->name_dumpfile, open_flags,
@@ -1384,6 +1386,9 @@ check_dump_file(const char *path) {char *err_str; +if (info->flag_dry_run) +return TRUE; +if (access (path,F_OK ) !=0 )return TRUE;/* File does not exist */ if (info->flag_force) {
@@ -4643,6 +4648,8 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) }if (!write_and_check_space (fd, &fdh,sizeof (fdh), file_name))return FALSE; + }else if (info->flag_dry_run && fd == info->fd_dumpfile) { +return TRUE; }else {if (lseek (fd, offset,SEEK_SET ) == failed) { ERRMSG("Can't seek the dump file(%s). %s\n",
@@ -9007,6 +9014,9 @@ close_dump_file(void)if (info->flag_flatten)return ; +if (info->flag_dry_run) +return ; +if (close (info->fd_dumpfile) <0 )ERRMSG ("Can't close the dump file(%s). %s\n" , info->name_dumpfile,strerror (errno));
@@ -11032,7 +11042,8 @@ check_param_for_creating_dumpfile(int argc, char *argv[])*/ info->name_memory = argv[optind]; - }else if ((argc == optind +1 ) && info->flag_mem_usage) { + }else if ((argc == optind +1 ) && (info->flag_mem_usage || + info->flag_dry_run)) {/* * Parameter for showing the page number of memory * in different use from.
@@ -11412,6 +11423,7 @@ static struct option longopts[] = { {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {"dry-run", no_argument, NULL, OPT_DRY_RUN}, {0, 0, 0, 0} };
@@ -11578,6 +11590,9 @@ main(int argc, char *argv[]) info->flag_check_params = TRUE; message_level =DEFAULT_MSG_LEVEL ;break ; +case OPT_DRY_RUN : + info->flag_dry_run = TRUE; +break ;case '?' :MSG ("Commandline parameter is invalid.\n" );MSG ("Try `makedumpfile --help' for more information.\n" );
@@ -11591,6 +11606,10 @@ main(int argc, char *argv[])/* suppress debugging messages */ message_level =DEFAULT_MSG_LEVEL ; +if (info->flag_dry_run) +/* Suppress progress indicator as dumpfile won't get written */ + message_level &= ~ML_PRINT_PROGRESS ; +if (info->flag_show_usage) {print_usage ();return COMPLETED ;
@@ -11661,6 +11680,9 @@ main(int argc, char *argv[])if (!close_files_for_rearranging_dumpdata ()) goto out; +if (info->flag_dry_run) + goto check_ok; +MSG ("\n" );MSG ("The dumpfile is saved to %s.\n" , info->name_dumpfile); }else if (info->flag_reassemble) {
@@ -11677,6 +11699,10 @@ main(int argc, char *argv[])if (!reassemble_dumpfile ()) goto out; + +if (info->flag_dry_run) + goto check_ok; +MSG ("\n" );MSG ("The dumpfile is saved to %s.\n" , info->name_dumpfile); }else if (info->flag_dmesg) {
@@ -11739,6 +11765,9 @@ main(int argc, char *argv[])if (!create_dumpfile ()) goto out; +if (info->flag_dry_run) + goto check_ok; +MSG ("\n" );if (info->flag_split) {MSG ("The dumpfiles are saved to " );
makedumpfile.h +2 -0
@@ -1321,6 +1321,7 @@ struct DumpInfo {int flag_vmemmap;/* kernel supports vmemmap address space */ int flag_excludevm;/* -e - excluding unused vmemmap pages */ int flag_use_count;/* _refcount is named _count in struct page */ +int flag_dry_run;/* do not create a vmcore file */ unsigned long vaddr_for_vtop;/* virtual address for debugging */ long page_size;/* size of page */ long page_shift;
@@ -2364,6 +2365,7 @@ struct elf_prstatus {#define OPT_NUM_THREADS OPT_START+16#define OPT_PARTIAL_DMESG OPT_START+17#define OPT_CHECK_PARAMS OPT_START+18 +#define OPT_DRY_RUN OPT_START+19/* * Function Prototype.
print_info.c +3 -0
@@ -308,6 +308,9 @@ print_usage(void)MSG (" the crashkernel range, then calculates the page number of different kind per\n" );MSG (" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n" );MSG ("\n" ); +MSG (" [--dry-run]:\n" ); +MSG (" This option runs makedumpfile without writting output dump file.\n" ); +MSG ("\n" );MSG (" [-D]:\n" );MSG (" Print debugging message.\n" );MSG ("\n" );
Signature · 7 lines
2.25.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
RE: [MAKEDUMPFILE PATCH 1/2] Add option to prevent writing the dumpfile
Hi Julien,
Thanks for the patches, and sorry for the late reply..
-----Original Message-----
Quoted 2 lines
Add a --dry-run option to run all operations without writing the dump to the output file.
First, I think makedumpfile should not change its behavior (path checks, messages emitted, etc.) and exit code except for writing the dumpfile with or without the --dry-run option. For example with this patch:
$ touch dumpfile $ makedumpfile -d 1 vmcore dumpfile --dry-run --> ok, no problem $ makedumpfile -d 1 vmcore dumpfile --> error
This change is a bit strange to me. So with this premise, commented inline and attached a modified patch at end of this email. Could you check those?
Quoted 30 lines
Signed-off-by Julien Thierry <[email protected]>--- makedumpfile.8 | 5 +++++ makedumpfile.c | 33 +++++++++++++++++++++++++++++++-- makedumpfile.h | 2 ++ print_info.c | 3 +++ 4 files changed, 41 insertions(+), 2 deletions(-)makedumpfile.8 +5
-0@@ -637,6 +637,11 @@ Show the version of makedumpfile. Only check whether the command-line parameters are valid or not, and exit. Preferable to be given as the first parameter. +.TP +\fB\-\-dry-run\fR +Do not write the output dump file while still performing operations specified +by other options. + .SH ENVIRONMENT VARIABLES .TP 8makedumpfile.c +0
-0
makedumpfile.c open_dump_file(void) · line 1373
Quoted 9 lines
makedumpfile.c +3
-1@@ -1366,7 +1366,9 @@ open_dump_file(void)if (!info->flag_force) open_flags |=O_EXCL ; -if (info->flag_flatten) { +if (info->flag_dry_run) { + fd =-1 ; + }else if (info->flag_flatten) { fd =STDOUT_FILENO ; info->name_dumpfile = filename_stdout;
This does not support -F option.
# makedumpfile --dry-run -F -d 31 vmcore >/dev/null
Can't write the dump file((null)). Bad file descriptor
makedumpfile Failed.
I'll change the order here:
@@ -1372,6 +1372,8 @@ open_dump_file(void)
if (info->flag_flatten) {
fd = STDOUT_FILENO;
info->name_dumpfile = filename_stdout;
+ } else if (info->flag_dry_run) {
+ fd = -1;
} else if ((fd = open(info->name_dumpfile, open_flags,
S_IRUSR|S_IWUSR)) < 0) {
ERRMSG("Can't open the dump file(%s). %s\n",makedumpfile.c check_dump_file(const char *path) · line 1391
Quoted 8 lines
makedumpfile.c +3
-0} else if ((fd = open(info->name_dumpfile, open_flags,@@ -1384,6 +1386,9 @@ check_dump_file(const char *path) {char *err_str; +if (info->flag_dry_run) +return TRUE; +
I would prefer to check the path rather than skip it because of the reason I wrote above.
makedumpfile.c write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) · line 4652
Quoted 9 lines
makedumpfile.c +2
-0if (access (path,F_OK ) !=0 )return TRUE;/* File does not exist */ if (info->flag_force) {@@ -4643,6 +4648,8 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) }if (!write_and_check_space (fd, &fdh,sizeof (fdh), file_name))return FALSE; + }else if (info->flag_dry_run && fd == info->fd_dumpfile) { +return TRUE;
To support -F option and count bytes written later, I'll add this in write_and_check_space().
@@ -4711,6 +4713,9 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name)
{
int status, written_size = 0;+ if (info->flag_dry_run)
+ return TRUE;
+
while (written_size < buf_size) {
status = write(fd, buf + written_size,
buf_size - written_size);Quoted 14 lines
makedumpfile.c +3
-0}else {if (lseek (fd, offset,SEEK_SET ) == failed) { ERRMSG("Can't seek the dump file(%s). %s\n",@@ -9007,6 +9014,9 @@ close_dump_file(void)if (info->flag_flatten)return ; +if (info->flag_dry_run) +return ; +if (close (info->fd_dumpfile) <0 )ERRMSG ("Can't close the dump file(%s). %s\n" , info->name_dumpfile,strerror (errno));
makedumpfile.c check_param_for_creating_dumpfile(int argc, char *argv[]) · line 11046
Quoted 6 lines
makedumpfile.c +2
-1@@ -11032,7 +11042,8 @@ check_param_for_creating_dumpfile(int argc, char *argv[])*/ info->name_memory = argv[optind]; - }else if ((argc == optind +1 ) && info->flag_mem_usage) { + }else if ((argc == optind +1 ) && (info->flag_mem_usage || + info->flag_dry_run)) {
I would not like to change valid parameters with --dry-run, so will restore this.
Quoted 22 lines
makedumpfile.c +4
-0/* * Parameter for showing the page number of memory * in different use from. @@ -11412,6 +11423,7 @@ static struct option longopts[] = { {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {"dry-run", no_argument, NULL, OPT_DRY_RUN}, {0, 0, 0, 0} };@@ -11578,6 +11590,9 @@ main(int argc, char *argv[]) info->flag_check_params = TRUE; message_level =DEFAULT_MSG_LEVEL ;break ; +case OPT_DRY_RUN : + info->flag_dry_run = TRUE; +break ;case '?' :MSG ("Commandline parameter is invalid.\n" );MSG ("Try `makedumpfile --help' for more information.\n" );
makedumpfile.c main(int argc, char *argv[]) · line 11612
Quoted 7 lines
makedumpfile.c +4
-0@@ -11591,6 +11606,10 @@ main(int argc, char *argv[])/* suppress debugging messages */ message_level =DEFAULT_MSG_LEVEL ; +if (info->flag_dry_run) +/* Suppress progress indicator as dumpfile won't get written */ + message_level &= ~ML_PRINT_PROGRESS ; +
Will restore this as well.
Quoted 14 lines
makedumpfile.c +3
-0if (info->flag_show_usage) {print_usage ();return COMPLETED ;@@ -11661,6 +11680,9 @@ main(int argc, char *argv[])if (!close_files_for_rearranging_dumpdata ()) goto out; +if (info->flag_dry_run) + goto check_ok; +MSG ("\n" );MSG ("The dumpfile is saved to %s.\n" , info->name_dumpfile); }else if (info->flag_reassemble) {
makedumpfile.c main(int argc, char *argv[]) · line 11704
Quoted 6 lines
makedumpfile.c +3
-0@@ -11677,6 +11699,10 @@ main(int argc, char *argv[])if (!reassemble_dumpfile ()) goto out; + +if (info->flag_dry_run) + goto check_ok;
To make --reassemble, --dump-dmesg, etc. support --dry-run looks a bit troublesome and not so useful, I would like to not support it like:
@@ -11029,6 +11038,11 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[])
|| info->flag_exclude_xen_dom || info->flag_split)
return FALSE;+ if (info->flag_dry_run) {
+ MSG("--dry-run cannot be used with --reassemble.\n");
+ return FALSE;
+ }
+
if ((info->splitting_info
= malloc(sizeof(struct splitting_info) * info->num_dumpfile))
== NULL) {Quoted 49 lines
makedumpfile.c +4
-0+MSG ("\n" );MSG ("The dumpfile is saved to %s.\n" , info->name_dumpfile); }else if (info->flag_dmesg) {@@ -11739,6 +11765,9 @@ main(int argc, char *argv[])if (!create_dumpfile ()) goto out; +if (info->flag_dry_run) + goto check_ok; +MSG ("\n" );if (info->flag_split) {MSG ("The dumpfiles are saved to " );makedumpfile.h +2
-0@@ -1321,6 +1321,7 @@ struct DumpInfo {int flag_vmemmap;/* kernel supports vmemmap address space */ int flag_excludevm;/* -e - excluding unused vmemmap pages */ int flag_use_count;/* _refcount is named _count in struct page */ +int flag_dry_run;/* do not create a vmcore file */ unsigned long vaddr_for_vtop;/* virtual address for debugging */ long page_size;/* size of page */ long page_shift;@@ -2364,6 +2365,7 @@ struct elf_prstatus {#define OPT_NUM_THREADS OPT_START+16#define OPT_PARTIAL_DMESG OPT_START+17#define OPT_CHECK_PARAMS OPT_START+18 +#define OPT_DRY_RUN OPT_START+19/* * Function Prototype. print_info.c +3
-1@@ -308,6 +308,9 @@ print_usage(void)MSG (" the crashkernel range, then calculates the page number of different kind per\n" );MSG (" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n" );MSG ("\n" ); +MSG (" [--dry-run]:\n" ); +MSG (" This option runs makedumpfile without writting output dump file.\n" ); +MSG ("\n" );MSG (" [-D]:\n" );MSG (" Print debugging message.\n" );MSG ("\n" ); --
Quoted 1 line
2.25.4
From e4600ef29a1bac00b93a03e9dd82dd86c719ce94 Mon Sep 17 00:00:00 2001
From: Julien Thierry <[email protected]>
Date: Tue, 24 Nov 2020 10:45:24 +0000
Subject: [PATCH] Add --dry-run option to prevent writing the dumpfile
Add a --dry-run option to run all operations without writing the dump to the output file.
--- makedumpfile.8 | 5 +++++ makedumpfile.c | 37 ++++++++++++++++++++++++++++++------- makedumpfile.h | 2 ++ print_info.c | 3 +++ 4 files changed, 40 insertions(+), 7 deletions(-)
makedumpfile.8 +5 -0
@@ -637,6 +637,11 @@ Show the version of makedumpfile. Only check whether the command-line parameters are valid or not, and exit. Preferable to be given as the first parameter. +.TP +\fB\-\-dry-run\fR +Do not write the output dump file while still performing operations specified +by other options. + .SH ENVIRONMENT VARIABLES .TP 8
makedumpfile.c +30 -7
@@ -1372,6 +1372,8 @@ open_dump_file(void)if (info->flag_flatten) { fd =STDOUT_FILENO ; info->name_dumpfile = filename_stdout; + }else if (info->flag_dry_run) { + fd =-1 ; }else if ((fd =open (info->name_dumpfile, open_flags,S_IRUSR |S_IWUSR )) <0 ) { ERRMSG("Can't open the dump file(%s). %s\n",
@@ -4711,6 +4713,9 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) {int status, written_size =0 ; +if (info->flag_dry_run) +return TRUE; +while (written_size < buf_size) { status =write (fd, buf + written_size, buf_size - written_size);
@@ -4748,13 +4753,12 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) }if (!write_and_check_space (fd, &fdh,sizeof (fdh), file_name))return FALSE; - }else { -if (lseek (fd, offset,SEEK_SET ) == failed) { -ERRMSG ("Can't seek the dump file(%s). %s\n" , - file_name,strerror (errno)); -return FALSE; - } + }else if (!info->flag_dry_run && +lseek (fd, offset,SEEK_SET ) == failed) { +ERRMSG ("Can't seek the dump file(%s). %s\n" , file_name,strerror (errno)); +return FALSE; } +if (!write_and_check_space (fd, buf, buf_size, file_name))return FALSE;
@@ -9112,7 +9116,7 @@ close_dump_memory(void)void close_dump_file (void ) { -if (info->flag_flatten) +if (info->flag_flatten || info->flag_dry_run)return ;if (close (info->fd_dumpfile) <0 )
@@ -10985,6 +10989,11 @@ check_param_for_generating_vmcoreinfo(int argc, char *argv[])return FALSE; +if (info->flag_dry_run) { +MSG ("--dry-run cannot be used with -g.\n" ); +return FALSE; + } +return TRUE; }
@@ -11029,6 +11038,11 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[]) || info->flag_exclude_xen_dom || info->flag_split)return FALSE; +if (info->flag_dry_run) { +MSG ("--dry-run cannot be used with --reassemble.\n" ); +return FALSE; + } +if ((info->splitting_info =malloc (sizeof (struct splitting_info ) * info->num_dumpfile)) ==NULL ) {
@@ -11057,6 +11071,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) || (info->flag_read_vmcoreinfo && info->name_xen_syms))return FALSE; +if (info->flag_dry_run && info->flag_dmesg) { +MSG ("--dry-run cannot be used with --dump-dmesg.\n" ); +return FALSE; + } +if (info->flag_flatten && info->flag_split)return FALSE;
@@ -11520,6 +11539,7 @@ static struct option longopts[] = { {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {"dry-run", no_argument, NULL, OPT_DRY_RUN}, {0, 0, 0, 0} };
@@ -11686,6 +11706,9 @@ main(int argc, char *argv[]) info->flag_check_params = TRUE; message_level =DEFAULT_MSG_LEVEL ;break ; +case OPT_DRY_RUN : + info->flag_dry_run = TRUE; +break ;case '?' :MSG ("Commandline parameter is invalid.\n" );MSG ("Try `makedumpfile --help' for more information.\n" );
makedumpfile.h +2 -0
@@ -1322,6 +1322,7 @@ struct DumpInfo {int flag_vmemmap;/* kernel supports vmemmap address space */ int flag_excludevm;/* -e - excluding unused vmemmap pages */ int flag_use_count;/* _refcount is named _count in struct page */ +int flag_dry_run;/* do not create a vmcore file */ unsigned long vaddr_for_vtop;/* virtual address for debugging */ long page_size;/* size of page */ long page_shift;
@@ -2425,6 +2426,7 @@ struct elf_prstatus {#define OPT_NUM_THREADS OPT_START+16#define OPT_PARTIAL_DMESG OPT_START+17#define OPT_CHECK_PARAMS OPT_START+18 +#define OPT_DRY_RUN OPT_START+19/* * Function Prototype.
print_info.c +3 -0
@@ -308,6 +308,9 @@ print_usage(void)MSG (" the crashkernel range, then calculates the page number of different kind per\n" );MSG (" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n" );MSG ("\n" ); +MSG (" [--dry-run]:\n" ); +MSG (" This option runs makedumpfile without writting output dump file.\n" ); +MSG ("\n" );MSG (" [-D]:\n" );MSG (" Print debugging message.\n" );MSG ("\n" );
Signature · 11 lines
1.8.3.1 Thanks, Kazu _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
RE: [MAKEDUMPFILE PATCH 1/2] Add option to prevent writing the dumpfile
-----Original Message-----
Quoted 12 lines
Hi Julien,
Thanks for the patches, and sorry for the late reply..
-----Original Message-----
Quoted 2 lines
Add a --dry-run option to run all operations without writing the dump to the output file.
First, I think makedumpfile should not change its behavior (path checks, messages emitted, etc.) and exit code except for writing the dumpfile with or without the --dry-run option. For example with this patch:
Quoted 6 lines
$ touch dumpfile $ makedumpfile -d 1 vmcore dumpfile --dry-run --> ok, no problem $ makedumpfile -d 1 vmcore dumpfile --> errorThis change is a bit strange to me. So with this premise, commented inline and attached a modified patch at end of this email. Could you check those?
This patchset is applied with some modifications:
https://github.com/makedumpfile/makedumpfile/compare/54aec38...6f3e75a
I will add another for counting bytes to be written and more readable stats later..
Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
HAGIO KAZUHITO(萩尾 一仁)
AppliedRE: [MAKEDUMPFILE PATCH 1/2] Add option to prevent writing the dumpfile
Hi Lianbo, Julien,
-----Original Message-----
Quoted 4 lines
This patchset is applied with some modifications:
https://github.com/makedumpfile/makedumpfile/compare/54aec38...6f3e75aI will add another for counting bytes to be written and more readable stats later..
I've applied a patch to show write byte size.
https://github.com/makedumpfile/makedumpfile/commit/0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb
I hope this is used rightly.
Thanks,
Kazu
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/2 Add shorthand option to show report stats
In reply to Julien ThierryProvide shorthand option to enable report messages without needing to set a particular value for message-level.
--- makedumpfile.8 | 5 +++++ makedumpfile.c | 12 +++++++++++- makedumpfile.h | 1 + print_info.c | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-)
makedumpfile.8 +5 -0
@@ -642,6 +642,11 @@ Preferable to be given as the first parameter. Do not write the output dump file while still performing operations specified by other options. +.TP +\fB\-\-show-stats\fR +Display report messages. This is an alternative to enabling bit 4 in the level +provided to --message-level. + .SH ENVIRONMENT VARIABLES .TP 8
makedumpfile.c +11 -1
@@ -11424,13 +11424,14 @@ static struct option longopts[] = { {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, {"dry-run", no_argument, NULL, OPT_DRY_RUN}, + {"show-stats", no_argument, NULL, OPT_SHOW_STATS}, {0, 0, 0, 0} };int main (int argc,char *argv[]) { -int i, opt, flag_debug = FALSE; +int i, opt, flag_debug = FALSE, flag_show_stats = FALSE;if ((info =calloc (1 ,sizeof (struct DumpInfo ))) ==NULL ) { ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n",
@@ -11593,6 +11594,9 @@ main(int argc, char *argv[])case OPT_DRY_RUN : info->flag_dry_run = TRUE;break ; +case OPT_SHOW_STATS : + flag_show_stats = TRUE; +break ;case '?' :MSG ("Commandline parameter is invalid.\n" );MSG ("Try `makedumpfile --help' for more information.\n" );
@@ -11606,6 +11610,12 @@ main(int argc, char *argv[])/* suppress debugging messages */ message_level =DEFAULT_MSG_LEVEL ; +if (flag_show_stats) { + message_level |=ML_PRINT_REPORT_MSG ; +/* Progress indicator interferes with report messages */ + message_level &= ~ML_PRINT_PROGRESS ; + } +if (info->flag_dry_run)/* Suppress progress indicator as dumpfile won't get written */ message_level &= ~ML_PRINT_PROGRESS ;
makedumpfile.h +1 -0
@@ -2366,6 +2366,7 @@ struct elf_prstatus {#define OPT_PARTIAL_DMESG OPT_START+17#define OPT_CHECK_PARAMS OPT_START+18#define OPT_DRY_RUN OPT_START+19 +#define OPT_SHOW_STATS OPT_START+20/* * Function Prototype.
print_info.c +3 -0
@@ -311,6 +311,9 @@ print_usage(void)MSG (" [--dry-run]:\n" );MSG (" This option runs makedumpfile without writting output dump file.\n" );MSG ("\n" ); +MSG (" [--show-stats]:\n" ); +MSG (" This option sets message-level to print report messages\n" ); +MSG ("\n" );MSG (" [-D]:\n" );MSG (" Print debugging message.\n" );MSG ("\n" );
Signature · 7 lines
2.25.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
RE: [MAKEDUMPFILE PATCH 2/2] Add shorthand option to show report stats
-----Original Message-----
Quoted 58 lines
Provide shorthand option to enable report messages without needing to set a particular value for message-level.
Signed-off-by Julien Thierry <[email protected]>--- makedumpfile.8 | 5 +++++ makedumpfile.c | 12 +++++++++++- makedumpfile.h | 1 + print_info.c | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-)makedumpfile.8 +5
-0@@ -642,6 +642,11 @@ Preferable to be given as the first parameter. Do not write the output dump file while still performing operations specified by other options. +.TP +\fB\-\-show-stats\fR +Display report messages. This is an alternative to enabling bit 4 in the level +provided to --message-level. + .SH ENVIRONMENT VARIABLES .TP 8makedumpfile.c +5
-1@@ -11424,13 +11424,14 @@ static struct option longopts[] = { {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, {"dry-run", no_argument, NULL, OPT_DRY_RUN}, + {"show-stats", no_argument, NULL, OPT_SHOW_STATS}, {0, 0, 0, 0} };int main (int argc,char *argv[]) { -int i, opt, flag_debug = FALSE; +int i, opt, flag_debug = FALSE, flag_show_stats = FALSE;if ((info =calloc (1 ,sizeof (struct DumpInfo ))) ==NULL ) { ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n",@@ -11593,6 +11594,9 @@ main(int argc, char *argv[])case OPT_DRY_RUN : info->flag_dry_run = TRUE;break ; +case OPT_SHOW_STATS : + flag_show_stats = TRUE; +break ;case '?' :MSG ("Commandline parameter is invalid.\n" );MSG ("Try `makedumpfile --help' for more information.\n" );
makedumpfile.c main(int argc, char *argv[]) · line 11616
Quoted 7 lines
makedumpfile.c +4
-0@@ -11606,6 +11610,12 @@ main(int argc, char *argv[])/* suppress debugging messages */ message_level =DEFAULT_MSG_LEVEL ; +if (flag_show_stats) { + message_level |=ML_PRINT_REPORT_MSG ; +/* Progress indicator interferes with report messages */ + message_level &= ~ML_PRINT_PROGRESS ;
I personally don't think it's so interfering, should we drop the ML_PRINT_PROGRESS?
Otherwise, looks good to me.
Thanks,
Kazu
Quoted 32 lines
makedumpfile.c +2
-0+ } +if (info->flag_dry_run)/* Suppress progress indicator as dumpfile won't get written */ message_level &= ~ML_PRINT_PROGRESS ;makedumpfile.h +1
-0@@ -2366,6 +2366,7 @@ struct elf_prstatus {#define OPT_PARTIAL_DMESG OPT_START+17#define OPT_CHECK_PARAMS OPT_START+18#define OPT_DRY_RUN OPT_START+19 +#define OPT_SHOW_STATS OPT_START+20/* * Function Prototype. print_info.c +3
-1@@ -311,6 +311,9 @@ print_usage(void)MSG (" [--dry-run]:\n" );MSG (" This option runs makedumpfile without writting output dump file.\n" );MSG ("\n" ); +MSG (" [--show-stats]:\n" ); +MSG (" This option sets message-level to print report messages\n" ); +MSG ("\n" );MSG (" [-D]:\n" );MSG (" Print debugging message.\n" );MSG ("\n" ); --
Quoted 1 line
2.25.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec