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