]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add configured state to output
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Tue, 6 Sep 2011 00:52:58 +0000 (02:52 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 9 Sep 2011 21:41:25 +0000 (23:41 +0200)
CPUs may be in a configured or deconfigured state depending if the CPU resource
may be used by the guest.  If a CPU is in configured state the guest may use it
(i.e. set it online). It it is in deconfigured state it cannot use it before
changing its state to configured.  Display this CPU attribute as well.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
sys-utils/lscpu.1
sys-utils/lscpu.c

index 30dfbc61f3897c61b32eb7bc1097b5759e7a5fa7..b833bdc3b77acebb4cc703c3fb696ae96883e232 100644 (file)
@@ -21,7 +21,7 @@ which can be fed to other programs.
 
 Some options have a \fIlist\fP argument. The \fIlist\fP argument is a comma
 delimited list of the columns. Currently supported are CPU, Core, Node, Socket,
-Book, Cache, Polarization and Address columns.
+Book, Cache, Polarization, Address and Configured columns.
 If the \fIlist\fP argument is given then all requested columns are printed in
 the defined order.
 
index c142da736d7f28954b3b21b5bae47954c0673812..319412120db5929a5a442f6a7ec6d991c0064bc3 100644 (file)
@@ -174,6 +174,7 @@ struct lscpu_desc {
 
        int             *polarization;  /* cpu polarization */
        int             *addresses;     /* physical cpu addresses */
+       int             *configured;    /* cpu configured */
 };
 
 enum {
@@ -218,7 +219,8 @@ enum {
        COL_BOOK,
        COL_CACHE,
        COL_POLARIZATION,
-       COL_ADDRESS
+       COL_ADDRESS,
+       COL_CONFIGURED,
 };
 
 static const char *colnames[] =
@@ -230,7 +232,8 @@ static const char *colnames[] =
        [COL_BOOK] = "Book",
        [COL_CACHE] = "Cache",
        [COL_POLARIZATION] = "Polarization",
-       [COL_ADDRESS] = "Address"
+       [COL_ADDRESS] = "Address",
+       [COL_CONFIGURED] = "Configured",
 };
 
 
@@ -792,6 +795,16 @@ read_address(struct lscpu_desc *desc, int num)
        desc->addresses[num] = path_getnum(_PATH_SYS_CPU "/cpu%d/address", num);
 }
 
+static void
+read_configured(struct lscpu_desc *desc, int num)
+{
+       if (!path_exist(_PATH_SYS_CPU "/cpu%d/configure", num))
+               return;
+       if (!desc->configured)
+               desc->configured = xcalloc(desc->ncpus, sizeof(int));
+       desc->configured[num] = path_getnum(_PATH_SYS_CPU "/cpu%d/configure", num);
+}
+
 static int
 cachecmp(const void *a, const void *b)
 {
@@ -959,6 +972,11 @@ get_cell_data(struct lscpu_desc *desc, int cpu, int col,
                if (desc->addresses)
                        snprintf(buf, bufsz, "%d", desc->addresses[cpu]);
                break;
+       case COL_CONFIGURED:
+               if (desc->configured)
+                       snprintf(buf, bufsz,
+                                desc->configured[cpu] ? _("Y") : _("N"));
+               break;
        }
        return buf;
 }
@@ -1359,6 +1377,7 @@ int main(int argc, char *argv[])
                read_cache(desc, i);
                read_polarization(desc, i);
                read_address(desc, i);
+               read_configured(desc, i);
        }
 
        qsort(desc->caches, desc->ncaches, sizeof(struct cpu_cache), cachecmp);
@@ -1395,6 +1414,8 @@ int main(int argc, char *argv[])
                                columns[ncolumns++] = COL_CORE;
                        if (desc->caches)
                                columns[ncolumns++] = COL_CACHE;
+                       if (desc->configured)
+                               columns[ncolumns++] = COL_CONFIGURED;
                        if (desc->polarization)
                                columns[ncolumns++] = COL_POLARIZATION;
                        if (desc->addresses)