sample_all
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "monitor_kernel.h"
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/stacktrace.h>
|
||||
#include <linux/interrupt.h>
|
||||
// #include <linux/sched/task.h>
|
||||
// #include <linux/sched/mm.h>
|
||||
|
||||
@@ -119,10 +119,10 @@ static int init_sa_buffer(void) {
|
||||
static void diag_tsk(struct task_struct *p, variable_monitor_task *tsk_info) {
|
||||
unsigned int nr_bt;
|
||||
// printk(KERN_INFO "diag_tsk\n");
|
||||
diag_task_brief(p, &tsk_info->task); // task brief
|
||||
if (tsk_info->task.sys_task == 1) { // system task
|
||||
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
|
||||
} else { // other task
|
||||
} 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,
|
||||
&tsk_info->proc_chains); // proc chains
|
||||
@@ -209,6 +209,9 @@ static void clear_all_watch(void) {
|
||||
|
||||
static void diag_vm_record(kernel_watch_timer *k_watch_timer,
|
||||
unsigned char is_print) {
|
||||
|
||||
unsigned long long start_time = ktime_get_real();
|
||||
|
||||
static variable_monitor_record vm_record;
|
||||
|
||||
kernel_watch_arg *kwarg;
|
||||
@@ -240,8 +243,8 @@ static void diag_vm_record(kernel_watch_timer *k_watch_timer,
|
||||
|
||||
if (is_print) {
|
||||
printk(KERN_INFO "-----------variable monitor----------\n");
|
||||
printk(KERN_INFO "threshold exceeded, Timestamp %lld, Delay %lld:\n",
|
||||
vm_record.tv, ktime_get_real() - vm_record.tv);
|
||||
printk(KERN_INFO "threshold exceeded, Timestamp %lld, Stack finish Delay %lld:\n",
|
||||
vm_record.tv, start_time - vm_record.tv);
|
||||
|
||||
for (i = 0; i < vm_record.threshold_over_count; i++) {
|
||||
printk(
|
||||
@@ -259,7 +262,7 @@ static void diag_vm_record(kernel_watch_timer *k_watch_timer,
|
||||
}
|
||||
}
|
||||
|
||||
void diag_task_by_tgid(pid_t tgid){
|
||||
void diag_task_by_tgid(pid_t tgid) {
|
||||
|
||||
struct task_struct *tsk;
|
||||
int ret;
|
||||
@@ -275,7 +278,7 @@ void diag_task_by_tgid(pid_t tgid){
|
||||
if (!tsk) {
|
||||
ret = -EINVAL;
|
||||
rcu_read_unlock();
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
diag_variant_buffer_spin_lock(&load_monitor_variant_buffer, flags);
|
||||
@@ -296,8 +299,8 @@ void diag_task_by_tgid(pid_t tgid){
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
void diag_task_all(void){
|
||||
pr_info("diag_task_all, tv %lld\n", ktime_get_real());
|
||||
void diag_task_all(void) {
|
||||
// pr_info("diag_task_all, tv %lld\n", ktime_get_real());
|
||||
|
||||
static variable_monitor_task tsk_info;
|
||||
|
||||
@@ -328,13 +331,24 @@ 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());
|
||||
// pr_info("diag_task_all, finish tv %lld\n", ktime_get_real());
|
||||
}
|
||||
|
||||
void diag_task_info(kernel_watch_timer *k_watch_timer) {
|
||||
if (k_watch_timer->threshold_over_count <= 0) // if no threshold reached
|
||||
return;
|
||||
diag_task_all();
|
||||
pr_info("diag_stack, tv %lld\n", ktime_get_real());
|
||||
if (sample_all) {
|
||||
diag_task_all();
|
||||
} else {
|
||||
int i;
|
||||
kernel_watch_arg *kwarg;
|
||||
for (i = 0; i < k_watch_timer->threshold_over_count; i++) {
|
||||
kwarg = &k_watch_timer->k_watch_args[k_watch_timer->threshold_buffer[i]];
|
||||
diag_task_by_tgid(kwarg->task_id);
|
||||
}
|
||||
}
|
||||
pr_info("diag_stack, finish tv %lld\n", ktime_get_real());
|
||||
diag_vm_record(k_watch_timer, 1);
|
||||
}
|
||||
|
||||
@@ -494,9 +508,9 @@ enum hrtimer_restart check_variable_cb(struct hrtimer *timer) {
|
||||
k_watch_timer->tv = ktime_get_real();
|
||||
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);
|
||||
|
||||
queue_work(system_highpri_wq, &k_watch_timer->wk);
|
||||
// diag_task_info(k_watch_timer);
|
||||
|
||||
// orig_raise_softirq(MY_SOFTIRQ); // for test
|
||||
|
||||
// restart timer after dump_reset_sec sec
|
||||
|
||||
Reference in New Issue
Block a user