]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add MHZ column
authorKarel Zak <kzak@redhat.com>
Tue, 3 Nov 2020 09:27:46 +0000 (10:27 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Nov 2020 08:19:02 +0000 (09:19 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu.c

index c5620035d51df80f80c3466ab05eab21e59d7980..5fdcec7c83ffd4f4795f4054bbbb473f7d523255 100644 (file)
@@ -102,6 +102,7 @@ enum {
        COL_CPU_ADDRESS,
        COL_CPU_CONFIGURED,
        COL_CPU_ONLINE,
+       COL_CPU_MHZ,
        COL_CPU_MAXMHZ,
        COL_CPU_MINMHZ,
 };
@@ -144,6 +145,7 @@ static struct lscpu_coldesc coldescs_cpu[] =
        [COL_CPU_ADDRESS]      = { "ADDRESS", N_("physical address of a CPU") },
        [COL_CPU_CONFIGURED]   = { "CONFIGURED", N_("shows if the hypervisor has allocated the CPU") },
        [COL_CPU_ONLINE]       = { "ONLINE", N_("shows if Linux currently makes use of the CPU"), SCOLS_FL_RIGHT },
+       [COL_CPU_MHZ]          = { "MHZ", N_("shows the currently MHz of the CPU"), SCOLS_FL_RIGHT },
        [COL_CPU_MAXMHZ]       = { "MAXMHZ", N_("shows the maximum MHz of the CPU"), SCOLS_FL_RIGHT },
        [COL_CPU_MINMHZ]       = { "MINMHZ", N_("shows the minimum MHz of the CPU"), SCOLS_FL_RIGHT }
 };
@@ -405,6 +407,10 @@ static char *get_cell_data(
                        snprintf(buf, bufsz, "%s",
                                 is_cpu_online(cxt, cpu) ? _("yes") : _("no"));
                break;
+       case COL_CPU_MHZ:
+               if (cpu->mhz)
+                       xstrncpy(buf, cpu->mhz, bufsz);
+               break;
        case COL_CPU_MAXMHZ:
                if (cpu->mhz_max_freq)
                        snprintf(buf, bufsz, "%.4f", cpu->mhz_max_freq);