[Crash-utility] [PATCH 2/5] zram/swap cache: treat xarray case

HATAYAMA Daisuke d.hatayama at fujitsu.com
Wed May 27 04:59:12 UTC 2020


In recent kernels, radix_tree_root has been replaced by
xarray. lookup_swap_cache() needs to switch depending on what type
i_pages in address_space structure has.

See the following commit of linux kernel git repository for reference:

    eb797a8ee0ab4cd03df556980ce7bf167cadaa50
    page cache: Rearrange address_space
---
 diskdump.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/diskdump.c b/diskdump.c
index 572ef70..88d0dee 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2657,6 +2657,11 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
 	ulong swp_type, swp_space, page;
 	struct list_pair lp;
 	physaddr_t paddr;
+	static int is_xarray = -1;
+
+	if (is_xarray < 0) {
+		is_xarray = STREQ(MEMBER_TYPE_NAME("address_space", "i_pages"), "xarray");
+	}
 
 	swp_type = __swp_type(pte_val);
 	if (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {
@@ -2675,7 +2680,7 @@ 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 (do_radix_tree(swp_space, RADIX_TREE_SEARCH, &lp)){
+	if ((is_xarray ? do_xarray : do_radix_tree)(swp_space, RADIX_TREE_SEARCH, &lp)) {
 		readmem((ulong)lp.value, KVADDR, &page, sizeof(void *),
 				"swap_cache page", FAULT_ON_ERROR);
 		if (!is_page_ptr(page, &paddr)) {
-- 
1.8.3.1




More information about the Crash-utility mailing list