/proc/interrupts

cat /proc/interrupts 

读取到的内容从左到右,分别为:1、逻辑中断号,2、中断在各CPU发生的次数,3、中断所属设备类名称,4、硬件中断号,5、中断处理函数。

如下图:

代码实现分析如下红色字体1~ 5 . 

489  int show_interrupts(struct seq_file *p, void *v)
490  {
491      static int prec;
492  
493      unsigned long flags, any_count = 0;
494      int i = *(loff_t *) v, j;
495      struct irqaction *action;
496      struct irq_desc *desc;
497  
498      if (i > ACTUAL_NR_IRQS)
499          return 0;
500  
501      if (i == ACTUAL_NR_IRQS)
502          return arch_show_interrupts(p, prec);
503 
504      /* print header and calculate the width of the first column */   
505      if (i == 0) {
506          for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec)
507              j *= 10;
508  
509          seq_printf(p, "%*s", prec + 8, "");
510          for_each_online_cpu(j)
511              seq_printf(p, "CPU%-8d", j);
512          seq_putc(p, '\n');
513      }
514  
515      irq_lock_sparse();
516      desc = irq_to_desc(i);
517      if (!desc)
518          goto outsparse;
519  
520      raw_spin_lock_irqsave(&desc->lock, flags);
521      for_each_online_cpu(j)
522          any_count |= kstat_irqs_cpu(i, j);
523      action = desc->action;
524      if (!action && !any_count)
525          goto out;
526  
527      seq_printf(p, "%*d: ", prec, i);     //1、打印逻辑中断号

528      for_each_online_cpu(j)
529          seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));    //2、打印中断次数
530  
531      if (desc->irq_data.chip) {
532          if (desc->irq_data.chip->irq_print_chip)
533              desc->irq_data.chip->irq_print_chip(&desc->irq_data, p);
534          else if (desc->irq_data.chip->name)
535              seq_printf(p, " %8s", desc->irq_data.chip->name);   //3、打印中断名称
536          else
537              seq_printf(p, " %8s", "-");
538      } else {
539          seq_printf(p, " %8s", "None");
540      }
541      if (desc->irq_data.domain)
542          seq_printf(p, " %*d", prec, (int) desc->irq_data.hwirq);        //4、打印硬件中断号,比如,gpio number 
543  #ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL
544      seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");  //打印中断触发类型
545  #endif
546      if (desc->name)
547          seq_printf(p, "-%-8s", desc->name);
548  
549      if (action) {
550          seq_printf(p, "  %s", action->name);
551          while ((action = action->next) != NULL)
552              seq_printf(p, ", %s", action->name);    //5、打印中断处理函数名称
553      }
554  
555      seq_putc(p, '\n');
556  out:
557      raw_spin_unlock_irqrestore(&desc->lock, flags);
558  outsparse:
559      irq_unlock_sparse();
560      return 0;
561  }
562 
--------------------- 
作者:fybon 
来源:CSDN 
原文:https://blog.csdn.net/fybon/article/details/78414794 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值