RE: [PATCH] makedumpfile: printk: add support for lockless ringbuffer

2020-11-24 Thread 萩尾 一仁
Hi John,

-Original Message-
> Hi Kazu,
> 
> On 2020-11-20, HAGIO KAZUHITO(萩尾 一仁)   wrote:
> > Thank you for confirming and testing.
> > I will merge this after a few slight fixes and more tests.
> 
> After looking more closely, I see that your patch is still using the old
> state flags. With the current version, there is now a value-based state
> field. Both state values 1 (committed) and 2 (finalized) are valid for
> printing. Should I submit a follow-up patch? Or are these the "slight
> fixes" you are referring to?

Thank you for pointing it out!  Could you submit a follow-up patch?
It would be very helpful.

Thanks,
Kazu
___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[MAKEDUMPFILE PATCH 1/2] Add option to prevent writing the dumpfile

2020-11-24 Thread Julien Thierry
Add a --dry-run option to run all operations without writing the
dump to the output file.

Signed-off-by: Julien Thierry 
---
 makedumpfile.8 |  5 +
 makedumpfile.c | 33 +++--
 makedumpfile.h |  2 ++
 print_info.c   |  3 +++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.8 b/makedumpfile.8
index 2fe2cd0..39a63ba 100644
--- a/makedumpfile.8
+++ b/makedumpfile.8
@@ -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
diff --git a/makedumpfile.c b/makedumpfile.c
index cdde040..90258f3 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -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_

[MAKEDUMPFILE PATCH 2/2] Add shorthand option to show report stats

2020-11-24 Thread Julien Thierry
Provide shorthand option to enable report messages without needing
to set a particular value for message-level.

Signed-off-by: Julien Thierry 
---
 makedumpfile.8 |  5 +
 makedumpfile.c | 12 +++-
 makedumpfile.h |  1 +
 print_info.c   |  3 +++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.8 b/makedumpfile.8
index 39a63ba..ec1e625 100644
--- a/makedumpfile.8
+++ b/makedumpfile.8
@@ -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
diff --git a/makedumpfile.c b/makedumpfile.c
index 90258f3..db31a03 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -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;
diff --git a/makedumpfile.h b/makedumpfile.h
index 58126cb..18c8b0b 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -2366,6 +2366,7 @@ struct elf_prstatus {
 #define OPT_PARTIAL_DMESG   OPT_START+17
 #define OPT_CHECK_PARAMSOPT_START+18
 #define OPT_DRY_RUN OPT_START+19
+#define OPT_SHOW_STATS  OPT_START+20
 
 /*
  * Function Prototype.
diff --git a/print_info.c b/print_info.c
index d2b0cb7..6ebf611 100644
--- a/print_info.c
+++ b/print_info.c
@@ -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");
-- 
2.25.4


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[MAKDUMPFILE PATCH 0/2] Get stats without writing dumpfile

2020-11-24 Thread Julien Thierry
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
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


RE: [PATCH] makedumpfile: printk: add support for lockless ringbuffer

2020-11-24 Thread John Ogness
Hi Kazu,

On 2020-11-20, HAGIO KAZUHITO(萩尾 一仁) wrote:
> Thank you for confirming and testing.
> I will merge this after a few slight fixes and more tests.

After looking more closely, I see that your patch is still using the old
state flags. With the current version, there is now a value-based state
field. Both state values 1 (committed) and 2 (finalized) are valid for
printing. Should I submit a follow-up patch? Or are these the "slight
fixes" you are referring to?

John Ogness

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec