From: zhenwei pi Date: Thu, 2 Jul 2020 12:24:20 +0000 (+0800) Subject: irqtop/lsirq: add additional desc for softirq X-Git-Tag: v2.37-rc1~554 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2a49bc243ce09e394adb2bb4ea9d04a5d6f7f68;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c index 3ed793740a..dac2e546ea 100644 --- a/sys-utils/irq-common.c +++ b/sys-utils/irq-common.c @@ -56,6 +56,38 @@ static const struct colinfo infos[] = { [COL_NAME] = {"NAME", 0.70, SCOLS_FL_TRUNC, N_("name"), SCOLS_JSON_STRING}, }; +/* make softirq friendly to end-user */ +struct softirq_desc { + char *irq; + char *desc; +} softirq_descs[] = { + { .irq = "HI", .desc = "high priority tasklet softirq" }, + { .irq = "TIMER", .desc = "timer softirq" }, + { .irq = "NET_TX", .desc = "network transmit softirq", }, + { .irq = "NET_RX", .desc = "network receive softirq" }, + { .irq = "BLOCK", .desc = "block device softirq" }, + { .irq = "IRQ_POLL", .desc = "IO poll softirq" }, + { .irq = "TASKLET", .desc = "normal priority tasklet softirq" }, + { .irq = "SCHED", .desc = "schedule softirq" }, + { .irq = "HRTIMER", .desc = "high resolution timer softirq" }, + { .irq = "RCU", .desc = "RCU softirq" }, +}; + +static void get_softirq_desc(struct irq_info *curr) +{ + int i, size = ARRAY_SIZE(softirq_descs); + + for (i = 0; i < size; i++) { + if (!strcmp(curr->irq, softirq_descs[i].irq)) + break; + } + + if (i < size) + curr->name = xstrdup(softirq_descs[i].desc); + else + curr->name = xstrdup(""); +} + int irq_column_name_to_id(const char *name, size_t namesz) { size_t i; @@ -255,15 +287,20 @@ static struct irq_stat *get_irqinfo(int softirq) tmp += 11; } - if (tmp - line < length) { - /* strip all space before desc */ - while (isspace(*tmp)) - tmp++; - tmp = remove_repeated_spaces(tmp); - rtrim_whitespace((unsigned char *)tmp); - curr->name = xstrdup(tmp); - } else /* no irq name string, we have to set '\0' here */ - curr->name = xstrdup(""); + /* softirq always has no desc, add additional desc for softirq */ + if (softirq) + get_softirq_desc(curr); + else { + if (tmp - line < length) { + /* strip all space before desc */ + while (isspace(*tmp)) + tmp++; + tmp = remove_repeated_spaces(tmp); + rtrim_whitespace((unsigned char *)tmp); + curr->name = xstrdup(tmp); + } else /* no irq name string, we have to set '\0' here */ + curr->name = xstrdup(""); + } if (stat->nr_irq == stat->nr_irq_info) { stat->nr_irq_info *= 2; diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index 89c493e983..71e877bd9f 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -294,8 +294,7 @@ static void parse_args( struct irqtop_ctl *ctl, out->columns[out->ncolumns++] = COL_IRQ; out->columns[out->ncolumns++] = COL_TOTAL; out->columns[out->ncolumns++] = COL_DELTA; - if (!ctl->softirq) - out->columns[out->ncolumns++] = COL_NAME; + out->columns[out->ncolumns++] = COL_NAME; } /* add -o [+] to putput */ diff --git a/sys-utils/lsirq.c b/sys-utils/lsirq.c index 0c7bfd83b7..1a90efe217 100644 --- a/sys-utils/lsirq.c +++ b/sys-utils/lsirq.c @@ -138,8 +138,7 @@ int main(int argc, char **argv) if (!out.ncolumns) { out.columns[out.ncolumns++] = COL_IRQ; out.columns[out.ncolumns++] = COL_TOTAL; - if (!softirq) - out.columns[out.ncolumns++] = COL_NAME; + out.columns[out.ncolumns++] = COL_NAME; } /* add -o [+] to putput */