fix init work bug

kernel_wtimer_num to volatile
This commit is contained in:
John Doe
2023-12-01 11:19:07 +00:00
parent 0d1f57f06e
commit a880fd3b32
3 changed files with 21 additions and 5 deletions

View File

@@ -305,6 +305,17 @@ int start_watch_variable(watch_arg warg) {
return 0;
}
void init_work_all_hrTimer(void) {
int i = 0;
kernel_watch_timer *timer = NULL;
for (i = 0; i < kernel_wtimer_num; i++) {
timer = &(kernel_wtimer_list[i]);
// init work
INIT_WORK(&timer->wk, diag_task_info_work);
}
// printk(KERN_INFO "HrTimer work init,module keep %d hrtimer for now\n", kernel_wtimer_num);
}
/**
* @brief clear watch with pid
*
@@ -315,6 +326,7 @@ void clear_watch(pid_t 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
init_work_all_hrTimer();
start_all_hrTimer(); // restart timer
}
@@ -342,11 +354,11 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
if (j > 0) // if any threshold reached
{
k_watch_timer->threshold_num = j;
// highpri_wq
queue_work(system_highpri_wq, &k_watch_timer->wk);
// restart timer after 5s
hrtimer_forward(timer, timer->base->get_time(),
ktime_set(dump_reset_sec, 0)); //! todo
// highpri_wq
queue_work(system_highpri_wq, &k_watch_timer->wk);
} else {
// keep frequency
hrtimer_forward(timer, timer->base->get_time(), k_watch_timer->kt);