分享

itop更方便的了解Linux下中断情况 -- Linux -- IT技术大学习 -- 共学习 共进步!

 mzsm 2015-01-25
    在作网络程序的时候, 经常需要了解interrupts和软中断的平衡情况, 需要知道每秒有多少中断发生,发生在哪个cpu上.

     Linux下中断来源可以从 /proc/interrupts 中了解到:

$ cat /proc/interrupts           CPU0       CPU1  0:     247701     250313   IO-APIC-edge      timer  1:        501        567   IO-APIC-edge      i8042  3:          1          1   IO-APIC-edge  8:          1          0   IO-APIC-edge      rtc0  9:        256        240   IO-APIC-fasteoi   acpi 12:       1134       1149   IO-APIC-edge      i8042 16:        629        554   IO-APIC-fasteoi   nvidia 17:      21313      20869   IO-APIC-fasteoi   firewire_ohci, eth1 18:          0          0   IO-APIC-fasteoi   mmc0 19:      51822      50079   IO-APIC-fasteoi   ata_piix, ata_piix 20:       5605       5255   IO-APIC-fasteoi   ehci_hcd:usb2, uhci_hcd:usb3, uhci_hcd:usb6 21:          0          0   IO-APIC-fasteoi   uhci_hcd:usb4, uhci_hcd:usb7 22:         33         33   IO-APIC-fasteoi   ehci_hcd:usb1, uhci_hcd:usb5, uhci_hcd:usb8 45:        337        247   PCI-MSI-edge      eth0 46:        441        447   PCI-MSI-edge      hda_intelNMI:          0          0   Non-maskable interruptsLOC:     169176     174899   Local timer interruptsSPU:          0          0   Spurious interruptsPMI:          0          0   Performance monitoring interruptsPND:          0          0   Performance pending workRES:      42289      40236   Rescheduling interruptsCAL:        154       1076   Function call interruptsTLB:       5838       5365   TLB shootdownsTRM:          0          0   Thermal event interruptsTHR:          0          0   Threshold APIC interruptsMCE:          0          0   Machine check exceptionsMCP:          5          5   Machine check pollsERR:          1MIS:          0

    软中断可以从/proc/softirqs 了解到:

$ cat /proc/softirqs                CPU0       CPU1      HI:          0          0   TIMER:     160508    1170976  NET_TX:          2          2  NET_RX:       3303       3165   BLOCK:      50964      49198BLOCK_IOPOLL:          0          0 TASKLET:      24743      24284   SCHED:      39483      41848 HRTIMER:         34         40     RCU:      92193      92592

    总的中断次数可以从vmstat或者dstat了解到:

$ vmstatprocs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa 3  0      0  44160 327144 876600    0    0   894   584  458 2295 11  5 70 15

    top提供了更方便的方式了解,作者Hunz在源码里面写:

    It’s quite simple but it does its job.

    虽然简单,但是适用:

    Ubutun下可以这样安装: apt-get install itop

$ itopINT                NAME          RATE             MAX  0 [PIC-edge      time]   628 Ints/s     (max:   628)  1 [PIC-edge      i804]     4 Ints/s     (max:     4) 17 [PIC-fasteoi   fire]     8 Ints/s     (max:    22) 19 [PIC-fasteoi   ata_]     1 Ints/s     (max:    14) 20 [PIC-fasteoi   ehci]    25 Ints/s     (max:    25) 45 [MSI-edge      eth0]     1 Ints/s     (max:     1)

    他会计算每秒每个中断源中断的次数,看起来比较方便.

    祝玩的开心!

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多