Blame SOURCES/kexec-tools-2.0.8-makedumpfile-Add-module-of-generating-table.patch

a6d77e
Return-Path: yishimat@redhat.com
a6d77e
Received: from zmta05.collab.prod.int.phx2.redhat.com (LHLO
a6d77e
 zmta05.collab.prod.int.phx2.redhat.com) (10.5.81.12) by
a6d77e
 zmail24.collab.prod.int.phx2.redhat.com with LMTP; Thu, 2 Jul 2015 01:08:58
a6d77e
 -0400 (EDT)
a6d77e
Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27])
a6d77e
	by zmta05.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 6922D17C114;
a6d77e
	Thu,  2 Jul 2015 01:08:58 -0400 (EDT)
a6d77e
Received: from [10.3.112.13] ([10.3.112.13])
a6d77e
	by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6258t32026109;
a6d77e
	Thu, 2 Jul 2015 01:08:56 -0400
a6d77e
Subject: [RHEL7.2 PATCH resend v3 3/5] Add module of generating table.
a6d77e
To: kexec-kdump-list@redhat.com
a6d77e
References: <55929D94.4020500@redhat.com> <5594C62C.3030407@redhat.com>
a6d77e
Cc: Minfei Huang <mhuang@redhat.com>, bhe@redhat.com, yishimat@redhat.com
a6d77e
From: Yasuaki Ishimatsu <yishimat@redhat.com>
a6d77e
Message-ID: <5594C766.5010801@redhat.com>
a6d77e
Date: Thu, 2 Jul 2015 01:08:54 -0400
a6d77e
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101
a6d77e
 Thunderbird/38.0.1
a6d77e
MIME-Version: 1.0
a6d77e
In-Reply-To: <5594C62C.3030407@redhat.com>
a6d77e
Content-Type: text/plain; charset=utf-8
a6d77e
Content-Transfer-Encoding: 7bit
a6d77e
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27
a6d77e
Content-Length: 5064
a6d77e
a6d77e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1182379
a6d77e
a6d77e
The patch is back ported directory from the following upstream commit:
a6d77e
a6d77e
commit 28e367cb78258e5d8d89edc5435804495661d1a3
a6d77e
Author: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
a6d77e
Date:   Fri Nov 7 09:43:26 2014 +0900
a6d77e
a6d77e
    [PATCH v5 3/5] Add module of generating table.
a6d77e
a6d77e
    Set block size and generate basic information of block table.
a6d77e
a6d77e
    Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
a6d77e
    Signed-off-by: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
a6d77e
a6d77e
Resolves: rhbz#1182379
a6d77e
Signed-off-by: Yasuaki Ishimatsu <yishimat@redhat.com>
a6d77e
a6d77e
---
a6d77e
 makedumpfile-1.5.7/makedumpfile.c |  109 ++++++++++++++++++++++++++++++++++++-
a6d77e
 makedumpfile-1.5.7/makedumpfile.h |    4 ++
a6d77e
 2 files changed, 112 insertions(+), 1 deletions(-)
a6d77e
a6d77e
diff --git a/makedumpfile-1.5.7/makedumpfile.c b/makedumpfile-1.5.7/makedumpfile.c
a6d77e
index 4d2f077..5ffe8e1 100644
a6d77e
--- a/makedumpfile-1.5.7/makedumpfile.c
a6d77e
+++ b/makedumpfile-1.5.7/makedumpfile.c
a6d77e
@@ -5208,7 +5208,14 @@ create_dump_bitmap(void)
a6d77e
 	if (info->flag_cyclic) {
a6d77e
 		if (!prepare_bitmap2_buffer_cyclic())
a6d77e
 			goto out;
a6d77e
-		info->num_dumpable = get_num_dumpable_cyclic();
a6d77e
+		if (info->flag_split) {
a6d77e
+			if (!prepare_splitblock_table())
a6d77e
+				goto out;
a6d77e
+
a6d77e
+			info->num_dumpable = get_num_dumpable_cyclic_withsplit();
a6d77e
+		} else {
a6d77e
+			info->num_dumpable = get_num_dumpable_cyclic();
a6d77e
+		}
a6d77e
a6d77e
 		if (!info->flag_elf_dumpfile)
a6d77e
 			free_bitmap2_buffer_cyclic();
a6d77e
@@ -5745,6 +5752,61 @@ read_from_splitblock_table(char *entry)
a6d77e
 	return value;
a6d77e
 }
a6d77e
a6d77e
+/*
a6d77e
+ * The splitblock size is specified as Kbyte with --splitblock-size <size> option.
a6d77e
+ * If not specified, set default value.
a6d77e
+ */
a6d77e
+int
a6d77e
+check_splitblock_size(void)
a6d77e
+{
a6d77e
+	if (info->splitblock_size) {
a6d77e
+		info->splitblock_size <<= 10;
a6d77e
+		if (info->splitblock_size == 0) {
a6d77e
+			ERRMSG("The splitblock size could not be 0. %s.\n",
a6d77e
+				strerror(errno));
a6d77e
+			return FALSE;
a6d77e
+		}
a6d77e
+		if (info->splitblock_size % info->page_size != 0) {
a6d77e
+			ERRMSG("The splitblock size must be align to page_size. %s.\n",
a6d77e
+				strerror(errno));
a6d77e
+			return FALSE;
a6d77e
+		}
a6d77e
+	} else {
a6d77e
+		info->splitblock_size = DEFAULT_SPLITBLOCK_SIZE;
a6d77e
+	}
a6d77e
+
a6d77e
+	return TRUE;
a6d77e
+}
a6d77e
+
a6d77e
+int
a6d77e
+prepare_splitblock_table(void)
a6d77e
+{
a6d77e
+	size_t table_size;
a6d77e
+
a6d77e
+	if (!check_splitblock_size())
a6d77e
+		return FALSE;
a6d77e
+
a6d77e
+	if ((splitblock = calloc(1, sizeof(struct SplitBlock))) == NULL) {
a6d77e
+		ERRMSG("Can't allocate memory for the splitblock. %s.\n",
a6d77e
+			strerror(errno));
a6d77e
+		return FALSE;
a6d77e
+	}
a6d77e
+
a6d77e
+	splitblock->page_per_splitblock = info->splitblock_size / info->page_size;
a6d77e
+	splitblock->num = divideup(info->max_mapnr, splitblock->page_per_splitblock);
a6d77e
+	splitblock->entry_size = calculate_entry_size();
a6d77e
+	table_size = splitblock->entry_size * splitblock->num;
a6d77e
+
a6d77e
+	splitblock->table = (char *)calloc(sizeof(char), table_size);
a6d77e
+	if (!splitblock->table) {
a6d77e
+		ERRMSG("Can't allocate memory for the splitblock_table. %s.\n",
a6d77e
+			 strerror(errno));
a6d77e
+		return FALSE;
a6d77e
+	}
a6d77e
+
a6d77e
+	return TRUE;
a6d77e
+}
a6d77e
+
a6d77e
 mdf_pfn_t
a6d77e
 get_num_dumpable(void)
a6d77e
 {
a6d77e
@@ -5760,6 +5822,45 @@ get_num_dumpable(void)
a6d77e
 	return num_dumpable;
a6d77e
 }
a6d77e
a6d77e
+/*
a6d77e
+ * generate splitblock_table
a6d77e
+ * modified from function get_num_dumpable_cyclic
a6d77e
+ */
a6d77e
+mdf_pfn_t
a6d77e
+get_num_dumpable_cyclic_withsplit(void)
a6d77e
+{
a6d77e
+	mdf_pfn_t pfn, num_dumpable = 0;
a6d77e
+	mdf_pfn_t dumpable_pfn_num = 0, pfn_num = 0;
a6d77e
+	struct cycle cycle = {0};
a6d77e
+	int pos = 0;
a6d77e
+
a6d77e
+	pfn_memhole = info->max_mapnr;
a6d77e
+
a6d77e
+	for_each_cycle(0, info->max_mapnr, &cycle) {
a6d77e
+		if (!exclude_unnecessary_pages_cyclic(&cycle))
a6d77e
+			return FALSE;
a6d77e
+
a6d77e
+		if (info->flag_mem_usage)
a6d77e
+			exclude_zero_pages_cyclic(&cycle);
a6d77e
+
a6d77e
+		for (pfn = cycle.start_pfn; pfn < cycle.end_pfn; pfn++) {
a6d77e
+			if (is_dumpable_cyclic(info->partial_bitmap2, pfn, &cycle)) {
a6d77e
+				num_dumpable++;
a6d77e
+				dumpable_pfn_num++;
a6d77e
+			}
a6d77e
+			if (++pfn_num >= splitblock->page_per_splitblock) {
a6d77e
+				write_into_splitblock_table(splitblock->table + pos,
a6d77e
+							    dumpable_pfn_num);
a6d77e
+				pos += splitblock->entry_size;
a6d77e
+				pfn_num = 0;
a6d77e
+				dumpable_pfn_num = 0;
a6d77e
+			}
a6d77e
+		}
a6d77e
+	}
a6d77e
+
a6d77e
+	return num_dumpable;
a6d77e
+}
a6d77e
+
a6d77e
 mdf_pfn_t
a6d77e
 get_num_dumpable_cyclic(void)
a6d77e
 {
a6d77e
@@ -9717,6 +9818,12 @@ out:
a6d77e
 		if (info->page_buf != NULL)
a6d77e
 			free(info->page_buf);
a6d77e
 		free(info);
a6d77e
+
a6d77e
+		if (splitblock) {
a6d77e
+			if (splitblock->table)
a6d77e
+				free(splitblock->table);
a6d77e
+			free(splitblock);
a6d77e
+		}
a6d77e
 	}
a6d77e
 	free_elf_info();
a6d77e
a6d77e
diff --git a/makedumpfile-1.5.7/makedumpfile.h b/makedumpfile-1.5.7/makedumpfile.h
a6d77e
index a263631..f9d9332 100644
a6d77e
--- a/makedumpfile-1.5.7/makedumpfile.h
a6d77e
+++ b/makedumpfile-1.5.7/makedumpfile.h
a6d77e
@@ -1178,6 +1178,8 @@ extern struct DumpInfo		*info;
a6d77e
 /*
a6d77e
  * for cyclic_splitting mode,Manage memory by splitblock
a6d77e
  */
a6d77e
+#define DEFAULT_SPLITBLOCK_SIZE (1LL << 30)
a6d77e
+
a6d77e
 struct SplitBlock {
a6d77e
 	char *table;
a6d77e
 	long long num;
a6d77e
@@ -1888,9 +1890,11 @@ struct elf_prstatus {
a6d77e
  * Function Prototype.
a6d77e
  */
a6d77e
 mdf_pfn_t get_num_dumpable_cyclic(void);
a6d77e
+mdf_pfn_t get_num_dumpable_cyclic_withsplit(void);
a6d77e
 int get_loads_dumpfile_cyclic(void);
a6d77e
 int initial_xen(void);
a6d77e
 unsigned long long get_free_memory_size(void);
a6d77e
 int calculate_cyclic_buffer_size(void);
a6d77e
+int prepare_splitblock_table(void);
a6d77e
a6d77e
 #endif /* MAKEDUMPFILE_H */
a6d77e
-- 
a6d77e
1.7.1
a6d77e