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
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、列印邏輯中斷号