diff options
| author | zy <[email protected]> | 2023-11-08 05:19:46 -0500 |
|---|---|---|
| committer | zy <[email protected]> | 2023-11-08 05:19:46 -0500 |
| commit | e22f9e889cbefdd55d74be74518d4b9452c32fa8 (patch) | |
| tree | 21ae52e886e98f43846e360ed1581f88f5eeb248 | |
| parent | f20847d07c26c6cce42d4a2d72f34a9646a5adc4 (diff) | |
if task == TASK_RUNNING || __task_contributes_to_load
| -rw-r--r-- | watch_module.h | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/watch_module.h b/watch_module.h index fd283a2..beb9ffd 100644 --- a/watch_module.h +++ b/watch_module.h @@ -80,6 +80,12 @@ unsigned int (*orig_stack_trace_save_tsk)(struct task_struct *task, unsigned lon // LOOKUP_SYMS(show_stack); void (*orig_show_stack)(struct task_struct *task, unsigned long *sp, const char *loglvl); +// https://www.spinics.net/lists/kernel/msg3582022.html +// remove from 5.8.rc3,but it still work +// whether the task contributes to the load +#define __task_contributes_to_load(task) \ + ((READ_ONCE(task->__state) & TASK_UNINTERRUPTIBLE) != 0 && (task->flags & PF_FROZEN) == 0 && \ + (READ_ONCE(task->__state) & TASK_NOLOAD) == 0) /// @brief print all task stack /// @param @@ -97,23 +103,12 @@ static void print_all_task_stack(void) LOAD_INT(avenrun[0]), LOAD_FRAC(avenrun[0]), LOAD_INT(avenrun[1]), LOAD_FRAC(avenrun[1]), LOAD_INT(avenrun[2]), LOAD_FRAC(avenrun[2])); rcu_read_lock(); // lock run queue - printk("Running task\n"); + // printk("Running task\n"); do_each_thread(g, p) { - if (p->__state == TASK_RUNNING) + if (p->__state == TASK_RUNNING || __task_contributes_to_load(p)) { - printk("running task: name %s, pid %d\n", p->comm, p->pid); - nr_bt = orig_stack_trace_save_tsk(p, backtrace, BACKTRACE_DEPTH, 0); - stack_trace_print(backtrace, nr_bt, 0); // print - } - } - while_each_thread(g, p); - printk("Uninterrupted task\n"); - do_each_thread(g, p) - { - if (p->__state & TASK_UNINTERRUPTIBLE) - { - printk("uninterrupted task: name %s, pid %d\n", p->comm, p->pid); + printk("task: name %s, pid %d\n", p->comm, p->pid); nr_bt = orig_stack_trace_save_tsk(p, backtrace, BACKTRACE_DEPTH, 0); stack_trace_print(backtrace, nr_bt, 0); // print } |
