您的位置:首页 > 其它

软件检测系统所有cpu的中断计数实现方向

2012-05-17 00:29 411 查看
在cpu0的时钟中断里,检测是否所有cpu都关中断,如果有的话,则打印告警信息,以及打印待观测线程的回溯以及所在cpu的运行状态

timer.c

#ifdef CONFIG_SMP_DEBUG

/*

 * add by ryan 05/16/2012

 */

unsigned long cpu_timer_tick[32];

int cpu_flag_dump[32]={0};

u64 last_tick_cpu0;

int system_is_down = 0;

int sysctl_dead_time = 100;

int cpu0_checking = 0;

extern void mips_send_nmi_single(int cpu);

#define MIN_TICK_START 0x3000/*3 minitues,make sure all process started*/

#define INTERV_HANDINT 5000

static int data_cleared = 0;

extern int watdog_dead_on_cpu;

extern void dump_wdog_info(void);

extern unsigned long push_maxtime_ns[];

extern unsigned long pull_maxtime_ns[];

extern unsigned long timer_maxtime_ns[];

extern unsigned long hrtime_func_maxtime_ns[];

extern unsigned long hrtime_func_maxtime_name[];

extern void dump_wdog_info(void);

void dump_max_data(void)

{

 static int has_printed = 0;

 int i = 0;

 unsigned long long dead_time;

 dead_time = ktime_to_ns(ktime_get());

 if(has_printed)

  return;

 has_printed = 1;

 printk("Dump all cpu max data[%lldms]:\n",dead_time>>20);

 for(;i<32;++i){

  printk("cpu[%d]'s push max time:%ldms\n",i,(push_maxtime_ns[i]>>20));

  printk("cpu[%d]'s pull max time:%ldms\n",i,(pull_maxtime_ns[i]>>20));

  printk("cpu[%d]'s timer max time:%ldms\n",i,(timer_maxtime_ns[i]>>20));

  printk("cpu[%d]'s hrtimer max time:%ldms,",i,(hrtime_func_maxtime_ns[i]>>20));

  print_symbol("name:%s\n",hrtime_func_maxtime_name[i]);

 }

}

void dump_max_data_timer_list(void)

{

 int i = 0;

 printk("Dump all cpu max data in timer_list:\n");

 for(;i<32;++i){

  printk("cpu[%d]'s push max time:%ldms\n",i,(push_maxtime_ns[i]>>20));

  printk("cpu[%d]'s pull max time:%ldms\n",i,(pull_maxtime_ns[i]>>20));

  printk("cpu[%d]'s timer max time:%ldms\n",i,(timer_maxtime_ns[i]>>20));

 }

}

void check_timer_start(void)

{

 int i = 1;

 for(;i<32;++i)

  cpu_timer_tick[i]=kstat_irqs_cpu(7, i);

}

void check_timer_end(void)

{

 int i = 1;

 for(;i<32;++i){

   /*should I dump only once?*/

   if(cpu_flag_dump[i]==1)

    continue;

   

   if((kstat_irqs_cpu(7, i)>MIN_TICK_START)&&(cpu_timer_tick[i]==kstat_irqs_cpu(7, i))){

     int save_console_level = console_loglevel;

     console_loglevel = 4;

     mips_send_nmi_single(i);

     printk("send nmi to cpu[%d]\n",i);

     cpu_flag_dump[i] = 1;

     system_is_down = 1;

     dump_max_data();

     console_loglevel = save_console_level;

    

   }

  }

}

void check_dead_cpu(void)

{

 if(system_is_down)

  return;

 if(time_after64(jiffies_64,         

                             last_tick_cpu0

                             +sysctl_dead_time)){

        last_tick_cpu0=jiffies_64;

  if(cpu0_checking){

   cpu0_checking = 0;

   check_timer_end();

  }else{

      cpu0_checking = 1;

   check_timer_start();

  }

 }

}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  timer system list