diag_task_kern_stack void -> unsigned int;

adjust print
This commit is contained in:
zy
2023-11-20 02:12:21 -05:00
parent 504f2fb903
commit ba633b50bc
3 changed files with 23 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
#include "monitor_kernel.h"
#include <linux/sched.h>
#include <linux/stacktrace.h>
// #include <linux/sched/task.h>
// #include <linux/sched/mm.h>
@@ -55,24 +56,32 @@ static int init_buffer(unsigned int buf_size) {
}
void diag_tsk(struct task_struct *p, variable_monitor_task *tsk_info,unsigned long *flags) {
int i;
unsigned int nr_bt;
printk(KERN_INFO "diag_tsk\n");
diag_task_brief(p, &tsk_info->task); // task brief
printk("1\n");
// printk("1\n");
diag_task_user_stack(p, &tsk_info->user_stack); // user stack
printk("2\n");
diag_task_kern_stack(p, &tsk_info->kern_stack); // kernel stack
printk("3\n");
// printk("2\n");
nr_bt = diag_task_kern_stack(p, &tsk_info->kern_stack); // kernel stack
// printk("pid: %d, kernel stack.stack\n", p->pid);
// for (i = 0; i < nr_bt; i++) {
// printk("%lx\n", tsk_info->kern_stack.stack[i]);
// }
// printk("pid: %d, stack_trace_print\n", p->pid);
stack_trace_print(tsk_info->kern_stack.stack, nr_bt, 0); /* 打印栈 */
// printk("3\n");
dump_proc_chains_argv(1, p, &mm_tree_struct,
&tsk_info->proc_chains); // proc chains
printk("4\n");
// printk("4\n");
diag_variant_buffer_spin_lock(&load_monitor_variant_buffer, *flags);
diag_variant_buffer_reserve(&load_monitor_variant_buffer,
sizeof(variable_monitor_task));
printk("5\n");
// printk("5\n");
diag_variant_buffer_write_nolock(&load_monitor_variant_buffer, tsk_info,
sizeof(variable_monitor_task));
printk("6\n");
// printk("6\n");
diag_variant_buffer_seal(&load_monitor_variant_buffer);
diag_variant_buffer_spin_unlock(&load_monitor_variant_buffer, *flags);
}
@@ -206,7 +215,7 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
static variable_monitor_record vm_record = {0};
vm_record.id = event_id;
vm_record.et_type = 1; //! todo event type
vm_record.et_type = 0; //! todo event type
vm_record.tv = ktime_get_real();
vm_record.threshold_num = j;
@@ -228,8 +237,8 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
do_each_thread(g, p) {
if (p->__state == TASK_RUNNING || __task_contributes_to_load(p) ||
p->__state == TASK_IDLE) {
tsk_info.et_type = 2; //! todo event type
p->__state == TASK_IDLE || 1) {
tsk_info.et_type = 1; //! todo event type
tsk_info.id = event_id;
tsk_info.tv = vm_record.tv;
diag_tsk(p, &tsk_info, &flags);

View File

@@ -322,8 +322,8 @@ void diag_task_user_stack(struct task_struct *tsk, user_stack_detail *detail) {
}
}
void diag_task_kern_stack(struct task_struct *tsk, kern_stack_detail *detail) {
orig_stack_trace_save_tsk(tsk, detail->stack, BACKTRACE_DEPTH, 0);
unsigned int diag_task_kern_stack(struct task_struct *tsk, kern_stack_detail *detail) {
return orig_stack_trace_save_tsk(tsk, detail->stack, BACKTRACE_DEPTH, 0);
}
void dump_proc_chains_argv(int style, struct task_struct *tsk, mm_tree *mm_tree,

View File

@@ -94,7 +94,7 @@ void diag_task_brief(struct task_struct *tsk,
task_detail *detail); // get task brief
void diag_task_user_stack(struct task_struct *tsk,
user_stack_detail *detail); // get task user stack
void diag_task_kern_stack(struct task_struct *tsk,
unsigned int diag_task_kern_stack(struct task_struct *tsk,
kern_stack_detail *detail); // get task kernel stack
void dump_proc_chains_argv(
int style, struct task_struct *tsk, mm_tree *mm_tree,