summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorzy <[email protected]>2023-12-14 06:24:38 -0500
committerzy <[email protected]>2023-12-14 06:24:38 -0500
commit3034599a245a4536bf7886b8fa668e80206bd5de (patch)
tree7df8aad92411e76fc9e47dfce3610265770f45f6 /source
parentbd1290abd4d156cb2e4467d3406d5ea114f401dd (diff)
remove swirq
Diffstat (limited to 'source')
-rw-r--r--source/module/monitor_kernel.c20
-rw-r--r--source/module/monitor_kernel.h2
-rw-r--r--source/module/monitor_kernel_lib.c45
3 files changed, 42 insertions, 25 deletions
diff --git a/source/module/monitor_kernel.c b/source/module/monitor_kernel.c
index 2695266..c30a63e 100644
--- a/source/module/monitor_kernel.c
+++ b/source/module/monitor_kernel.c
@@ -12,16 +12,16 @@
#include <linux/interrupt.h>
-enum {
- MY_SOFTIRQ = 11, // 这个值是示例,确保它没有被其他软中断使用
-};
+// enum {
+// MY_SOFTIRQ = 11, // 这个值是示例,确保它没有被其他软中断使用
+// };
-static void my_softirq_handler(struct softirq_action *action)
-{
- // 这是软中断处理函数,它不能睡眠,必须快速执行
- // 在这里调用 get_raw_stack
- diag_task_all();
-}
+// static void my_softirq_handler(struct softirq_action *action)
+// {
+// // 这是软中断处理函数,它不能睡眠,必须快速执行
+// // 在这里调用 get_raw_stack
+// diag_task_all();
+// }
// for character device
static dev_t dev_num;
@@ -190,7 +190,7 @@ int init_module(void) {
// orig_X | buffer
monitor_init();
- orig_open_softirq(MY_SOFTIRQ, my_softirq_handler);
+ // orig_open_softirq(MY_SOFTIRQ, my_softirq_handler);
return 0;
}
diff --git a/source/module/monitor_kernel.h b/source/module/monitor_kernel.h
index ae927df..fff5547 100644
--- a/source/module/monitor_kernel.h
+++ b/source/module/monitor_kernel.h
@@ -37,6 +37,6 @@ check_variable_cb(struct hrtimer *timer); // hrtimer callback
// for test
int diag_pid(int id); // for test
int diag_tgid(int id); // for test
-void diag_task_info(kernel_watch_timer *k_watch_timer);
+void diag_task(kernel_watch_timer *k_watch_timer);
void diag_task_all(void);
void diag_task_by_tgid(pid_t tgid); \ No newline at end of file
diff --git a/source/module/monitor_kernel_lib.c b/source/module/monitor_kernel_lib.c
index 37b3487..a865c89 100644
--- a/source/module/monitor_kernel_lib.c
+++ b/source/module/monitor_kernel_lib.c
@@ -122,6 +122,8 @@ static void diag_tsk(struct task_struct *p, variable_monitor_task *tsk_info) {
diag_task_brief(p, &tsk_info->task); // task brief
if (tsk_info->task.sys_task == 1) { // system task
nr_bt = diag_task_kern_stack(p, &tsk_info->kern_stack); // kernel stack
+ dump_proc_chains_argv(1, p, &mm_tree_struct,
+ &tsk_info->proc_chains); // proc chains
} else { // other task
nr_bt = diag_task_kern_stack(p, &tsk_info->kern_stack); // kernel stack
dump_proc_chains_argv(1, p, &mm_tree_struct,
@@ -207,6 +209,12 @@ static void clear_all_watch(void) {
memset(kernel_wtimer_list, 0, sizeof(kernel_wtimer_list));
}
+/**
+ * @brief all threshold reached info
+ *
+ * @param k_watch_timer
+ * @param is_print
+ */
static void diag_vm_record(kernel_watch_timer *k_watch_timer,
unsigned char is_print) {
@@ -262,6 +270,12 @@ static void diag_vm_record(kernel_watch_timer *k_watch_timer,
}
}
+
+/**
+ * @brief diag task by tgid
+ *
+ * @param tgid
+ */
void diag_task_by_tgid(pid_t tgid) {
struct task_struct *tsk;
@@ -299,9 +313,11 @@ void diag_task_by_tgid(pid_t tgid) {
rcu_read_unlock();
}
+/**
+ * @brief diag all task info
+ *
+ */
void diag_task_all(void) {
- // pr_info("diag_task_all, tv %lld\n", ktime_get_real());
-
static variable_monitor_task tsk_info;
unsigned long event_id = get_cycles();
@@ -331,16 +347,20 @@ void diag_task_all(void) {
diag_variant_buffer_spin_unlock(&load_monitor_variant_buffer, flags);
rcu_read_unlock();
- // pr_info("diag_task_all, finish tv %lld\n", ktime_get_real());
}
-void diag_task_info(kernel_watch_timer *k_watch_timer) {
+/**
+ * @brief diag task entry
+ *
+ * @param k_watch_timer
+ */
+void diag_task(kernel_watch_timer *k_watch_timer) {
if (k_watch_timer->threshold_over_count <= 0) // if no threshold reached
return;
pr_info("diag_stack, tv %lld\n", ktime_get_real());
- if (sample_all) {
+ if (sample_all) { // sample all task
diag_task_all();
- } else {
+ } else { // only care threshold reached task
int i;
kernel_watch_arg *kwarg;
for (i = 0; i < k_watch_timer->threshold_over_count; i++) {
@@ -353,14 +373,14 @@ void diag_task_info(kernel_watch_timer *k_watch_timer) {
}
/**
- * @brief diag task info, for work queue
+ * @brief diag task, for work queue
*
* @param work
*/
void diag_task_info_work(struct work_struct *work) {
kernel_watch_timer *k_watch_timer =
container_of(work, kernel_watch_timer, wk);
- diag_task_info(k_watch_timer);
+ diag_task(k_watch_timer);
}
/**
@@ -473,9 +493,6 @@ void clear_watch(pid_t pid) {
start_all_hrTimer(); // restart timer
}
-// enum {
-// MY_SOFTIRQ = 11, // 这个值是示例,确保它没有被其他软中断使用
-// };
/**
* @brief main callback function
@@ -509,9 +526,9 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
pr_info("threshold reached, tv %lld\n", k_watch_timer->tv);
// highpri_wq
queue_work(system_highpri_wq, &k_watch_timer->wk);
- // diag_task_info(k_watch_timer);
-
- // orig_raise_softirq(MY_SOFTIRQ); // for test
+
+ // diag_task(k_watch_timer);
+ // orig_raise_softirq(MY_SOFTIRQ); // for swirq test
// restart timer after dump_reset_sec sec
hrtimer_forward(timer, timer->base->get_time(),