Previous the mt_slots and mt_pivots array are assigned at compile time, however they are arch dependent and may be inconsistent with the vmcore. To avoid such issue, we read the array from vmcore instead.
Signed-off-by: Tao Liu <l...@redhat.com> --- maple_tree.c | 37 ++++++++++++++++++++----------------- maple_tree.h | 23 ----------------------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/maple_tree.c b/maple_tree.c index ff07d58..38a8b06 100644 --- a/maple_tree.c +++ b/maple_tree.c @@ -31,21 +31,8 @@ #define MAPLE_PARENT_RANGE32 0x04 #define MAPLE_PARENT_NOT_RANGE16 0x02 -static const unsigned char mt_slots[] = { - [maple_dense] = MAPLE_NODE_SLOTS, - [maple_leaf_64] = MAPLE_RANGE64_SLOTS, - [maple_range_64] = MAPLE_RANGE64_SLOTS, - [maple_arange_64] = MAPLE_ARANGE64_SLOTS, -}; -#define mt_slot_count(x) mt_slots[mte_node_type(x)] - -static const unsigned char mt_pivots[] = { - [maple_dense] = 0, - [maple_leaf_64] = MAPLE_RANGE64_SLOTS - 1, - [maple_range_64] = MAPLE_RANGE64_SLOTS - 1, - [maple_arange_64] = MAPLE_ARANGE64_SLOTS - 1, -}; -#define mt_pivot_count(x) mt_pivots[mte_node_type(x)] +unsigned char *mt_slots = NULL; +unsigned char *mt_pivots = NULL; #define ma_parent_ptr(x) ((struct maple_pnode *)(x)) #define ma_enode_ptr(x) ((struct maple_enode *)(x)) @@ -105,13 +92,15 @@ static inline struct maple_enode *mas_start(struct ma_state *mas) /* empty tree */ if (!root) { - mas->offset = MAPLE_NODE_SLOTS; + // mas->offset = MAPLE_NODE_SLOTS; + mas->offset = mt_slots[maple_dense]; return NULL; } /* Single entry tree */ mas->node = MAS_ROOT; - mas->offset = MAPLE_NODE_SLOTS; + // mas->offset = MAPLE_NODE_SLOTS; + mas->offset = mt_slots[maple_dense]; /* Single entry tree. */ if (mas->index > 0) @@ -796,6 +785,8 @@ void *mas_find(struct ma_state *mas, unsigned long max) /***********************************************/ void maple_init(void) { + int array_len; + STRUCT_SIZE_INIT(maple_tree_struct, "maple_tree"); STRUCT_SIZE_INIT(maple_node_struct, "maple_node"); @@ -818,4 +809,16 @@ void maple_init(void) MEMBER_OFFSET_INIT(maple_range_64_meta, "maple_range_64", "meta"); MEMBER_OFFSET_INIT(maple_metadata_end, "maple_metadata", "end"); + + array_len = get_array_length("mt_slots", NULL, sizeof(char)); + mt_slots = calloc(array_len, sizeof(char)); + readmem(symbol_value("mt_slots"), KVADDR, mt_slots, + array_len * sizeof(char), "maple_init read mt_slots", + FAULT_ON_ERROR); + + array_len = get_array_length("mt_pivots", NULL, sizeof(char)); + mt_pivots = calloc(array_len, sizeof(char)); + readmem(symbol_value("mt_pivots"), KVADDR, mt_pivots, + array_len * sizeof(char), "maple_init read mt_pivots", + FAULT_ON_ERROR); } \ No newline at end of file diff --git a/maple_tree.h b/maple_tree.h index 98f3c5c..aca1741 100644 --- a/maple_tree.h +++ b/maple_tree.h @@ -61,29 +61,6 @@ enum maple_type { .max = ULONG_MAX, \ } -#if defined(ALPHA) || defined(IA64) || \ - defined(S390) || defined(S390X) || \ - defined(PPC64) || defined(X86_64) || \ - defined(ARM64) || defined(SPARC64) || \ - defined(MIPS64) -/* 64bit sizes */ -#define MAPLE_NODE_SLOTS 31 /* 256 bytes including ->parent */ -#define MAPLE_RANGE64_SLOTS 16 /* 256 bytes */ -#define MAPLE_ARANGE64_SLOTS 10 /* 240 bytes */ -#define MAPLE_ARANGE64_META_MAX 15 /* Out of range for metadata */ -#define MAPLE_ALLOC_SLOTS (MAPLE_NODE_SLOTS - 1) -#endif - -#if defined(X86) || defined(PPC) || \ - defined(ARM) || defined(MIPS) -/* 32bit sizes */ -#define MAPLE_NODE_SLOTS 63 /* 256 bytes including ->parent */ -#define MAPLE_RANGE64_SLOTS 32 /* 256 bytes */ -#define MAPLE_ARANGE64_SLOTS 21 /* 240 bytes */ -#define MAPLE_ARANGE64_META_MAX 31 /* Out of range for metadata */ -#define MAPLE_ALLOC_SLOTS (MAPLE_NODE_SLOTS - 2) -#endif - #define MAPLE_NODE_MASK 255UL #define MT_FLAGS_ALLOC_RANGE 0x01 -- 2.33.1 -- Crash-utility mailing list Crash-utility@redhat.com https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki