1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2023 Huawei Device Co., Ltd. 4 */ 5 6 #ifndef _JIT_SPACE_LIST_H 7 #define _JIT_SPACE_LIST_H 8 9 #include <linux/list.h> 10 #include <linux/slab.h> 11 #include <linux/rbtree.h> 12 #include <linux/spinlock.h> 13 #include <asm-generic/errno-base.h> 14 15 #include "jit_memory_log.h" 16 static struct rb_root root_tree = RB_ROOT; 17 18 extern struct jit_process { 19 int pid; // pid is the key and cookie is value in rbTree 20 unsigned long cookie; 21 struct rb_node node; 22 struct list_head head; 23 }; 24 25 extern struct jit_space_node { 26 unsigned long begin, end; 27 struct list_head head; 28 }; 29 30 inline struct jit_space_node *init_jit_space_node(unsigned long begin, unsigned long end); 31 32 const void find_jit_space(struct list_head *head, unsigned long begin, unsigned long size, int *err); 33 void update_jit_space(struct list_head *head, unsigned long begin, unsigned long size); 34 void delete_jit_space(struct list_head *head, unsigned long begin, unsigned long size, int *err); 35 void exit_jit_space(struct list_head *head); 36 37 38 #endif //_JIT_SPACE_LIST_H