init && exit
This commit is contained in:
@@ -12,8 +12,8 @@ static unsigned char w_arg2k_w_arg(void *ptr, watch_arg warg,
|
||||
kernel_watch_arg *k_watch_arg) {
|
||||
// k_watch_arg init
|
||||
k_watch_arg->task_id = warg.task_id;
|
||||
strncpy(k_watch_arg->name, warg.name, MAX_NAME_LEN + 1); // name
|
||||
k_watch_arg->name[MAX_NAME_LEN + 1] = '\0'; // just in case
|
||||
strncpy(k_watch_arg->name, warg.name, MAX_NAME_LEN + 1); // name
|
||||
k_watch_arg->name[MAX_NAME_LEN + 1] = '\0'; // just in case
|
||||
k_watch_arg->kptr = ptr;
|
||||
k_watch_arg->length_byte = warg.length_byte;
|
||||
k_watch_arg->threshold = warg.threshold;
|
||||
@@ -28,7 +28,7 @@ static void init_mm_tree(mm_tree *mm_tree) {
|
||||
}
|
||||
|
||||
static int init_buffer(unsigned int buf_size) {
|
||||
init_mm_tree(&mm_tree_struct); // init mm_tree
|
||||
init_mm_tree(&mm_tree_struct); // init mm_tree
|
||||
init_diag_variant_buffer(&load_monitor_variant_buffer, buf_size);
|
||||
int ret = 0;
|
||||
ret = alloc_diag_variant_buffer(&load_monitor_variant_buffer);
|
||||
@@ -56,10 +56,10 @@ static void clear_all_watch(void) {
|
||||
int monitor_init(void) {
|
||||
int ret = 0;
|
||||
|
||||
init_orig_fun(); // init orig_X
|
||||
ret = init_buffer(50 * 1024 * 1024); // 50M
|
||||
if (ret)
|
||||
return 0;
|
||||
ret = init_orig_fun(); // init orig_X
|
||||
if (ret) return ret;
|
||||
ret = init_buffer(50 * 1024 * 1024); // 50M
|
||||
if (ret) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ void monitor_exit() {
|
||||
clear_all_watch();
|
||||
// free buffer
|
||||
destroy_diag_variant_buffer(&load_monitor_variant_buffer);
|
||||
printk(KERN_INFO "clear all buffer\n");
|
||||
}
|
||||
/**
|
||||
* @brief start watch variable
|
||||
@@ -99,7 +100,7 @@ int start_watch_variable(watch_arg warg) {
|
||||
}
|
||||
// k_watch_arg init
|
||||
w_arg2k_w_arg(kptr, warg, &k_watch_arg);
|
||||
timer = get_timer(warg.time_ns); // get a valuable timer
|
||||
timer = get_timer(warg.time_ns); // get a valuable timer
|
||||
|
||||
printk(KERN_INFO "ptr transform kptr: %p\n", kptr);
|
||||
printk(KERN_INFO "timer: %p\n", timer);
|
||||
@@ -107,7 +108,7 @@ int start_watch_variable(watch_arg warg) {
|
||||
timer->sentinel, timer->time_ns);
|
||||
printk(KERN_INFO "timer->hr_timer: %p\n", &timer->hr_timer);
|
||||
|
||||
TIMER_CANCEL(timer); // just in case
|
||||
TIMER_CANCEL(timer); // just in case
|
||||
timer_add_watch(timer, k_watch_arg);
|
||||
TIMER_START(timer);
|
||||
|
||||
@@ -122,8 +123,8 @@ int start_watch_variable(watch_arg warg) {
|
||||
*/
|
||||
void clear_watch(pid_t pid) {
|
||||
printk(KERN_INFO "clear pid %d 's watch variable\n", pid);
|
||||
cancel_all_hrTimer(); // just in case
|
||||
del_all_kwarg_by_pid(pid); // delete all kwarg with pid
|
||||
free_page_list(pid); // free page with pid
|
||||
start_all_hrTimer(); // restart timer
|
||||
cancel_all_hrTimer(); // just in case
|
||||
del_all_kwarg_by_pid(pid); // delete all kwarg with pid
|
||||
free_page_list(pid); // free page with pid
|
||||
start_all_hrTimer(); // restart timer
|
||||
}
|
||||
Reference in New Issue
Block a user