when zspage define 'huge', crash-utility zram decompress fail.
we need to be compatible with the previous kernel,
so we can't define 'huge' directly in zspage, just move to the right when calculating.
Link: https://lkml.kernel.org/r/20211115185909.3949505-6-minchan@xxxxxxxxxx
Signed-off-by: chenguanyou <chenguanyou@xxxxxxxxxx>
---
defs.h | 4 ++++
diskdump.c | 21 ++++++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/defs.h b/defs.h
index 96a7a2a..ac19410 100644
--- a/defs.h
+++ b/defs.h
@@ -2225,6 +2225,7 @@ struct offset_table { /* stash of commonly-used offsets */
long module_memory_base;
long module_memory_size;
long irq_data_irq;
+ long zspage_huge;
};
struct size_table { /* stash of commonly-used sizes */
@@ -7212,6 +7213,9 @@ ulong try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulon
#define ZRAM_FLAG_SAME_BIT (1<<25)
struct zspage {
struct {
+ // Link: https://lkml.kernel.org/r/20211115185909.3949505-6-minchan@xxxxxxxxxx
+ // unsigned int huge : 1; // compatible
+
unsigned int fullness : 2;
unsigned int class : 9;
unsigned int isolated : 3;
diff --git a/diskdump.c b/diskdump.c
index 2c284ff..891ee2f 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2764,6 +2764,8 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
physaddr_t paddr;
unsigned int obj_idx, class_idx, size;
ulong pages[2], sizes[2];
+ ulong zspage_shift = 0;
+ ulong zs_magic;
readmem(handle, KVADDR, &obj, sizeof(void *), "zram entry", FAULT_ON_ERROR);
obj >>= OBJ_TAG_BITS;
@@ -2774,9 +2776,13 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
sizeof(void *), "page_private", FAULT_ON_ERROR);
readmem(zspage, KVADDR, &zspage_s, sizeof(struct zspage), "zspage", FAULT_ON_ERROR);
- class_idx = zspage_s.class;
- if (zspage_s.magic != ZSPAGE_MAGIC)
- error(FATAL, "zspage magic incorrect: %x\n", zspage_s.magic);
+ if (VALID_MEMBER(zspage_huge))
+ zspage_shift = 1; // huge shift
+
+ class_idx = zspage_s.class >> zspage_shift;
+ zs_magic = zspage_s.magic >> zspage_shift;
+ if (zs_magic != ZSPAGE_MAGIC)
+ error(FATAL, "zspage magic incorrect: %x\n", zs_magic);
class = pool + OFFSET(zspoll_size_class);
class += (class_idx * sizeof(void *));
@@ -2794,8 +2800,13 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
}
pages[0] = page;
- readmem(page + OFFSET(page_freelist), KVADDR, &pages[1],
- sizeof(void *), "page_freelist", FAULT_ON_ERROR);
+ if (VALID_MEMBER(page_freelist)) {
+ readmem(page + OFFSET(page_freelist), KVADDR, &pages[1],
+ sizeof(void *), "page_freelist", FAULT_ON_ERROR);
+ } else {
+ readmem(page + OFFSET(page_index), KVADDR, &pages[1],
+ sizeof(void *), "page_index", FAULT_ON_ERROR);
+ }
sizes[0] = PAGESIZE() - off;
sizes[1] = size - sizes[0];
if (!is_page_ptr(pages[0], &paddr)) {
--
2.39.0
|
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki