remove swirq
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user