Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx> Cc: Zhenwei Pi <pizhenwei@xxxxxxxxxxxxx> Cc: Sami Kerola <kerolasa@xxxxxx> Cc: Karel Zak <kzak@xxxxxxxxxx> --- sys-utils/irqtop.1.adoc | 4 +++- sys-utils/irqtop.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/sys-utils/irqtop.1.adoc b/sys-utils/irqtop.1.adoc index 880ee1906..b9962ce1c 100644 --- a/sys-utils/irqtop.1.adoc +++ b/sys-utils/irqtop.1.adoc @@ -12,7 +12,7 @@ irqtop - utility to display kernel interrupt information == SYNOPSIS -*irqtop* [options] +*irqtop* [options]... [IRQ] [PATTERN] ... == DESCRIPTION @@ -20,6 +20,8 @@ Display kernel interrupt counter information in *top*(1) style view. The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using *--output*. +Displays interrupt counter information only for the specified _IRQ_ or for irqnames matching _PATTERN_ when given. + == OPTIONS *-o*, *--output* _list_:: diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index dc59f4829..c5deb840b 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -87,6 +87,8 @@ struct irqtop_ctl { bool batch; bool request_exit, softirq; + + char **filters; }; static inline int irqtop_printf(struct irqtop_ctl *ctl, const char *fmt, ...) @@ -140,7 +142,7 @@ static int update_screen(struct irqtop_ctl *ctl, struct irq_output *out) table = get_scols_table(input_file, out, ctl->prev_stat, &stat, ctl->softirq, ctl->threshold, ctl->setsize, - ctl->cpuset, NULL); + ctl->cpuset, ctl->filters); free(input_file); if (!table) { ctl->request_exit = 1; @@ -426,6 +428,19 @@ static void parse_args( struct irqtop_ctl *ctl, } } + if (optind < argc) { + int i; + int filters_len; + + filters_len = argc - optind + 1; + ctl->filters = (char **)xmalloc(filters_len * sizeof(void *)); + memset(ctl->filters, 0, filters_len * sizeof(void *)); + + for (i = optind; i < argc; i++) + ctl->filters[i - optind] = xstrdup(argv[i]); + ctl->filters[i - optind] = NULL; + } + /* default */ if (!out->ncolumns) { out->columns[out->ncolumns++] = COL_IRQ; @@ -452,7 +467,8 @@ int main(int argc, char **argv) struct irqtop_ctl ctl = { .timer.it_interval = {3, 0}, .timer.it_value = {3, 0}, - .iter = -1 + .iter = -1, + .filters = NULL }; setlocale(LC_ALL, ""); @@ -478,6 +494,15 @@ int main(int argc, char **argv) free_irqstat(ctl.prev_stat); free(ctl.hostname); cpuset_free(ctl.cpuset); + if (ctl.filters) { + char **saved = ctl.filters; + + while(*(ctl.filters)) { + free(*(ctl.filters)); + (ctl.filters)++; + } + free(saved); + } if (!ctl.batch) { if (is_tty) -- 2.43.5