[PATCH v2 09/10] Make makedumpfile available to read and compress pages parallelly
Zhou Wenjian
zhouwj-fnst at cn.fujitsu.com
Fri Jun 19 01:56:43 PDT 2015
From: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
Using this patch, it is available to use multiple threads to read
and compress pages. This parallel process will save time.
Currently, sadump and xen kdump is not supported.
Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
---
makedumpfile.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
makedumpfile.h | 2 +
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 04d5e92..8ffe174 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3857,6 +3857,27 @@ out:
DEBUG_MSG("Buffer size for the cyclic mode: %ld\n", info->bufsize_cyclic);
}
+ if (info->num_threads) {
+ if (is_xen_memory()) {
+ MSG("'--num-threads' option is disable,\n");
+ MSG("because %s is Xen's memory core image.\n",
+ info->name_memory);
+ return FALSE;
+ }
+
+ if (info->flag_sadump) {
+ MSG("'--num-threads' option is disable,\n");
+ MSG("because %s is sadump %s format.\n",
+ info->name_memory, sadump_format_type_name());
+ return FALSE;
+ }
+
+ if (!initial_for_parallel()) {
+ MSG("Fail to initial for parallel process.\n");
+ return FALSE;
+ }
+ }
+
if (!is_xen_memory() && !cache_init())
return FALSE;
@@ -7906,9 +7927,16 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
if (!write_kdump_bitmap2(&cycle))
return FALSE;
- if (!write_kdump_pages_cyclic(cd_header, cd_page, &pd_zero,
+ if (info->num_threads) {
+ if (!write_kdump_pages_parallel_cyclic(cd_header,
+ cd_page, &pd_zero,
+ &offset_data, &cycle))
+ return FALSE;
+ } else {
+ if (!write_kdump_pages_cyclic(cd_header, cd_page, &pd_zero,
&offset_data, &cycle))
- return FALSE;
+ return FALSE;
+ }
}
free_bitmap2_buffer();
@@ -9875,6 +9903,18 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->flag_sadump_diskset && !sadump_is_supported_arch())
return FALSE;
+ if (info->num_threads) {
+ if (info->flag_split) {
+ MSG("--num-threads cannot used with --split.\n");
+ return FALSE;
+ }
+
+ if (info->flag_elf_dumpfile) {
+ MSG("--num-threads cannot used with ELF format.\n");
+ return FALSE;
+ }
+ }
+
if ((argc == optind + 2) && !info->flag_flatten
&& !info->flag_split
&& !info->flag_sadump_diskset) {
@@ -9939,6 +9979,18 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
} else
return FALSE;
+ if (info->num_threads) {
+ if ((info->parallel_info =
+ malloc(sizeof(parallel_info_t) * info->num_threads))
+ == NULL) {
+ MSG("Can't allocate memory for parallel_info.\n");
+ return FALSE;
+ }
+
+ memset(info->parallel_info, 0, sizeof(parallel_info_t)
+ * info->num_threads);
+ }
+
return TRUE;
}
@@ -10255,6 +10307,8 @@ static struct option longopts[] = {
{"mem-usage", no_argument, NULL, OPT_MEM_USAGE},
{"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE},
{"work-dir", required_argument, NULL, OPT_WORKING_DIR},
+ {"num-threads", required_argument, NULL, OPT_NUM_THREADS},
+ {"num-buffers", required_argument, NULL, OPT_NUM_BUFFERS},
{0, 0, 0, 0}
};
@@ -10399,6 +10453,12 @@ main(int argc, char *argv[])
case OPT_WORKING_DIR:
info->working_dir = optarg;
break;
+ case OPT_NUM_THREADS:
+ info->num_threads = atoi(optarg);
+ break;
+ case OPT_NUM_BUFFERS:
+ info->num_buffers = atoi(optarg);
+ break;
case '?':
MSG("Commandline parameter is invalid.\n");
MSG("Try `makedumpfile --help' for more information.\n");
@@ -10542,6 +10602,8 @@ out:
else if (!info->flag_mem_usage)
MSG("makedumpfile Completed.\n");
+ free_for_parallel();
+
if (info) {
if (info->dh_memory)
free(info->dh_memory);
@@ -10569,6 +10631,8 @@ out:
free(info->p2m_mfn_frame_list);
if (info->page_buf != NULL)
free(info->page_buf);
+ if (info->parallel_info != NULL)
+ free(info->parallel_info);
free(info);
if (splitblock) {
diff --git a/makedumpfile.h b/makedumpfile.h
index d0760d9..9dfe5b6 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -2032,6 +2032,8 @@ struct elf_prstatus {
#define OPT_MEM_USAGE OPT_START+13
#define OPT_SPLITBLOCK_SIZE OPT_START+14
#define OPT_WORKING_DIR OPT_START+15
+#define OPT_NUM_THREADS OPT_START+16
+#define OPT_NUM_BUFFERS OPT_START+17
/*
* Function Prototype.
--
1.7.1
More information about the kexec
mailing list