[Crash-utility] Patches for zram, swap cache fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
Sharing 3 changes for zram regarding swap cache handling. Please have a look.

Subject: [PATCH 1/3] zram, swap cache missing page tree offset
Subject: [PATCH 2/3] zram, swap cache entries are pointer to struct page
Subject: [PATCH 3/3] zram, exclude shadow entries from swap cache lookup

Thanks
Johan
From 7cc73ed60d78fc173acc9367884561f3cdee9fab Mon Sep 17 00:00:00 2001
From: Johan Erlandsson <johan.erlandsson@xxxxxxxx>
Date: Fri, 20 Oct 2023 19:10:52 +0200
Subject: [PATCH 1/3] zram, swap cache missing page tree offset

The radix or xarray start at an offset inside struct address_space.
---
 diskdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/diskdump.c b/diskdump.c
index 0fe46f4..f3483d8 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2901,7 +2901,8 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
 	swp_space += (swp_offset >> SWAP_ADDRESS_SPACE_SHIFT) * SIZE(address_space);
 
 	lp.index = swp_offset;
-	if ((is_xarray ? do_xarray : do_radix_tree)(swp_space, RADIX_TREE_SEARCH, &lp)) {
+	if ((is_xarray ? do_xarray : do_radix_tree)
+		(swp_space+OFFSET(address_space_page_tree), RADIX_TREE_SEARCH, &lp)) {
 		readmem((ulong)lp.value, KVADDR, &page, sizeof(void *),
 				"swap_cache page", FAULT_ON_ERROR);
 		if (!is_page_ptr(page, &paddr)) {
-- 
2.42.0

From b828f5f653145129b0f2974704aa03d32c67c1c7 Mon Sep 17 00:00:00 2001
From: Johan Erlandsson <johan.erlandsson@xxxxxxxx>
Date: Thu, 9 Nov 2023 16:13:29 +0100
Subject: [PATCH 2/3] zram, swap cache entries are pointer to struct page

The entries in radix, xarray (swap cache) are address to struct page.
---
 diskdump.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/diskdump.c b/diskdump.c
index f3483d8..6bd8271 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2903,9 +2903,7 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
 	lp.index = swp_offset;
 	if ((is_xarray ? do_xarray : do_radix_tree)
 		(swp_space+OFFSET(address_space_page_tree), RADIX_TREE_SEARCH, &lp)) {
-		readmem((ulong)lp.value, KVADDR, &page, sizeof(void *),
-				"swap_cache page", FAULT_ON_ERROR);
-		if (!is_page_ptr(page, &paddr)) {
+		if (!is_page_ptr((ulong)lp.value, &paddr)) {
 			error(WARNING, "radix page: %lx: not a page pointer\n", lp.value);
 			return NULL;
 		}
-- 
2.42.0

From 8d04ea2d6110fa7a7a5453d98ade525de1b89585 Mon Sep 17 00:00:00 2001
From: Johan Erlandsson <johan.erlandsson@xxxxxxxx>
Date: Mon, 23 Oct 2023 15:42:32 +0200
Subject: [PATCH 3/3] zram, exclude shadow entries from swap cache lookup

radix or xarray can contain shadow entries from previous page
entries. These should be ignored when looking for a page pointer.
---
 diskdump.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/diskdump.c b/diskdump.c
index 6bd8271..590762d 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2871,6 +2871,17 @@ out:
 	return zram_buf;
 }
 
+static inline bool radix_tree_exceptional_entry(ulong entry)
+{
+	return entry & RADIX_TREE_EXCEPTIONAL_ENTRY;
+}
+
+/* this already exists in maple_tree.h add to defs.h ? */
+static inline bool xa_is_value(ulong entry)
+{
+	return entry & 1;
+}
+
 static unsigned char *
 lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
 {
@@ -2903,6 +2914,10 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
 	lp.index = swp_offset;
 	if ((is_xarray ? do_xarray : do_radix_tree)
 		(swp_space+OFFSET(address_space_page_tree), RADIX_TREE_SEARCH, &lp)) {
+		if ((is_xarray ? xa_is_value : radix_tree_exceptional_entry)((ulong)lp.value)) {
+			/* ignore shadow values */
+			return NULL;
+		}
 		if (!is_page_ptr((ulong)lp.value, &paddr)) {
 			error(WARNING, "radix page: %lx: not a page pointer\n", lp.value);
 			return NULL;
-- 
2.42.0

--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux