Show write byte size in report messages

Backport from upstream:

commit 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb
Author: Kazuhito Hagio <k-hagio-ab@nec.com>
Date:   Thu Feb 4 16:29:06 2021 +0900

    [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>

Signed-off-by: Tao Liu <ltao@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Tao Liu 2021-04-19 22:13:38 +08:00 committed by Kairui Song
parent 8973bd7ed0
commit 0db060c4e2
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,59 @@
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 09/12] [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

View File

@ -105,6 +105,7 @@ Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state
Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch
Patch606: ./kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch
Patch607: ./kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch
Patch608: ./kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@ -125,6 +126,7 @@ tar -z -x -v -f %{SOURCE19}
%patch605 -p1
%patch606 -p1
%patch607 -p1
%patch608 -p1
%ifarch ppc
%define archdef ARCH=ppc