Commit Graph

45 Commits

Author SHA1 Message Date
Karel Zak a23aecc1bf irqtop: add per-cpu stats
irqtop | total: 1245107402 delta: 7394 | ws.net.home | 2021-02-24 20:11:09+01:00

        cpu0 cpu1 cpu2 cpu3 cpu4 cpu5 cpu6 cpu7
  %irq: 12.9 13.0 12.8 11.9 12.4 13.4 11.6 12.0
%delta: 13.7  9.7 22.6  7.9  9.5 17.5  8.3 10.8

       IRQ      TOTAL      DELTA NAME
       LOC  989162414       6111 Local timer interrupts
       TLB  100492740         67 TLB shootdowns
       CAL   95058001        321 Function call interrupts
        42   23893801        241 IR-PCI-MSI 1048576-edge nvidia
        30   20209392        494 IR-PCI-MSI 327680-edge xhci_hcd
       RES   12996335         86 Rescheduling interrupts
        29    1354219          4 IR-PCI-MSI 512000-edge ahci[0000:00:1f.2]
        41     682653         31 IR-PCI-MSI 409600-edge eno1
   ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-24 20:11:05 +01:00
Karel Zak 1b889dcc07 irqtop: print header in reverse mode
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-24 14:29:20 +01:00
zhenwei pi b2a49bc243 irqtop/lsirq: add additional desc for softirq
Suggested by Karel, add additional description to make softirq more
friendly to end-user. Discuss about this:
    https://github.com/karelzak/util-linux/pull/1079

Note that, we should keep softirqs table align to kernel source code.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-07-23 12:23:56 +02:00
zhenwei pi b6ce063b04 irqtop/lsirq: support softirq
Add '-S' or '--softirq' for irqtop/lsirq, instead of interrupts, show
softirqs infomation. Because there is no more description of softirq,
do not show 'NAME' column by default.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-07-23 12:23:56 +02:00
Karel Zak 5868026e2c build-sys: fix irqtop compilation with -lslang
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-08 13:18:20 +02:00
Karel Zak a0f62b0b20 lsirq: add new command
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 16:21:10 +01:00
Karel Zak 44e39c9940 irqtop: cleanup sort stuff
* user "cmp" in the function names (it does not sort)
* keep all in irq-common.c
* use column names on command line (e.g. --sort NAME)
* hardcode default to sort_result()

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 15:29:03 +01:00
Karel Zak e925cf378f irqtop: small cleanup in main() 2020-03-06 14:55:19 +01:00
Karel Zak 77f57b90f7 irqtop: cleanup struct irq_stat use
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 14:49:53 +01:00
Karel Zak 9c0740fc64 irqtop: move WINDOW back to control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 14:21:46 +01:00
Karel Zak 02f2919e95 irqtop: minor cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 14:11:30 +01:00
Karel Zak 94e7e258a3 irqtop: move independent code to irq-common.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 14:04:33 +01:00
Karel Zak c6ccf2ec96 irqtop: add struct irq_output
* add irq_output to keep top-like stufff independent on data
  management

* remove horrible "const"

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 13:38:02 +01:00
Karel Zak 212ca752c1 irqtop: keep table in functions only
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:56:56 +01:00
Karel Zak a6fa6aad4b irqtop: remove dead code
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:46:45 +01:00
Karel Zak ec95b4365f irqtop: separate normal and ncurses way
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:44:16 +01:00
Karel Zak d5280921be irqtop: remove unnecessary code
* remove unused code smp_num_cpus
* care about hostname and timer only real top-like output

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:36:41 +01:00
Karel Zak 60794bd2c6 irqtop: keep WINDOW pointer in functions only
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:32:39 +01:00
Karel Zak f675b00803 irqtop: separate screen and scols code
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:25:40 +01:00
Karel Zak bd83424b80 irqtop: reorder function
Move functions to make next changes more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:12:12 +01:00
Karel Zak 487c746638 irqtop: cleanup command line options
* use -o for output columns (like we have in another tools)
* support -o +COLUMN

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 12:06:22 +01:00
Sami Kerola b5886f298e
irqtop: trim white spaces from end of name field
Excess white spaces were easiest to see in json output.

    $ irqtop --once --json
    {
       "interrupts": [
          {"irq":"LOC", "total":7425148, "name":"Local timer interrupts "},
          {"irq":"51", "total":1848384, "name":"IR-PCI-MSI 32768-edge i915 "},
          {"irq":"RES", "total":1176665, "name":"Rescheduling interrupts "},
          ...

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-04 21:40:24 +00:00
Karel Zak f5377ca454 irqtop: use -J for JSON
* add -J to the man page
* add note about default output
* be compatible with another util-linux tools and use -J

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-04 14:58:18 +01:00
Karel Zak 0d8ead9327 irqtop: don't print header for --once
We don't use any extra header for lsblk, lsmem, ... so don't make it
different.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-04 14:51:12 +01:00
Karel Zak 642f6cb0cb irqtop: simplify terminal resizing
* don't care about term size and attrs when runs only once
* explicitly define signals
* resize immediately after SIGWINCH (to keep it nice for users)

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-04 14:47:20 +01:00
Karel Zak 6f99d9d613 iqrtop: cleanup header
* add '|' to make it more readable
* use time string without 'T'

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-04 14:17:27 +01:00
Sami Kerola d7f9cdf535
irqtop: tidy coding style and update usage() text
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-24 18:26:38 +00:00
Sami Kerola d77e9e13dd
irqtop: do not use fixed size /proc/interrupts line buffer
Allocating and freeing all the time is a little bit heavier, but it is also
more robust.  It is impossible to know if field lenghts stay fixed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-23 17:36:33 +00:00
Sami Kerola 68afc56bcd
irqtop: add total and delta as own columns
This commit add total and delta as separate columns rather than a toggle,
making output generally more informative.  When using command I found that
sort order key bindings should match with first letter of column headers so
that they are as easy as possible to remember, and therefore enhancing user
experience.

Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-23 17:27:12 +00:00
Sami Kerola 28ddd62bed
irqtop: use name instead of desc as irq name field referal
This matches with sort order n for name, and allows later usage of d for
delta without needing to go around d for description.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola daee272009
irqtop: improve header
Change total to display delta or count depending on run mode.  Add space in
between header and irqtop body.  Print only number of active CPU in header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola bf611f4034
irqtop: hide cursor when in interactive mode
Visible cursor is distraction.  Secondly with visible cursor key commands
can be visible adding unwanted characters to end of output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola 11b20fb29d
irqtop: display number of new interupts in-between updates
The rirst output is total count followed by number of interupts since
previous screen update.  This is how the irqtop worked before libsmartcols
was added to the command.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola 8d8cef8045
irqtop: use libsmartcols
This makes output to be automatically be nicely adjusted to optimal width.
In this commit also removes excess spaces from description strings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:40 +00:00
Sami Kerola a163d853c6
irqtop: include hostname and timestamp to output header
Having a when and from where information is useful in situations when output
is examined later and possibly elsewhere.  Typical example would be a
screenshot or output copy-paste of a terminal to a ticketing system.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola fa8c5cd503
irqtop: use epoll event loop
The event loop takes care of the standard screen updates, signals, and user
inputs.  Two nice things using even loop like this are; 1) no need for any
global variables and 2) effect of user commands is immediate.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola 29135b2320
irqtop: move screen update to a separate function
The main() was too long.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola bc90c16a78
irqtop: fix open file descriptor leak
With very short delay one can see irqfile file descriptors pile up rather
quickly causing program to stop with too many open files error.  This commit
fixes that, and removes couple other memory leaks.  With these the command
should hopefully run fine for days if not even months.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 4e55ffbdde
irqtop: change the update delay to use struct timeval
The struct timeval is more expressive, and it allows use of fractional and
subsecond intervals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola a937ed0fd4
irqtop: use runtime control structure
This is pretty standard util-linux way to avoid global variables, and pass
runtime configuration around.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 465e279a26
irqtop: use lib/monotonic.c to determine uptime
This should be functionally the same, and has the advantage of avoiding
duplicated code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 9aea73b3ba
irqtop: use memory allocation that check errors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola a11660d155
irqtop: avoid function like pre-processor definitions
And simplify how terminal size determination.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 57e3dc061b
irqtop: use util-linux libcommon facilities
Including NLS support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 952690cfd2
irctop: move source code to sys-utils/ directory
And remove files that util-linux does not need from the earlier repository.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:13 +00:00