irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
/*
|
|
|
|
* irqtop.c - utility to display kernel interrupt information.
|
|
|
|
*
|
2020-03-06 07:04:33 -06:00
|
|
|
* Copyright (C) 2019 zhenwei pi <pizhenwei@bytedance.com>
|
|
|
|
* Copyright (C) 2020 Karel Zak <kzak@redhat.com>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2020-01-03 15:06:43 -06:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <limits.h>
|
|
|
|
#include <locale.h>
|
2020-01-03 15:06:43 -06:00
|
|
|
#include <signal.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <stdio.h>
|
2020-01-03 15:06:43 -06:00
|
|
|
#include <stdlib.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <string.h>
|
2020-01-05 03:27:19 -06:00
|
|
|
#include <sys/epoll.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/select.h>
|
2020-01-05 03:27:19 -06:00
|
|
|
#include <sys/signalfd.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <sys/time.h>
|
2020-01-05 03:27:19 -06:00
|
|
|
#include <sys/timerfd.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <sys/types.h>
|
2020-01-03 15:06:43 -06:00
|
|
|
#include <termios.h>
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2020-01-03 15:06:43 -06:00
|
|
|
#ifdef HAVE_SLCURSES_H
|
|
|
|
# include <slcurses.h>
|
|
|
|
#elif defined(HAVE_SLANG_SLCURSES_H)
|
|
|
|
# include <slang/slcurses.h>
|
|
|
|
#elif defined(HAVE_NCURSESW_NCURSES_H) && defined(HAVE_WIDECHAR)
|
|
|
|
# include <ncursesw/ncurses.h>
|
|
|
|
#elif defined(HAVE_NCURSES_H)
|
|
|
|
# include <ncurses.h>
|
|
|
|
#elif defined(HAVE_NCURSES_NCURSES_H)
|
|
|
|
# include <ncurses/ncurses.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_WIDECHAR
|
|
|
|
# include <wctype.h>
|
|
|
|
# include <wchar.h>
|
|
|
|
#endif
|
|
|
|
|
2020-02-08 10:00:20 -06:00
|
|
|
#include <libsmartcols.h>
|
|
|
|
|
2020-01-03 15:06:43 -06:00
|
|
|
#include "c.h"
|
|
|
|
#include "closestream.h"
|
2020-01-04 01:45:43 -06:00
|
|
|
#include "monotonic.h"
|
2020-01-03 15:06:43 -06:00
|
|
|
#include "nls.h"
|
|
|
|
#include "pathnames.h"
|
2020-01-04 02:32:42 -06:00
|
|
|
#include "strutils.h"
|
2020-01-05 04:40:12 -06:00
|
|
|
#include "timeutils.h"
|
2020-01-04 01:33:01 -06:00
|
|
|
#include "ttyutils.h"
|
2020-01-04 01:40:49 -06:00
|
|
|
#include "xalloc.h"
|
2020-01-03 15:06:43 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
#include "irq-common.h"
|
2020-02-24 12:26:38 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
#define MAX_EVENTS 3
|
2020-03-06 06:38:02 -06:00
|
|
|
|
2020-01-04 02:08:17 -06:00
|
|
|
struct irqtop_ctl {
|
|
|
|
int cols;
|
|
|
|
int rows;
|
2020-01-05 03:27:19 -06:00
|
|
|
struct itimerspec timer;
|
2020-02-21 16:28:43 -06:00
|
|
|
struct irq_stat *prev_stat;
|
2020-01-05 04:40:12 -06:00
|
|
|
char *hostname;
|
2020-03-06 04:40:49 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
unsigned int request_exit:1;
|
2020-03-06 06:38:02 -06:00
|
|
|
|
2020-01-04 02:08:17 -06:00
|
|
|
};
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
static void parse_input(struct irqtop_ctl *ctl, struct irq_output *out, char c)
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
{
|
2020-01-03 15:06:43 -06:00
|
|
|
switch (c) {
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
case 'i':
|
2020-03-06 06:38:02 -06:00
|
|
|
out->sort_func = sort_interrupts;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
break;
|
2020-02-22 10:42:56 -06:00
|
|
|
case 't':
|
2020-03-06 06:38:02 -06:00
|
|
|
out->sort_func = sort_total;
|
2020-02-22 10:42:56 -06:00
|
|
|
break;
|
|
|
|
case 'd':
|
2020-03-06 06:38:02 -06:00
|
|
|
out->sort_func = sort_delta;
|
2020-02-22 10:42:56 -06:00
|
|
|
break;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
case 'n':
|
2020-03-06 06:38:02 -06:00
|
|
|
out->sort_func = sort_name;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
case 'Q':
|
2020-01-04 02:32:42 -06:00
|
|
|
ctl->request_exit = 1;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
static int update_screen(struct irqtop_ctl *ctl, struct irq_output *out, WINDOW *win)
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
{
|
2020-03-06 05:56:56 -06:00
|
|
|
struct libscols_table *table;
|
2020-01-05 03:00:28 -06:00
|
|
|
struct irq_stat *stat;
|
2020-03-06 05:44:16 -06:00
|
|
|
time_t now = time(NULL);
|
|
|
|
char timestr[64], *data;
|
2020-01-05 03:00:28 -06:00
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
table = get_scols_table(out, ctl->prev_stat, &stat);
|
2020-03-06 05:56:56 -06:00
|
|
|
if (!table) {
|
2020-01-05 03:00:28 -06:00
|
|
|
ctl->request_exit = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-03-04 07:51:12 -06:00
|
|
|
/* header in interactive mode */
|
2020-03-06 05:44:16 -06:00
|
|
|
move(0, 0);
|
|
|
|
strtime_iso(&now, ISO_TIMESTAMP, timestr, sizeof(timestr));
|
|
|
|
wprintw(win, _("irqtop | total: %ld delta: %ld | %s | %s\n\n"),
|
2020-02-22 10:42:56 -06:00
|
|
|
stat->total_irq, stat->delta_irq, ctl->hostname, timestr);
|
2020-02-08 10:00:20 -06:00
|
|
|
|
2020-03-06 05:56:56 -06:00
|
|
|
scols_print_table_to_string(table, &data);
|
2020-03-06 05:44:16 -06:00
|
|
|
wprintw(win, "%s", data);
|
|
|
|
free(data);
|
|
|
|
|
2020-02-22 08:48:55 -06:00
|
|
|
/* clean up */
|
2020-03-06 05:56:56 -06:00
|
|
|
scols_unref_table(table);
|
2020-02-22 10:42:56 -06:00
|
|
|
if (ctl->prev_stat)
|
|
|
|
free_irqinfo(ctl->prev_stat);
|
|
|
|
ctl->prev_stat = stat;
|
2020-01-05 03:00:28 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
static int event_loop(struct irqtop_ctl *ctl, struct irq_output *out, WINDOW *win)
|
2020-01-05 03:27:19 -06:00
|
|
|
{
|
|
|
|
int efd, sfd, tfd;
|
|
|
|
sigset_t sigmask;
|
|
|
|
struct signalfd_siginfo siginfo;
|
|
|
|
struct epoll_event ev, events[MAX_EVENTS];
|
|
|
|
long int nr;
|
|
|
|
uint64_t unused;
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
efd = epoll_create1(0);
|
|
|
|
|
|
|
|
if ((tfd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0)
|
|
|
|
err(EXIT_FAILURE, _("cannot not create timerfd"));
|
|
|
|
if (timerfd_settime(tfd, 0, &ctl->timer, NULL) != 0)
|
|
|
|
err(EXIT_FAILURE, _("cannot set timerfd"));
|
2020-03-04 07:47:20 -06:00
|
|
|
|
2020-01-05 03:27:19 -06:00
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = tfd;
|
|
|
|
if (epoll_ctl(efd, EPOLL_CTL_ADD, tfd, &ev) != 0)
|
|
|
|
err(EXIT_FAILURE, _("epoll_ctl failed"));
|
|
|
|
|
|
|
|
if (sigfillset(&sigmask) != 0)
|
|
|
|
err(EXIT_FAILURE, _("sigfillset failed"));
|
|
|
|
if (sigprocmask(SIG_BLOCK, &sigmask, NULL) != 0)
|
|
|
|
err(EXIT_FAILURE, _("sigprocmask failed"));
|
2020-03-04 07:47:20 -06:00
|
|
|
|
|
|
|
sigaddset(&sigmask, SIGWINCH);
|
|
|
|
sigaddset(&sigmask, SIGTERM);
|
|
|
|
sigaddset(&sigmask, SIGINT);
|
|
|
|
sigaddset(&sigmask, SIGQUIT);
|
|
|
|
|
|
|
|
if ((sfd = signalfd(-1, &sigmask, SFD_CLOEXEC)) < 0)
|
2020-01-05 03:27:19 -06:00
|
|
|
err(EXIT_FAILURE, _("cannot not create signalfd"));
|
2020-03-04 07:47:20 -06:00
|
|
|
|
2020-01-05 03:27:19 -06:00
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = sfd;
|
|
|
|
if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd, &ev) != 0)
|
|
|
|
err(EXIT_FAILURE, _("epoll_ctl failed"));
|
|
|
|
|
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = STDIN_FILENO;
|
|
|
|
if (epoll_ctl(efd, EPOLL_CTL_ADD, STDIN_FILENO, &ev) != 0)
|
|
|
|
err(EXIT_FAILURE, _("epoll_ctl failed"));
|
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
retval |= update_screen(ctl, out, win);
|
2020-01-05 03:27:19 -06:00
|
|
|
refresh();
|
|
|
|
|
|
|
|
while (!ctl->request_exit) {
|
|
|
|
const ssize_t nr_events = epoll_wait(efd, events, MAX_EVENTS, -1);
|
|
|
|
|
|
|
|
for (nr = 0; nr < nr_events; nr++) {
|
|
|
|
if (events[nr].data.fd == tfd) {
|
|
|
|
if (read(tfd, &unused, sizeof(unused)) < 0)
|
|
|
|
warn(_("read failed"));
|
|
|
|
} else if (events[nr].data.fd == sfd) {
|
|
|
|
if (read(sfd, &siginfo, sizeof(siginfo)) < 0) {
|
|
|
|
warn(_("read failed"));
|
|
|
|
continue;
|
|
|
|
}
|
2020-03-04 07:47:20 -06:00
|
|
|
if (siginfo.ssi_signo == SIGWINCH) {
|
2020-01-05 03:27:19 -06:00
|
|
|
get_terminal_dimension(&ctl->cols, &ctl->rows);
|
2020-03-04 07:47:20 -06:00
|
|
|
resizeterm(ctl->rows, ctl->cols);
|
|
|
|
}
|
2020-01-05 03:27:19 -06:00
|
|
|
else {
|
|
|
|
ctl->request_exit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (events[nr].data.fd == STDIN_FILENO) {
|
|
|
|
char c;
|
|
|
|
|
|
|
|
if (read(STDIN_FILENO, &c, 1) != 1)
|
|
|
|
warn(_("read failed"));
|
2020-03-06 06:38:02 -06:00
|
|
|
parse_input(ctl, out, c);
|
2020-01-05 03:27:19 -06:00
|
|
|
} else
|
|
|
|
abort();
|
2020-03-06 06:38:02 -06:00
|
|
|
retval |= update_screen(ctl, out, win);
|
2020-01-05 03:27:19 -06:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2020-03-06 05:12:12 -06:00
|
|
|
static void __attribute__((__noreturn__)) usage(void)
|
|
|
|
{
|
|
|
|
fputs(USAGE_HEADER, stdout);
|
|
|
|
printf(_(" %s [options]\n"), program_invocation_short_name);
|
|
|
|
fputs(USAGE_SEPARATOR, stdout);
|
|
|
|
|
|
|
|
puts(_("Interactive utility to display kernel interrupt information."));
|
|
|
|
|
|
|
|
fputs(USAGE_OPTIONS, stdout);
|
|
|
|
fputs(_(" -d, --delay <secs> delay updates\n"), stdout);
|
|
|
|
fputs(_(" --once only display interrupts once, then exit\n"), stdout);
|
|
|
|
fputs(_(" -J --json output json, implies displaying once\n"), stdout);
|
|
|
|
fputs(_(" -o --output <list> define which output columns to use (see below)\n"), stdout);
|
|
|
|
fputs(_(" -s, --sort <char> specify sort criteria by character (see below)\n"), stdout);
|
|
|
|
fputs(USAGE_SEPARATOR, stdout);
|
|
|
|
printf(USAGE_HELP_OPTIONS(22));
|
|
|
|
|
|
|
|
fputs(_("\nThe following interactive key commands are valid:\n"), stdout);
|
|
|
|
fputs(_(" i sort by IRQ\n"), stdout);
|
|
|
|
fputs(_(" t sort by TOTAL\n"), stdout);
|
|
|
|
fputs(_(" d sort by DELTA\n"), stdout);
|
|
|
|
fputs(_(" n sort by NAME\n"), stdout);
|
|
|
|
fputs(_(" q Q quit program\n"), stdout);
|
|
|
|
|
|
|
|
fputs(USAGE_COLUMNS, stdout);
|
2020-03-06 07:04:33 -06:00
|
|
|
irq_print_columns(stdout);
|
2020-03-06 05:12:12 -06:00
|
|
|
|
|
|
|
printf(USAGE_MAN_TAIL("irqtop(1)"));
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
static void parse_args( struct irqtop_ctl *ctl,
|
|
|
|
struct irq_output *out,
|
|
|
|
int argc,
|
|
|
|
char **argv)
|
2020-01-05 03:00:28 -06:00
|
|
|
{
|
2020-03-06 04:40:49 -06:00
|
|
|
const char *outarg = NULL;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
static const struct option longopts[] = {
|
2020-01-03 15:06:43 -06:00
|
|
|
{"delay", required_argument, NULL, 'd'},
|
|
|
|
{"sort", required_argument, NULL, 's'},
|
2020-03-06 04:40:49 -06:00
|
|
|
{"output", required_argument, NULL, 'o'},
|
2020-01-03 15:06:43 -06:00
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"version", no_argument, NULL, 'V'},
|
|
|
|
{NULL, 0, NULL, 0}
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
};
|
2020-01-05 03:00:28 -06:00
|
|
|
int o;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
|
2020-03-06 04:40:49 -06:00
|
|
|
while ((o = getopt_long(argc, argv, "d:o:s:hJV", longopts, NULL)) != -1) {
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
switch (o) {
|
|
|
|
case 'd':
|
2020-01-05 03:27:19 -06:00
|
|
|
{
|
|
|
|
struct timeval delay;
|
|
|
|
|
|
|
|
strtotimeval_or_err(optarg, &delay,
|
|
|
|
_("failed to parse delay argument"));
|
|
|
|
TIMEVAL_TO_TIMESPEC(&delay, &ctl->timer.it_interval);
|
|
|
|
ctl->timer.it_value = ctl->timer.it_interval;
|
|
|
|
}
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
break;
|
|
|
|
case 's':
|
2020-03-06 06:38:02 -06:00
|
|
|
out->sort_func = set_sort_func(optarg[0]);
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
break;
|
2020-03-06 04:40:49 -06:00
|
|
|
case 'o':
|
|
|
|
outarg = optarg;
|
2020-02-08 10:00:20 -06:00
|
|
|
break;
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
case 'V':
|
2020-01-03 15:06:43 -06:00
|
|
|
print_version(EXIT_SUCCESS);
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
case 'h':
|
2020-01-03 15:06:43 -06:00
|
|
|
usage();
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
default:
|
2020-01-05 03:00:28 -06:00
|
|
|
errtryhelp(EXIT_FAILURE);
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
}
|
|
|
|
}
|
2020-03-06 04:40:49 -06:00
|
|
|
|
|
|
|
/* default */
|
2020-03-06 06:38:02 -06:00
|
|
|
if (!out->ncolumns) {
|
|
|
|
out->columns[out->ncolumns++] = COL_IRQ;
|
|
|
|
out->columns[out->ncolumns++] = COL_TOTAL;
|
2020-03-06 07:04:33 -06:00
|
|
|
out->columns[out->ncolumns++] = COL_DELTA;
|
2020-03-06 06:38:02 -06:00
|
|
|
out->columns[out->ncolumns++] = COL_NAME;
|
2020-03-06 04:40:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add -o [+]<list> to putput */
|
2020-03-06 06:38:02 -06:00
|
|
|
if (outarg && string_add_to_idarray(outarg, out->columns,
|
|
|
|
ARRAY_SIZE(out->columns),
|
2020-03-06 07:04:33 -06:00
|
|
|
&out->ncolumns,
|
|
|
|
irq_column_name_to_id) < 0)
|
2020-03-06 04:40:49 -06:00
|
|
|
exit(EXIT_FAILURE);
|
2020-01-05 03:00:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2020-03-06 05:32:39 -06:00
|
|
|
WINDOW *win = NULL;
|
2020-03-04 07:47:20 -06:00
|
|
|
int is_tty = 0;
|
2020-01-05 03:00:28 -06:00
|
|
|
int retval = EXIT_SUCCESS;
|
|
|
|
struct termios saved_tty;
|
2020-03-06 06:38:02 -06:00
|
|
|
struct irq_output out = { .ncolumns = 0, .sort_func = DEF_SORT_FUNC };
|
2020-01-05 03:27:19 -06:00
|
|
|
struct irqtop_ctl ctl = {
|
|
|
|
.timer.it_interval = {3, 0},
|
|
|
|
.timer.it_value = {3, 0}
|
|
|
|
};
|
2020-01-05 03:00:28 -06:00
|
|
|
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
2020-03-06 06:38:02 -06:00
|
|
|
parse_args(&ctl, &out, argc, argv);
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
is_tty = isatty(STDIN_FILENO);
|
|
|
|
if (is_tty && tcgetattr(STDIN_FILENO, &saved_tty) == -1)
|
|
|
|
fputs(_("terminal setting retrieval"), stdout);
|
2020-03-04 07:47:20 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
win = initscr();
|
|
|
|
get_terminal_dimension(&ctl.cols, &ctl.rows);
|
|
|
|
resizeterm(ctl.rows, ctl.cols);
|
|
|
|
curs_set(0);
|
2020-03-04 07:47:20 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
ctl.hostname = xgethostname();
|
|
|
|
event_loop(&ctl, &out, win);
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
|
2020-03-06 07:04:33 -06:00
|
|
|
free_irqinfo(ctl.prev_stat);
|
|
|
|
free(ctl.hostname);
|
|
|
|
|
|
|
|
if (is_tty)
|
|
|
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
|
|
|
|
delwin(win);
|
|
|
|
endwin();
|
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.
so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.
irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
IRQ COUNT DESC
CAL 21196 Function call interrupts
LOC 13733 Local timer interrupts
154 1430 IR-PCI-MSI 32768-edge i915
127 1322 IR-PCI-MSI 327680-edge xhci_hcd
RES 1224 Rescheduling interrupts
146 336 IR-PCI-MSI 520192-edge enp0s31f6
IWI 135 IRQ work interrupts
147 48 IR-PCI-MSI 31981569-edge nvme0q2
151 42 IR-PCI-MSI 31981573-edge nvme0q6
TLB 8 TLB shootdowns
150 7 IR-PCI-MSI 31981572-edge nvme0q5
152 5 IR-PCI-MSI 31981574-edge nvme0q7
156 4 IR-PCI-MSI 1572864-edge iwlwifi
148 3 IR-PCI-MSI 31981570-edge nvme0q3
153 2 IR-PCI-MSI 31981575-edge nvme0q8
NMI 2 Non-maskable interrupts
PMI 2 Performance monitoring interrupts
0 0 IR-IO-APIC 2-edge timer
1 0 IR-IO-APIC 1-edge i8042
8 0 IR-IO-APIC 8-edge rtc0
9 0 IR-IO-APIC 9-fasteoi acpi
12 0 IR-IO-APIC 12-edge i8042
test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2019-11-11 06:48:59 -06:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|