e83d5f939a
Release: crash-8.0.5-2 Resolves: RHEL-43414 Signed-off-by: Tao Liu <ltao@redhat.com>
112 lines
3.4 KiB
Diff
112 lines
3.4 KiB
Diff
From af2ac4c41df6d87f090613ecf3521ca073754cb0 Mon Sep 17 00:00:00 2001
|
|
From: chenguanyou <chenguanyou@xiaomi.com>
|
|
Date: Wed, 24 Apr 2024 17:00:20 +0800
|
|
Subject: [PATCH 2/9] Cleanup: replace struct zspage_5_17 with union
|
|
|
|
This patch is a refactoring on commit [1], and has no functional
|
|
change. The reason is that the structure of zspage has not changed,
|
|
just new bits have been introduced. So a union is better to reduce
|
|
code replication.
|
|
|
|
[1] 0172e35083b5 ("Fix "rd" command to display data on zram on Linux 5.17 and later")
|
|
|
|
Signed-off-by: chenguanyou <chenguanyou@xiaomi.com>
|
|
---
|
|
defs.h | 32 +++++++++++++++-----------------
|
|
diskdump.c | 15 ++++++---------
|
|
2 files changed, 21 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/defs.h b/defs.h
|
|
index 3cb8e63..01f316e 100644
|
|
--- a/defs.h
|
|
+++ b/defs.h
|
|
@@ -7407,28 +7407,26 @@ ulong try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulon
|
|
#define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT)
|
|
|
|
struct zspage {
|
|
- struct {
|
|
- unsigned int fullness : 2;
|
|
- unsigned int class : 9;
|
|
- unsigned int isolated : 3;
|
|
- unsigned int magic : 8;
|
|
+ union {
|
|
+ unsigned int flag_bits;
|
|
+ struct {
|
|
+ unsigned int fullness : 2;
|
|
+ unsigned int class : 9;
|
|
+ unsigned int isolated : 3;
|
|
+ unsigned int magic : 8;
|
|
+ } v0;
|
|
+ struct {
|
|
+ unsigned int huge : 1;
|
|
+ unsigned int fullness : 2;
|
|
+ unsigned int class : 9;
|
|
+ unsigned int isolated : 3;
|
|
+ unsigned int magic : 8;
|
|
+ } v5_17;
|
|
};
|
|
unsigned int inuse;
|
|
unsigned int freeobj;
|
|
};
|
|
|
|
-struct zspage_5_17 {
|
|
- struct {
|
|
- unsigned int huge : 1;
|
|
- unsigned int fullness : 2;
|
|
- unsigned int class : 9;
|
|
- unsigned int isolated : 3;
|
|
- unsigned int magic : 8;
|
|
- };
|
|
- unsigned int inuse;
|
|
- unsigned int freeobj;
|
|
-};
|
|
-
|
|
/*
|
|
* makedumpfile.c
|
|
*/
|
|
diff --git a/diskdump.c b/diskdump.c
|
|
index 4a473e1..1f7118c 100644
|
|
--- a/diskdump.c
|
|
+++ b/diskdump.c
|
|
@@ -2820,7 +2820,6 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
|
|
{
|
|
ulong obj, off, class, page, zspage;
|
|
struct zspage zspage_s;
|
|
- struct zspage_5_17 zspage_5_17_s;
|
|
physaddr_t paddr;
|
|
unsigned int obj_idx, class_idx, size;
|
|
ulong pages[2], sizes[2];
|
|
@@ -2834,15 +2833,13 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
|
|
readmem(page + OFFSET(page_private), KVADDR, &zspage,
|
|
sizeof(void *), "page_private", FAULT_ON_ERROR);
|
|
|
|
+ readmem(zspage, KVADDR, &zspage_s, sizeof(struct zspage), "zspage", FAULT_ON_ERROR);
|
|
if (VALID_MEMBER(zspage_huge)) {
|
|
- readmem(zspage, KVADDR, &zspage_5_17_s,
|
|
- sizeof(struct zspage_5_17), "zspage_5_17", FAULT_ON_ERROR);
|
|
- class_idx = zspage_5_17_s.class;
|
|
- zs_magic = zspage_5_17_s.magic;
|
|
+ class_idx = zspage_s.v5_17.class;
|
|
+ zs_magic = zspage_s.v5_17.magic;
|
|
} else {
|
|
- readmem(zspage, KVADDR, &zspage_s, sizeof(struct zspage), "zspage", FAULT_ON_ERROR);
|
|
- class_idx = zspage_s.class;
|
|
- zs_magic = zspage_s.magic;
|
|
+ class_idx = zspage_s.v0.class;
|
|
+ zs_magic = zspage_s.v0.magic;
|
|
}
|
|
|
|
if (zs_magic != ZSPAGE_MAGIC)
|
|
@@ -2888,7 +2885,7 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
|
|
|
|
out:
|
|
if (VALID_MEMBER(zspage_huge)) {
|
|
- if (!zspage_5_17_s.huge)
|
|
+ if (!zspage_s.v5_17.huge)
|
|
return (zram_buf + ZS_HANDLE_SIZE);
|
|
} else {
|
|
readmem(page, KVADDR, &obj, sizeof(void *), "page flags", FAULT_ON_ERROR);
|
|
--
|
|
2.40.1
|
|
|