workqueue fix init
This commit is contained in:
@@ -57,7 +57,7 @@ static int init_buffer(unsigned int buf_size) {
|
||||
|
||||
static void diag_tsk(struct task_struct *p, variable_monitor_task *tsk_info) {
|
||||
unsigned int nr_bt;
|
||||
printk(KERN_INFO "diag_tsk\n");
|
||||
// printk(KERN_INFO "diag_tsk\n");
|
||||
diag_task_brief(p, &tsk_info->task); // task brief
|
||||
// printk("1\n");
|
||||
diag_task_user_stack(p, &tsk_info->user_stack); // user stack
|
||||
@@ -78,7 +78,7 @@ static void diag_tsk(struct task_struct *p, variable_monitor_task *tsk_info) {
|
||||
}
|
||||
|
||||
static void push_tsk_info(variable_monitor_task *tsk_info,unsigned long *flags) {
|
||||
printk(KERN_INFO "push_tsk_info\n");
|
||||
// printk(KERN_INFO "push_tsk_info\n");
|
||||
diag_variant_buffer_spin_lock(&load_monitor_variant_buffer, *flags);
|
||||
diag_variant_buffer_reserve(&load_monitor_variant_buffer,
|
||||
sizeof(variable_monitor_task));
|
||||
@@ -101,11 +101,14 @@ static void clear_all_watch(void) {
|
||||
memset(kernel_wtimer_list, 0, sizeof(kernel_wtimer_list));
|
||||
}
|
||||
|
||||
static void sample_task_work(struct work_struct *work){
|
||||
void sample_task_work(struct work_struct *work){
|
||||
|
||||
kernel_watch_timer *k_watch_timer = container_of(work, kernel_watch_timer, wk);
|
||||
|
||||
if (k_watch_timer->threshold_num <= 0) return;
|
||||
|
||||
printk(KERN_INFO "sample_task_work\n");
|
||||
|
||||
struct task_struct *g, *p; // g: task group; p: task
|
||||
unsigned long flags;
|
||||
unsigned long event_id = get_cycles();
|
||||
@@ -124,6 +127,17 @@ static void sample_task_work(struct work_struct *work){
|
||||
kwarg = &k_watch_timer->k_watch_args[k_watch_timer->threshold_buffer[i]];
|
||||
k_w_arg2threshold(kwarg, &vm_record.threshold_record[i]);
|
||||
}
|
||||
// !todo 调整输出
|
||||
printk(KERN_INFO "超出阈值:%lld\n", vm_record.tv);
|
||||
|
||||
for (i = 0; i < vm_record.threshold_num; i++) {
|
||||
printk(KERN_INFO "\t: pid: %d, name: %s, ptr: %p, threshold:%lld\n",
|
||||
vm_record.threshold_record[i].task_id,
|
||||
vm_record.threshold_record[i]
|
||||
.name, // Assuming name is a null-terminated string
|
||||
vm_record.threshold_record[i].ptr,
|
||||
vm_record.threshold_record[i].threshold);
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
|
||||
@@ -154,6 +168,7 @@ static void sample_task_work(struct work_struct *work){
|
||||
}
|
||||
}
|
||||
while_each_thread(g, p);
|
||||
return ;
|
||||
}
|
||||
/**
|
||||
* @brief all module function init. orig_X | buffer | workqueue
|
||||
@@ -170,11 +185,11 @@ int monitor_init(void) {
|
||||
if (ret)
|
||||
return -1;
|
||||
// init workqueue
|
||||
int i;
|
||||
for (i=0; i < MAX_TIMER_NUM; i++) {
|
||||
kernel_watch_timer *kw_timer = &kernel_wtimer_list[i];
|
||||
INIT_WORK(&kw_timer->wk, sample_task_work);
|
||||
}
|
||||
// int i;
|
||||
// for (i=0; i < MAX_TIMER_NUM; i++) {
|
||||
// kernel_watch_timer *kw_timer = &kernel_wtimer_list[i];
|
||||
// INIT_WORK(&kw_timer->wk, sample_task_work);
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -218,6 +233,8 @@ int start_watch_variable(watch_arg warg) {
|
||||
w_arg2k_w_arg(kptr, warg, &k_watch_arg);
|
||||
timer = get_timer(warg.time_ns); // get a valuable timer
|
||||
|
||||
INIT_WORK(&timer->wk, sample_task_work);
|
||||
|
||||
printk(KERN_INFO "ptr transform kptr: %p\n", kptr);
|
||||
printk(KERN_INFO "timer: %p\n", timer);
|
||||
printk(KERN_INFO "timer->sentinel: %d, timer->time_ns: %lld\n",
|
||||
|
||||
Reference in New Issue
Block a user