summaryrefslogtreecommitdiff
path: root/source/module
diff options
context:
space:
mode:
authorzy <[email protected]>2023-12-12 11:50:10 +0800
committerzy <[email protected]>2023-12-12 11:50:10 +0800
commit636b2df0dd2179969b25d3f62bccd535f219f18e (patch)
treebeda911df984ed932778c67ad4d076cecf5e9c64 /source/module
parentfddda83a880748d62dce1cfb1a3e13e09f0e0ba7 (diff)
code clean
Diffstat (limited to 'source/module')
-rw-r--r--source/module/monitor_kernel.c5
-rw-r--r--source/module/monitor_kernel.h1
-rw-r--r--source/module/monitor_kernel_lib.c23
-rw-r--r--source/module/monitor_proc.h2
-rw-r--r--source/module/monitor_timer.c9
5 files changed, 30 insertions, 10 deletions
diff --git a/source/module/monitor_kernel.c b/source/module/monitor_kernel.c
index 79d8103..f12d131 100644
--- a/source/module/monitor_kernel.c
+++ b/source/module/monitor_kernel.c
@@ -76,14 +76,13 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num,
printk(KERN_INFO "variable_monitor IOCTL_DUMP_LOG\n");
ret = copy_from_user(&dump_param, (ioctl_dump_param *)ioctl_param,
sizeof(ioctl_dump_param));
- printk(KERN_INFO "dump_param: %p %lu %p\n", dump_param.user_ptr_len,
+ printk(KERN_INFO "dump_param: %p %d %p\n", dump_param.user_ptr_len,
dump_param.user_buf_len, dump_param.user_buf);
if (!ret) {
- // printk(KERN_INFO "ret\n");
ret = copy_to_user_variant_buffer(
&load_monitor_variant_buffer, dump_param.user_ptr_len,
dump_param.user_buf, dump_param.user_buf_len);
- printk(KERN_INFO "ret %d, %lu\n", ret, dump_param.user_buf_len);
+ printk(KERN_INFO "ret %d, %d\n", ret, dump_param.user_buf_len);
}
// printk(KERN_INFO "copy_to_user_variant_buffer \n");
break;
diff --git a/source/module/monitor_kernel.h b/source/module/monitor_kernel.h
index d2bbdc6..7a2b56a 100644
--- a/source/module/monitor_kernel.h
+++ b/source/module/monitor_kernel.h
@@ -19,6 +19,7 @@ extern int dump_reset_sec;
extern mm_tree mm_tree_struct;
extern struct diag_variant_buffer load_monitor_variant_buffer; // global buffer
+#define LOAD_MONITOR_BUFFER_SIZE 256 * 1024 * 1024 // 10MB
int monitor_init(void); // monitor init
void monitor_exit(void); // monitor exit
diff --git a/source/module/monitor_kernel_lib.c b/source/module/monitor_kernel_lib.c
index 31feb67..da46316 100644
--- a/source/module/monitor_kernel_lib.c
+++ b/source/module/monitor_kernel_lib.c
@@ -260,7 +260,7 @@ void diag_task_info_work(struct work_struct *work) {
return;
}
/**
- * @brief all module function init. orig_X | buffer | workqueue
+ * @brief all module function init. orig_X | buffer
*
* @return int
*/
@@ -270,8 +270,7 @@ int monitor_init(void) {
ret = init_orig_fun(); // init orig_X
if (ret)
return ret;
- //! todo
- ret = init_buffer(256 * 1024 * 1024); // 512M
+ ret = init_buffer(LOAD_MONITOR_BUFFER_SIZE); // 256M
if (ret)
return -1;
return 0;
@@ -335,6 +334,10 @@ int start_watch_variable(watch_arg warg) {
return 0;
}
+/**
+ * @brief reinit all timer's work
+ *
+ */
void init_work_all_hrTimer(void) {
int i = 0;
kernel_watch_timer *timer = NULL;
@@ -343,8 +346,6 @@ void init_work_all_hrTimer(void) {
// 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);
}
/**
@@ -402,6 +403,12 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
return HRTIMER_RESTART; // restart timer
}
+/**
+ * @brief for test only
+ *
+ * @param id
+ * @return int
+ */
int diag_pid(int id) {
struct task_struct *tsk;
int ret;
@@ -437,6 +444,12 @@ int diag_pid(int id) {
return 0;
}
+/**
+ * @brief for test only
+ *
+ * @param id
+ * @return int
+ */
int diag_tgid(int id) {
struct task_struct *tsk;
int ret;
diff --git a/source/module/monitor_proc.h b/source/module/monitor_proc.h
index 5afe3d3..33a3ead 100644
--- a/source/module/monitor_proc.h
+++ b/source/module/monitor_proc.h
@@ -2,7 +2,7 @@
#define MODULE_MONITOR_PROC_H
#define DEFAULT_INTERVAL_NS 10000 // 10us
-#define DEFAULT_DUMP_RESET_SEC 60 // 10s
+#define DEFAULT_DUMP_RESET_SEC 60 // 60s
extern int def_interval_ns;
extern int dump_reset_sec;
diff --git a/source/module/monitor_timer.c b/source/module/monitor_timer.c
index 705f97e..4652bc4 100644
--- a/source/module/monitor_timer.c
+++ b/source/module/monitor_timer.c
@@ -164,7 +164,10 @@ void cancel_all_hrTimer(void) {
printk(KERN_INFO "HrTimer cancel,module keep %d hrtimer for now\n", kernel_wtimer_num);
}
-
+/**
+ * @brief cancel all work
+ *
+ */
void cancel_all_work(void) {
int i = 0;
kernel_watch_timer *timer = NULL;
@@ -174,6 +177,10 @@ void cancel_all_work(void) {
}
}
+/**
+ * @brief destory all work
+ *
+ */
void cancel_destory_all_work(void) {
int i = 0;
kernel_watch_timer *timer = NULL;