Blame SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch

ab224c
From e23dc0a1aa5fa7a4429f72ff1c2fe87a87291065 Mon Sep 17 00:00:00 2001
ab224c
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
ab224c
Date: Tue, 17 Sep 2013 15:29:38 +0900
ab224c
Subject: [PATCH] [PATCH 2/2] cache: Reuse entry in pending list.
ab224c
ab224c
Currently, sadump_virt_phys_base() fails to calculate phys_base as
ab224c
below:
ab224c
ab224c
$ /pub/repos/makedumpfile/makedumpfile -f -p -d 31 -x /pub3/vmcores/comparevmcore_data/vmlinux-2.6.18-363.el5 /pub3/vmcores/comparevmcore_data/vmcore-2.6.18-363.el5-sadump /pub3/vmcores/comparevmcore_data/vmcore-pd31
ab224c
Switched running mode from cyclic to non-cyclic,
ab224c
because the cyclic mode doesn't support sadump format.
ab224c
readmem: type_addr: 1, addr:296020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff296020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff396020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff496020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff596020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff696020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff796020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff896020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffff996020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffffa96020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffffb96020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffffc96020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffffd96020, size:13
ab224c
readmem: type_addr: 1, addr:ffffffffffe96020, size:13
ab224c
readmem: type_addr: 1, addr:fffffffffff96020, size:13
ab224c
readmem: type_addr: 1, addr:96020, size:13
ab224c
readmem: type_addr: 1, addr:196020, size:13
ab224c
readmem: type_addr: 1, addr:296020, size:13
ab224c
readmem: type_addr: 1, addr:396020, size:13
ab224c
readmem: type_addr: 1, addr:496020, size:13
ab224c
readmem: type_addr: 1, addr:596020, size:13
ab224c
readmem: type_addr: 1, addr:696020, size:13
ab224c
readmem: type_addr: 1, addr:796020, size:13
ab224c
readmem: type_addr: 1, addr:896020, size:13
ab224c
readmem: type_addr: 1, addr:996020, size:13
ab224c
readmem: type_addr: 1, addr:a96020, size:13
ab224c
readmem: type_addr: 1, addr:b96020, size:13
ab224c
readmem: type_addr: 1, addr:c96020, size:13
ab224c
readmem: type_addr: 1, addr:d96020, size:13
ab224c
readmem: type_addr: 1, addr:e96020, size:13
ab224c
readmem: type_addr: 1, addr:f96020, size:13
ab224c
readmem: type_addr: 1, addr:1096020, size:13
ab224c
readmem: type_addr: 1, addr:1196020, size:13
ab224c
readmem: type_addr: 1, addr:1296020, size:13
ab224c
readmem: type_addr: 0, addr:ffffffff8045e260, size:32
ab224c
cpu_online_mask_init: Can't read cpu_online_mask memory.
ab224c
ab224c
makedumpfile Failed.
ab224c
ab224c
By git bisect, I found this bug is caused by the following commit:
ab224c
ab224c
commit 0aff0e5174d0708bf1bfb039ab863e1fea8a1029
ab224c
Author: Petr Tesarik <ptesarik@suse.cz>
ab224c
Date:   Wed Oct 31 16:12:47 2012 +0900
ab224c
ab224c
    [PATCH] keep dumpfile pages in a cache.
ab224c
ab224c
Then, I found this bug happens in the following senario.
ab224c
ab224c
If one of the readpage_xxx() methods fails reading 8 pages in a row, 8
ab224c
entries in pool are fully contained in pending list. Then,
ab224c
cache_alloc() returns NULL and this continues forever in the
ab224c
execution. In other words, there's assumption in cache_alloc() that if
ab224c
pool is fully used, they are fully in used list, not in pending list
ab224c
at all. However, the buggy path here breaks the assumption. This patch
ab224c
changes cache_alloc() so that it first tries to reuse enty in pending
ab224c
list if exists.
ab224c
ab224c
In fact, I found this bug in ad-hoc phys_base calculation performed in
ab224c
sadump_virt_phys_base(). However, I fixed cache side since this bug
ab224c
can occur in general on every vmcore format. Crash dump can contain
ab224c
broken data in any part of vmcore and so requested physical address to
ab224c
read can be broken likewise.
ab224c
ab224c
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
ab224c
---
ab224c
 cache.c | 25 +++++++++++++------------
ab224c
 1 file changed, 13 insertions(+), 12 deletions(-)
ab224c
ab224c
diff --git a/makedumpfile-1.5.4/cache.c b/makedumpfile-1.5.4/cache.c
ab224c
index dad8d80..0dd957c 100644
ab224c
--- a/makedumpfile-1.5.4/cache.c
ab224c
+++ b/makedumpfile-1.5.4/cache.c
ab224c
@@ -103,19 +103,20 @@ cache_alloc(unsigned long long paddr)
ab224c
 {
ab224c
 	struct cache_entry *entry = NULL;
ab224c
 
ab224c
-	if (avail)
ab224c
+	if (avail) {
ab224c
 		entry = &pool[--avail];
ab224c
-
ab224c
-	if (!entry) {
ab224c
-		if (used.tail) {
ab224c
-			entry = used.tail;
ab224c
-			remove_entry(&used, entry);
ab224c
-		} else
ab224c
-			return NULL;
ab224c
-	}
ab224c
-
ab224c
-	entry->paddr = paddr;
ab224c
-	add_entry(&pending, entry);
ab224c
+		entry->paddr = paddr;
ab224c
+		add_entry(&pending, entry);
ab224c
+	} else if (pending.tail) {
ab224c
+		entry = pending.tail;
ab224c
+		entry->paddr = paddr;
ab224c
+	} else if (used.tail) {
ab224c
+		entry = used.tail;
ab224c
+		remove_entry(&used, entry);
ab224c
+		entry->paddr = paddr;
ab224c
+		add_entry(&pending, entry);
ab224c
+	} else
ab224c
+		return NULL;
ab224c
 
ab224c
 	return entry->bufptr;
ab224c
 }
ab224c
-- 
ab224c
1.8.3.1
ab224c