]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop/lsirq: add additional desc for softirq
authorzhenwei pi <pizhenwei@bytedance.com>
Thu, 2 Jul 2020 12:24:20 +0000 (20:24 +0800)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Jul 2020 10:23:56 +0000 (12:23 +0200)
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>
sys-utils/irq-common.c
sys-utils/irqtop.c
sys-utils/lsirq.c

index 3ed793740a98e9804bef2f3568059f5fe7032b24..dac2e546ea36a4ecc2e9a82c34fd7fb7f87052e8 100644 (file)
@@ -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;
index 89c493e9831cfcab5f94b457d77e0907616c033e..71e877bd9fd1e4d24a3c0fb4e14a7502e68b8d4a 100644 (file)
@@ -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 [+]<list> to putput */
index 0c7bfd83b79bef10d5c3706b0169ef387d7aaf67..1a90efe21740c5e8c8421f6f510887cef0d3df8c 100644 (file)
@@ -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 [+]<list> to putput */