kexec-tools/SOURCES/kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch
2021-09-09 19:42:55 +00:00

60 lines
2.0 KiB
Diff

From 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Thu, 4 Feb 2021 16:29:06 +0900
Subject: [PATCH] [PATCH] Show write byte size in report messages
Show write byte size in report messages. This value can be different
from the size of the actual file because of some holes on dumpfile
data structure.
$ makedumpfile --show-stats -l -d 1 vmcore dump.ld1
...
Total pages : 0x0000000000080000
Write bytes : 377686445
...
# ls -l dump.ld1
-rw------- 1 root root 377691573 Feb 4 16:28 dump.ld1
Note that this value should not be used with /proc/kcore to determine
how much disk space is needed for crash dump, because the real memory
usage when a crash occurs can vary widely.
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
index fcd766b..894c88e 100644
--- a/makedumpfile-1.6.8/makedumpfile.c
+++ b/makedumpfile-1.6.8/makedumpfile.c
@@ -48,6 +48,8 @@ char filename_stdout[] = FILENAME_STDOUT;
static unsigned long long cache_hit;
static unsigned long long cache_miss;
+static unsigned long long write_bytes;
+
static void first_cycle(mdf_pfn_t start, mdf_pfn_t max, struct cycle *cycle)
{
cycle->start_pfn = round(start, info->pfn_cyclic);
@@ -4715,6 +4717,8 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name)
{
int status, written_size = 0;
+ write_bytes += buf_size;
+
if (info->flag_dry_run)
return TRUE;
@@ -10002,6 +10006,7 @@ print_report(void)
REPORT_MSG("Memory Hole : 0x%016llx\n", pfn_memhole);
REPORT_MSG("--------------------------------------------------\n");
REPORT_MSG("Total pages : 0x%016llx\n", info->max_mapnr);
+ REPORT_MSG("Write bytes : %llu\n", write_bytes);
REPORT_MSG("\n");
REPORT_MSG("Cache hit: %lld, miss: %lld", cache_hit, cache_miss);
if (cache_hit + cache_miss)
--
2.29.2