Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d986ba0329dcca102e227995371135c9bbcefb6b 70 lines 2.1 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#ifndef _LINUX_KHO_RADIX_TREE_H 4#define _LINUX_KHO_RADIX_TREE_H 5 6#include <linux/err.h> 7#include <linux/errno.h> 8#include <linux/mutex_types.h> 9#include <linux/types.h> 10 11/** 12 * DOC: Kexec Handover Radix Tree 13 * 14 * This is a radix tree implementation for tracking physical memory pages 15 * across kexec transitions. It was developed for the KHO mechanism but is 16 * designed for broader use by any subsystem that needs to preserve pages. 17 * 18 * The radix tree is a multi-level tree where leaf nodes are bitmaps 19 * representing individual pages. To allow pages of different sizes (orders) 20 * to be stored efficiently in a single tree, it uses a unique key encoding 21 * scheme. Each key is an unsigned long that combines a page's physical 22 * address and its order. 23 * 24 * Client code is responsible for allocating the root node of the tree, 25 * initializing the mutex lock, and managing its lifecycle. It must use the 26 * tree data structures defined in the KHO ABI, 27 * `include/linux/kho/abi/kexec_handover.h`. 28 */ 29 30struct kho_radix_node; 31 32struct kho_radix_tree { 33 struct kho_radix_node *root; 34 struct mutex lock; /* protects the tree's structure and root pointer */ 35}; 36 37typedef int (*kho_radix_tree_walk_callback_t)(phys_addr_t phys, 38 unsigned int order); 39 40#ifdef CONFIG_KEXEC_HANDOVER 41 42int kho_radix_add_page(struct kho_radix_tree *tree, unsigned long pfn, 43 unsigned int order); 44 45void kho_radix_del_page(struct kho_radix_tree *tree, unsigned long pfn, 46 unsigned int order); 47 48int kho_radix_walk_tree(struct kho_radix_tree *tree, 49 kho_radix_tree_walk_callback_t cb); 50 51#else /* #ifdef CONFIG_KEXEC_HANDOVER */ 52 53static inline int kho_radix_add_page(struct kho_radix_tree *tree, long pfn, 54 unsigned int order) 55{ 56 return -EOPNOTSUPP; 57} 58 59static inline void kho_radix_del_page(struct kho_radix_tree *tree, 60 unsigned long pfn, unsigned int order) { } 61 62static inline int kho_radix_walk_tree(struct kho_radix_tree *tree, 63 kho_radix_tree_walk_callback_t cb) 64{ 65 return -EOPNOTSUPP; 66} 67 68#endif /* #ifdef CONFIG_KEXEC_HANDOVER */ 69 70#endif /* _LINUX_KHO_RADIX_TREE_H */