软件检测系统所有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.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();
}
}
}
相关文章推荐
- 系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- ARM基础:系统调用与软件中断SWI的实现
- 系统调用与软件中断SWI的实现
- 验机软件大集合(CPU、硬盘、显卡、系统检测类有更新)[转自it168]
- 系统调用与软件中断SWI的实现
- SoC嵌入式软件架构设计II:否MMU的CPU虚拟内存管理的设计与实现方法
- 计算机监控系统仿真开发平台的软件实现(上)
- 获得Android系统所有已安装的应用并联网自动检测升级更新
- 笔记 基于OpenCV的目标跟踪软件与系统实现
- 用应用程序域实现软件系统的热插拔
- 根据接口名字查询系统中所有的实现类
- 免费论文检测 论文查重 软件 系统 论文免费检测 论文抄袭检测大师
- Android-->检测内置/外置SD卡存储卡,枚举所有挂载点(通过反射实现),监听SD卡广播
- 获得Android系统所有已安装的应用并联网自动检测升级更新
- 中国特色管理类软件项目开发之权限必杀技 -- 权限配置自由设定、实现智能化自动检测校验权限配置