From: Qiao Nuohan <[email protected]>

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 <[email protected]>
---
 makedumpfile.c |   77 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 makedumpfile.h |    2 +
 2 files changed, 75 insertions(+), 4 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 04a6c45..bb931c3 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3846,6 +3846,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;
 
@@ -8823,9 +8844,16 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data 
*cd_header, struct cache_d
                if (!write_kdump_bitmap2_cyclic(&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_cyclic();
@@ -9832,8 +9860,13 @@ writeout_dumpfile(void)
                        goto out;
                if (!write_kdump_bitmap())
                        goto out;
-               if (!write_kdump_pages(&cd_header, &cd_page))
-                       goto out;
+               if (info->num_threads) {
+                       if (!write_kdump_pages_parallel(&cd_header, &cd_page))
+                               goto out;
+               } else {
+                       if (!write_kdump_pages(&cd_header, &cd_page))
+                               goto out;
+               }
                if (!write_kdump_eraseinfo(&cd_page))
                        goto out;
        }
@@ -10847,6 +10880,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) {
@@ -10911,6 +10956,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;
 }
 
@@ -11223,6 +11280,8 @@ static struct option longopts[] = {
        {"non-mmap", no_argument, NULL, OPT_NON_MMAP},
        {"mem-usage", no_argument, NULL, OPT_MEM_USAGE},
        {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE},
+       {"num-threads", required_argument, NULL, OPT_NUM_THREADS},
+       {"num-buffers", required_argument, NULL, OPT_NUM_BUFFERS},
        {0, 0, 0, 0}
 };
 
@@ -11366,6 +11425,12 @@ main(int argc, char *argv[])
                case OPT_SPLITBLOCK_SIZE:
                        info->splitblock_size = atoi(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");
@@ -11509,6 +11574,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);
@@ -11536,6 +11603,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 67c2a38..42a8ee3 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1974,6 +1974,8 @@ struct elf_prstatus {
 #define OPT_NON_MMAP            OPT_START+13
 #define OPT_MEM_USAGE            OPT_START+14
 #define OPT_SPLITBLOCK_SIZE    OPT_START+15
+#define OPT_NUM_THREADS                OPT_START+16
+#define OPT_NUM_BUFFERS                OPT_START+17
 
 /*
  * Function Prototype.
-- 
1.7.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to