/* irqtop paths */
#define _PATH_PROC_INTERRUPTS "/proc/interrupts"
+#define _PATH_PROC_SOFTIRQS "/proc/softirqs"
#define _PATH_PROC_UPTIME "/proc/uptime"
/* kernel command line */
/*
* irqinfo - parse the system's interrupts
*/
-static struct irq_stat *get_irqinfo(void)
+static struct irq_stat *get_irqinfo(int softirq)
{
FILE *irqfile;
char *line = NULL, *tmp;
stat->irq_info = xmalloc(sizeof(*stat->irq_info) * IRQ_INFO_LEN);
stat->nr_irq_info = IRQ_INFO_LEN;
- irqfile = fopen(_PATH_PROC_INTERRUPTS, "r");
+ if (softirq)
+ irqfile = fopen(_PATH_PROC_SOFTIRQS, "r");
+ else
+ irqfile = fopen(_PATH_PROC_INTERRUPTS, "r");
if (!irqfile) {
warn(_("cannot open %s"), _PATH_PROC_INTERRUPTS);
goto free_stat;
struct libscols_table *get_scols_table(struct irq_output *out,
struct irq_stat *prev,
- struct irq_stat **xstat)
+ struct irq_stat **xstat,
+ int softirq)
{
struct libscols_table *table;
struct irq_info *result;
size_t i;
/* the stats */
- stat = get_irqinfo();
+ stat = get_irqinfo(softirq);
if (!stat)
return NULL;
struct libscols_table *get_scols_table(struct irq_output *out,
struct irq_stat *prev,
- struct irq_stat **xstat);
+ struct irq_stat **xstat,
+ int softirq);
#endif /* UTIL_LINUX_H_IRQ_COMMON */
struct irq_stat *prev_stat;
unsigned int request_exit:1;
+ unsigned int softirq:1;
};
/* user's input parser */
time_t now = time(NULL);
char timestr[64], *data;
- table = get_scols_table(out, ctl->prev_stat, &stat);
+ table = get_scols_table(out, ctl->prev_stat, &stat, ctl->softirq);
if (!table) {
ctl->request_exit = 1;
return 1;
fputs(_(" -d, --delay <secs> delay updates\n"), stdout);
fputs(_(" -o, --output <list> define which output columns to use\n"), stdout);
fputs(_(" -s, --sort <column> specify sort column\n"), stdout);
+ fputs(_(" -S, --softirq show softirqs instead of interrupts\n"), stdout);
fputs(USAGE_SEPARATOR, stdout);
printf(USAGE_HELP_OPTIONS(22));
{"delay", required_argument, NULL, 'd'},
{"sort", required_argument, NULL, 's'},
{"output", required_argument, NULL, 'o'},
+ {"softirq", no_argument, NULL, 'S'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
int o;
- while ((o = getopt_long(argc, argv, "d:o:s:hV", longopts, NULL)) != -1) {
+ while ((o = getopt_long(argc, argv, "d:o:s:ShV", longopts, NULL)) != -1) {
switch (o) {
case 'd':
{
case 'o':
outarg = optarg;
break;
+ case 'S':
+ ctl->softirq = 1;
+ break;
case 'V':
print_version(EXIT_SUCCESS);
case 'h':
out->columns[out->ncolumns++] = COL_IRQ;
out->columns[out->ncolumns++] = COL_TOTAL;
out->columns[out->ncolumns++] = COL_DELTA;
- out->columns[out->ncolumns++] = COL_NAME;
+ if (!ctl->softirq)
+ out->columns[out->ncolumns++] = COL_NAME;
}
/* add -o [+]<list> to putput */
#include "irq-common.h"
-static int print_irq_data(struct irq_output *out)
+static int print_irq_data(struct irq_output *out, int softirq)
{
struct libscols_table *table;
- table = get_scols_table(out, NULL, NULL);
+ table = get_scols_table(out, NULL, NULL, softirq);
if (!table)
return -1;
fputs(_(" -n, --noheadings don't print headings\n"), stdout);
fputs(_(" -o, --output <list> define which output columns to use\n"), stdout);
fputs(_(" -s, --sort <column> specify sort column\n"), stdout);
+ fputs(_(" -S, --softirq show softirqs instead of interrupts\n"), stdout);
fputs(USAGE_SEPARATOR, stdout);
printf(USAGE_HELP_OPTIONS(22));
{"sort", required_argument, NULL, 's'},
{"noheadings", no_argument, NULL, 'n'},
{"output", required_argument, NULL, 'o'},
+ {"softirq", no_argument, NULL, 'S'},
{"json", no_argument, NULL, 'J'},
{"pairs", no_argument, NULL, 'P'},
{"help", no_argument, NULL, 'h'},
{0}
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+ int softirq = 0;
setlocale(LC_ALL, "");
- while ((c = getopt_long(argc, argv, "no:s:hJPV", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "no:s:ShJPV", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
switch (c) {
case 's':
set_sort_func_by_name(&out, optarg);
break;
+ case 'S':
+ softirq = 1;
+ break;
case 'V':
print_version(EXIT_SUCCESS);
case 'h':
if (!out.ncolumns) {
out.columns[out.ncolumns++] = COL_IRQ;
out.columns[out.ncolumns++] = COL_TOTAL;
- out.columns[out.ncolumns++] = COL_NAME;
+ if (!softirq)
+ out.columns[out.ncolumns++] = COL_NAME;
}
/* add -o [+]<list> to putput */
irq_column_name_to_id) < 0)
exit(EXIT_FAILURE);
- return print_irq_data(&out) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+ return print_irq_data(&out, softirq) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}