mirror of
https://github.com/crash-utility/crash
synced 2025-03-04 05:17:36 +00:00
There have been two ways to iterate vm_area_struct until Linux 6.0: 1) by rbtree, aka vma.vm_rb; 2) by linked list, aka vma.vm_{next,prev}. However with the maple tree patches[1][2] in Linux 6.1, vm_rb and vm_{next,prev} are removed from vm_area_struct. The vm_area_dump() in crash mainly uses the linked list for vma iteration, which will not work for this case. So the maple tree iteration needs to be ported to crash. For crash, currently it only iteratively reads the maple tree, no more rcu safe or maple tree modification features needed. So we only port a subset of kernel maple tree features. In addition, we need to modify the ported kernel source code, making it compatible with crash. This patch deals with the two issues: 1) Poring mt_dump() function and all its dependencies from kernel source to crash, to enable crash maple tree iteration, 2) adapting the ported code with crash. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=524e00b36e8c547f5582eef3fb645a8d9fc5e3df [2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=763ecb035029f500d7e6dc99acd1ad299b7726a1 Signed-off-by: Tao Liu <ltao@redhat.com>
83 lines
1.6 KiB
C
83 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
#ifndef _MAPLE_TREE_H
|
|
#define _MAPLE_TREE_H
|
|
/*
|
|
* Maple Tree - An RCU-safe adaptive tree for storing ranges
|
|
* Copyright (c) 2018-2022 Oracle
|
|
* Authors: Liam R. Howlett <Liam.Howlett@Oracle.com>
|
|
* Matthew Wilcox <willy@infradead.org>
|
|
*
|
|
* eXtensible Arrays
|
|
* Copyright (c) 2017 Microsoft Corporation
|
|
* Author: Matthew Wilcox <willy@infradead.org>
|
|
*
|
|
* See Documentation/core-api/xarray.rst for how to use the XArray.
|
|
*/
|
|
#include <stdbool.h>
|
|
#include <limits.h>
|
|
#include <sys/types.h>
|
|
|
|
/*
|
|
* The following are copied and modified from include/linux/maple_tree.h
|
|
*/
|
|
|
|
enum maple_type {
|
|
maple_dense,
|
|
maple_leaf_64,
|
|
maple_range_64,
|
|
maple_arange_64,
|
|
};
|
|
|
|
#define MAPLE_NODE_MASK 255UL
|
|
|
|
#define MT_FLAGS_HEIGHT_OFFSET 0x02
|
|
#define MT_FLAGS_HEIGHT_MASK 0x7C
|
|
|
|
#define MAPLE_NODE_TYPE_MASK 0x0F
|
|
#define MAPLE_NODE_TYPE_SHIFT 0x03
|
|
|
|
#define MAPLE_RESERVED_RANGE 4096
|
|
|
|
/*
|
|
* The following are copied and modified from include/linux/xarray.h
|
|
*/
|
|
|
|
#define XA_ZERO_ENTRY xa_mk_internal(257)
|
|
|
|
static inline ulong xa_mk_internal(ulong v)
|
|
{
|
|
return (v << 2) | 2;
|
|
}
|
|
|
|
static inline bool xa_is_internal(ulong entry)
|
|
{
|
|
return (entry & 3) == 2;
|
|
}
|
|
|
|
static inline bool xa_is_node(ulong entry)
|
|
{
|
|
return xa_is_internal(entry) && entry > 4096;
|
|
}
|
|
|
|
static inline bool xa_is_value(ulong entry)
|
|
{
|
|
return entry & 1;
|
|
}
|
|
|
|
static inline bool xa_is_zero(ulong entry)
|
|
{
|
|
return entry == XA_ZERO_ENTRY;
|
|
}
|
|
|
|
static inline unsigned long xa_to_internal(ulong entry)
|
|
{
|
|
return entry >> 2;
|
|
}
|
|
|
|
static inline unsigned long xa_to_value(ulong entry)
|
|
{
|
|
return entry >> 1;
|
|
}
|
|
|
|
#endif /* _MAPLE_TREE_H */
|