IOCTL_PID
This commit is contained in:
@@ -366,37 +366,37 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
|
||||
return HRTIMER_RESTART; // restart timer
|
||||
}
|
||||
|
||||
int diag_test(int nid) {
|
||||
struct task_struct *g, *p; // g: task group; p: task
|
||||
int diag_pid(int pid) {
|
||||
struct task_struct *tsk;
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
unsigned long event_id = get_cycles();
|
||||
|
||||
static variable_monitor_task tsk_info = {0};
|
||||
static variable_monitor_record vm_record = {0};
|
||||
|
||||
vm_record.tv = ktime_get_real();
|
||||
pid_t id = (pid_t)pid;
|
||||
|
||||
rcu_read_lock();
|
||||
tsk = NULL;
|
||||
if (orig_find_task_by_vpid)
|
||||
tsk = orig_find_task_by_vpid(id);
|
||||
if (!tsk) {
|
||||
ret = -EINVAL;
|
||||
rcu_read_unlock();
|
||||
return ret;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
do_each_thread(g, p) {
|
||||
if (p->__state == TASK_RUNNING || __task_contributes_to_load(p) ||
|
||||
p->__state == TASK_IDLE) {
|
||||
get_task_struct(tsk); // count +1
|
||||
|
||||
get_task_struct(p);
|
||||
tsk_info.et_type = VARIABLE_MONITOR_TASK_TYPE;
|
||||
tsk_info.id = event_id;
|
||||
tsk_info.tv = vm_record.tv;
|
||||
diag_tsk(tsk, &tsk_info);
|
||||
put_task_struct(tsk); // count -1
|
||||
|
||||
tsk_info.et_type = VARIABLE_MONITOR_TASK_TYPE;
|
||||
tsk_info.id = event_id;
|
||||
tsk_info.tv = vm_record.tv;
|
||||
|
||||
diag_tsk(p, &tsk_info);
|
||||
|
||||
put_task_struct(p);
|
||||
|
||||
push_tskinfo_2_buffer(&tsk_info, &flags);
|
||||
}
|
||||
}
|
||||
while_each_thread(g, p);
|
||||
printk(KERN_INFO "-------------------------------------\n");
|
||||
push_tskinfo_2_buffer(&tsk_info, &flags); // push to buffer
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user