VARIABLE_MONITOR_TYPE
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "monitor_timer.h"
|
||||
#include "monitor_trace.h"
|
||||
|
||||
// ioctl
|
||||
#define IOCTL_WATCH_VARIABLE 0
|
||||
#define IOCTL_DUMP_LOG 1
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ void diag_task_info_work(struct work_struct *work) {
|
||||
kernel_watch_arg *kwarg;
|
||||
|
||||
vm_record.id = event_id;
|
||||
vm_record.et_type = 0; //! todo event type
|
||||
vm_record.et_type = VARIABLE_MONITOR_RECORD_TYPE;
|
||||
vm_record.tv = ktime_get_real();
|
||||
vm_record.threshold_num = k_watch_timer->threshold_num;
|
||||
|
||||
@@ -180,7 +180,7 @@ void diag_task_info_work(struct work_struct *work) {
|
||||
|
||||
get_task_struct(p); // count +1
|
||||
|
||||
tsk_info.et_type = 1; //! todo event type
|
||||
tsk_info.et_type = VARIABLE_MONITOR_TASK_TYPE;
|
||||
tsk_info.id = event_id;
|
||||
tsk_info.tv = vm_record.tv;
|
||||
diag_tsk(p, &tsk_info);
|
||||
@@ -315,53 +315,6 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
|
||||
}
|
||||
|
||||
int diag_test(int nid) {
|
||||
// static struct task_struct *tsk;
|
||||
// static struct task_struct *leader;
|
||||
// static variable_monitor_task tsk_info;
|
||||
// // unsigned int nr_bt;
|
||||
|
||||
// int ret;
|
||||
// unsigned long flags;
|
||||
// pid_t id = (pid_t)nid;
|
||||
|
||||
// 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;
|
||||
// }
|
||||
|
||||
// leader = tsk->group_leader;
|
||||
// if (leader == NULL || leader->exit_state == EXIT_ZOMBIE){
|
||||
// ret = -EINVAL;
|
||||
// rcu_read_unlock();
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
// get_task_struct(tsk);
|
||||
// rcu_read_unlock();
|
||||
|
||||
// tsk_info.et_type = 1;
|
||||
// test(tsk, &tsk_info);
|
||||
|
||||
// put_task_struct(tsk);
|
||||
// printk(KERN_INFO "put_task_struct finish\n");
|
||||
|
||||
// diag_variant_buffer_spin_lock(&load_monitor_variant_buffer, flags);
|
||||
// printk(KERN_INFO "1\n");
|
||||
// diag_variant_buffer_reserve(&load_monitor_variant_buffer,sizeof(variable_monitor_task));
|
||||
// printk(KERN_INFO "2\n");
|
||||
// diag_variant_buffer_write_nolock(&load_monitor_variant_buffer, &tsk_info,
|
||||
// sizeof(variable_monitor_task));
|
||||
// printk(KERN_INFO "3\n");
|
||||
// diag_variant_buffer_seal(&load_monitor_variant_buffer);
|
||||
// printk(KERN_INFO "4\n");
|
||||
// diag_variant_buffer_spin_unlock(&load_monitor_variant_buffer, flags);
|
||||
// printk(KERN_INFO "5\n");
|
||||
|
||||
struct task_struct *g, *p; // g: task group; p: task
|
||||
unsigned long flags;
|
||||
unsigned long event_id = get_cycles();
|
||||
@@ -369,27 +322,7 @@ int diag_test(int nid) {
|
||||
static variable_monitor_task tsk_info = {0};
|
||||
static variable_monitor_record vm_record = {0};
|
||||
|
||||
// vm_record.id = event_id;
|
||||
// vm_record.et_type = 0; //! todo event type
|
||||
vm_record.tv = ktime_get_real();
|
||||
// vm_record.threshold_num = j;
|
||||
|
||||
// printk("-------------------------------------\n");
|
||||
// printk("-------------watch monitor-----------\n");
|
||||
// printk("Threshold reached:\n");
|
||||
// for (i = 0; i < j; i++) {
|
||||
// kwarg = &k_watch_timer->k_watch_args[buffer[i]];
|
||||
// k_w_arg2threshold(kwarg, &vm_record.threshold_record[i]);
|
||||
// }
|
||||
// rcu_read_lock();
|
||||
|
||||
// diag_variant_buffer_spin_lock(&load_monitor_variant_buffer, flags);
|
||||
// diag_variant_buffer_reserve(&load_monitor_variant_buffer,
|
||||
// sizeof(variable_monitor_record));
|
||||
// diag_variant_buffer_write_nolock(&load_monitor_variant_buffer, &vm_record,
|
||||
// sizeof(variable_monitor_record));
|
||||
// diag_variant_buffer_seal(&load_monitor_variant_buffer);
|
||||
// diag_variant_buffer_spin_unlock(&load_monitor_variant_buffer, flags);
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
@@ -399,7 +332,7 @@ int diag_test(int nid) {
|
||||
|
||||
get_task_struct(p);
|
||||
|
||||
tsk_info.et_type = 1; //! todo event type
|
||||
tsk_info.et_type = VARIABLE_MONITOR_TASK_TYPE;
|
||||
tsk_info.id = event_id;
|
||||
tsk_info.tv = vm_record.tv;
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
|
||||
#define DIAG_USER_STACK_SIZE (16 * 1024)
|
||||
|
||||
// dump type
|
||||
#define VARIABLE_MONITOR_RECORD_TYPE 0x0
|
||||
#define VARIABLE_MONITOR_TASK_TYPE 0x1
|
||||
|
||||
typedef struct {
|
||||
pid_t task_id; // current process id
|
||||
char name[MAX_NAME_LEN + 1]; // name
|
||||
@@ -90,7 +94,7 @@ typedef struct {
|
||||
int et_type;
|
||||
unsigned long id;
|
||||
unsigned long long tv;
|
||||
task_detail task; // brief
|
||||
task_detail task; // brief
|
||||
// user_stack_detail user_stack; // user stack
|
||||
kern_stack_detail kern_stack; // kernel stack
|
||||
proc_chains_detail proc_chains; // process chains argv
|
||||
|
||||
@@ -20,7 +20,7 @@ static int task_info_extract(void *buf, unsigned int len, void *) {
|
||||
|
||||
et_type = (int *)buf;
|
||||
switch (*et_type) {
|
||||
case 0:
|
||||
case VARIABLE_MONITOR_RECORD_TYPE:
|
||||
if (len < sizeof(variable_monitor_record))
|
||||
break;
|
||||
vm_record = (variable_monitor_record *)buf;
|
||||
@@ -36,7 +36,7 @@ static int task_info_extract(void *buf, unsigned int len, void *) {
|
||||
vm_record->threshold_record[i].threshold);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case VARIABLE_MONITOR_TASK_TYPE:
|
||||
if (len < sizeof(variable_monitor_task))
|
||||
break;
|
||||
tsk_info = (variable_monitor_task *)buf;
|
||||
|
||||
@@ -6,9 +6,14 @@
|
||||
|
||||
#include <cstddef> // size_t
|
||||
|
||||
// ioctl
|
||||
#define IOCTL_WATCH_VARIABLE 0
|
||||
#define IOCTL_DUMP_LOG 1
|
||||
|
||||
// dump type
|
||||
#define VARIABLE_MONITOR_RECORD_TYPE 0x0
|
||||
#define VARIABLE_MONITOR_TASK_TYPE 0x1
|
||||
|
||||
#define DEVICE "/dev/variable_monitor"
|
||||
|
||||
#define CGROUP_NAME_LEN 32 // max length of cgroup name
|
||||
|
||||
Reference in New Issue
Block a user