* [PATCH 00/11] various lscpu changes
@ 2011-09-06 0:52 Heiko Carstens
2011-09-06 0:52 ` [PATCH 01/11] [PATCH] lscpu: remove comma operator Heiko Carstens
` (11 more replies)
0 siblings, 12 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Hi Karel,
another set of patches against lscpu. Since you didn't have chance to push
out your local tree to kernel.org yet, I simply based them on my old lscpu
branch which you applied on your local tree:
git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux.git lscpu
So, in theory there shouldn't be any merge conflicts ;)
Also, due to master.kernel.org being down I didn't set up a new git branch.
Anyway, the most notable change/addition is the new "-e|--extended" option
which prints a human readable extended cpu table:
CPU BOOK SOCKET CORE ONLINE CONFIGURED POLARIZATION ADDRESS
0 0 0 0 yes yes vert-medium 0
1 0 0 1 yes yes vert-low 1
2 0 0 2 yes yes vert-low 2
3 0 1 3 yes yes vert-low 3
4 0 1 4 yes yes vert-low 4
5 0 1 5 yes yes vert-low 5
6 1 2 6 yes yes vert-low 6
7 1 2 - no yes vert-low 7
8 1 2 - no yes vert-low 8
9 - - - no no - 9
10 - - - no no - 10
11 1 3 7 yes yes vert-low 11
12 1 3 8 yes yes vert-low 12
13 1 3 9 yes yes vert-low 13
14 1 3 10 yes yes vert-low 14
15 1 4 11 yes yes vert-low 15
16 1 5 12 yes yes vert-low 16
17 1 5 13 yes yes vert-low 17
18 1 5 14 yes yes vert-low 18
19 1 6 15 yes yes vert-low 19
Hopefully the patches don't look too bad. :)
Thanks,
Heiko
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/11] [PATCH] lscpu: remove comma operator
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 02/11] [PATCH] lscpu: fix cache output for extended parsable output Heiko Carstens
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Fix typo where the comma operator has been introduced.
Use a semicolon instead so we end up with simple assignment expressions.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index fb65d8e..3733cab 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1218,8 +1218,8 @@ int main(int argc, char *argv[])
} else {
columns[ncolumns++] = COL_CPU;
columns[ncolumns++] = COL_CORE;
- columns[ncolumns++] = COL_SOCKET,
- columns[ncolumns++] = COL_NODE,
+ columns[ncolumns++] = COL_SOCKET;
+ columns[ncolumns++] = COL_NODE;
columns[ncolumns++] = COL_CACHE;
compatible = 1;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/11] [PATCH] lscpu: fix cache output for extended parsable output
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
2011-09-06 0:52 ` [PATCH 01/11] [PATCH] lscpu: remove comma operator Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 03/11] [PATCH] lscpu: simplify cache column output function Heiko Carstens
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
The extended parsable output prints a colon instead of comma between each
item. The case where a CPU doesn't belong to any cache was not converted.
Just fix this.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 3733cab..45b644b 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -922,7 +922,7 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
}
}
if (x == ca->nsharedmaps)
- putchar(',');
+ putchar(compatible ? ',' : ':');
}
break;
case COL_POLARIZATION:
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/11] [PATCH] lscpu: simplify cache column output function
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
2011-09-06 0:52 ` [PATCH 01/11] [PATCH] lscpu: remove comma operator Heiko Carstens
2011-09-06 0:52 ` [PATCH 02/11] [PATCH] lscpu: fix cache output for extended parsable output Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 04/11] [PATCH] lscpu: allow read_cache() to be called for offline cpus Heiko Carstens
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Simplify the logic to "always print a ',' for each cache except if
it is the last one.
This is also a preparation patch for printing the cache column for
offline CPUs where it would print one colon too much because of the
current logic.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 45b644b..49b6f2b 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -915,13 +915,11 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
for (x = 0; x < ca->nsharedmaps; x++) {
if (CPU_ISSET_S(i, setsize, ca->sharedmaps[x])) {
- if (j != desc->ncaches - 1)
- putchar(compatible ? ',' : ':');
printf("%d", x);
break;
}
}
- if (x == ca->nsharedmaps)
+ if (j != 0)
putchar(compatible ? ',' : ':');
}
break;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/11] [PATCH] lscpu: allow read_cache() to be called for offline cpus
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (2 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 03/11] [PATCH] lscpu: simplify cache column output function Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 05/11] [PATCH] lscpu: add --version option Heiko Carstens
` (7 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
First check path before accessing files to be sure they actually
exist. This is necessary when also informations for offline CPUs
will be printed.
Since we do not necessarily know if "cpu is offline" means the same
as "path does not exist" just check for it.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 49b6f2b..d7c7028 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -804,6 +804,9 @@ read_cache(struct lscpu_desc *desc, int num)
struct cpu_cache *ca = &desc->caches[i];
cpu_set_t *map;
+ if (!path_exist(_PATH_SYS_SYSTEM "/cpu/cpu%d/cache/index%d",
+ num, i))
+ continue;
if (!ca->name) {
int type, level;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/11] [PATCH] lscpu: add --version option
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (3 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 04/11] [PATCH] lscpu: allow read_cache() to be called for offline cpus Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 06/11] [PATCH] lscpu: add human readable extended cpu table output Heiko Carstens
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Add a --version option like most other tools have it.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.1 | 5 ++++-
sys-utils/lscpu.c | 10 ++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index 6840590..2dc31b7 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -6,7 +6,7 @@
lscpu \- CPU architecture information helper
.SH SYNOPSIS
.B lscpu
-.RB [ \-hpx ]
+.RB [ \-hpxV ]
.RB [ \-s
.IR directory ]
.SH DESCRIPTION
@@ -47,6 +47,9 @@ a snapshot from a different system.
.BR \-x , " \-\-hex"
Use hexadecimal masks for CPU sets (e.g. 0x3). The default is to print the sets
in list format (e.g. 0,1).
+.TP
+.BR \-V , " \-\-version"
+Output version information and exit.
.SH BUGS
The basic overview about CPU family, model, etc. is always based on the first
CPU only.
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index d7c7028..841beae 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1178,7 +1178,8 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
" -h, --help print this help\n"
" -p, --parse[=LIST] print out a parsable instead of a readable format\n"
" -s, --sysroot DIR use directory DIR as system root\n"
- " -x, --hex print hexadecimal masks rather than lists of CPUs\n"));
+ " -x, --hex print hexadecimal masks rather than lists of CPUs\n"
+ " -V, --version output version information and exit\n"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -1195,6 +1196,7 @@ int main(int argc, char *argv[])
{ "parse", optional_argument, 0, 'p' },
{ "sysroot", required_argument, 0, 's' },
{ "hex", no_argument, 0, 'x' },
+ { "version", no_argument, 0, 'V' },
{ NULL, 0, 0, 0 }
};
@@ -1202,7 +1204,7 @@ int main(int argc, char *argv[])
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long(argc, argv, "hp::s:x", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hp::s:xV", longopts, NULL)) != -1) {
switch (c) {
case 'h':
usage(stdout);
@@ -1233,6 +1235,10 @@ int main(int argc, char *argv[])
case 'x':
hex = 1;
break;
+ case 'V':
+ printf(_("%s from %s\n"), program_invocation_short_name,
+ PACKAGE_STRING);
+ return EXIT_SUCCESS;
default:
usage(stderr);
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/11] [PATCH] lscpu: add human readable extended cpu table output
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (4 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 05/11] [PATCH] lscpu: add --version option Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 07/11] [PATCH] lscpu: add configured state to output Heiko Carstens
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
lscpu currently only supports a parsable output which contains a row for
each cpu and its attributes. This output contains only comas as separators
and is hard to read for humans.
Therefore add a new option "-e | --extended" which outputs the rows in a
much more readable (and non-parsable) form. Just like for the -p option a
list of columns can be specified that shall be included in the output.
By default this option will print all columns that contain data.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/Makefile.am | 5 +-
sys-utils/lscpu.1 | 29 +++++--
sys-utils/lscpu.c | 239 +++++++++++++++++++++++++++++++++++++------------
3 files changed, 206 insertions(+), 67 deletions(-)
diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am
index feb5888..ce50702 100644
--- a/sys-utils/Makefile.am
+++ b/sys-utils/Makefile.am
@@ -19,7 +19,10 @@ dist_man_MANS += dmesg.1 ctrlaltdel.8 cytune.8 setarch.8 \
if HAVE_CPU_SET_T
usrbin_exec_PROGRAMS += lscpu
-lscpu_SOURCES = lscpu.c $(top_srcdir)/lib/cpuset.c $(top_srcdir)/lib/strutils.c
+lscpu_SOURCES = lscpu.c $(top_srcdir)/lib/cpuset.c \
+ $(top_srcdir)/lib/strutils.c \
+ $(top_srcdir)/lib/mbsalign.c \
+ $(top_srcdir)/lib/tt.c
dist_man_MANS += lscpu.1
endif
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index 2dc31b7..db7fe72 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -6,7 +6,7 @@
lscpu \- CPU architecture information helper
.SH SYNOPSIS
.B lscpu
-.RB [ \-hpxV ]
+.RB [ \-ehpxV ]
.RB [ \-s
.IR directory ]
.SH DESCRIPTION
@@ -18,24 +18,37 @@ a human-readable format. It supports both online and offline CPUs.
It can also print out in a parsable format,
including how different caches are shared by different CPUs,
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.
+If the \fIlist\fP argument is given then all requested columns are printed in
+the defined order.
+
.SH OPTIONS
.TP
+.TP
+.BR \-e , " \-\-extended " \fI[=list]\fP
+Print CPU list out in human-readable format.
+
+If the \fIlist\fP argument is not given then all columns where data is
+available will be printed.
+
+Note that the optional \fIlist\fP argument cannot be separated from the
+option by a space, the correct form is for example '\fB-e=cpu,node\fP' or '\fB--extended=cpu,node\fP'.
+.TP
.BR \-h , " \-\-help"
Print a help message.
.TP
.BR \-p , " \-\-parse " \fI[=list]\fP
-Print out in parsable instead of human-readable format.
+Print out in parsable format.
If the \fIlist\fP argument is not given then the default backwardly compatible
output is printed. The backwardly compatible format uses two commas to
separate CPU cache columns. If no CPU caches are identified, then the cache
columns are not printed at all.
-
-The \fIlist\fP argument is comma delimited list of the columns. Currently
-supported are CPU, Core, Node, Socket, Book, Cache, Polarization and Address
-columns.
-If the \fIlist\fP argument is given then always all requested columns are printed in
-the defined order. The Cache columns are separated by ':'.
+.br
+If the \fIlist\fP argument is given then the cache columns are separated by ':'.
Note that the optional \fIlist\fP argument cannot be separated from the
option by a space, the correct form is for example '\fB-p=cpu,node\fP' or '\fB--parse=cpu,node\fP'.
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 841beae..bb0201b 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -39,6 +39,7 @@
#include "c.h"
#include "strutils.h"
#include "bitops.h"
+#include "tt.h"
#define CACHE_MAX 100
@@ -117,12 +118,17 @@ enum {
POLAR_HORIZONTAL
};
-const char *polar_modes[] = {
- [POLAR_UNKNOWN] = "U",
- [POLAR_VLOW] = "VL",
- [POLAR_VMEDIUM] = "VM",
- [POLAR_VHIGH] = "VH",
- [POLAR_HORIZONTAL] = "H"
+struct polarization_modes {
+ char *parsable;
+ char *readable;
+};
+
+struct polarization_modes pmodes[] = {
+ [POLAR_UNKNOWN] = {"U", "-"},
+ [POLAR_VLOW] = {"VL", "vert-low"},
+ [POLAR_VMEDIUM] = {"VM", "vert-medium"},
+ [POLAR_VHIGH] = {"VH", "vert-high"},
+ [POLAR_HORIZONTAL] = {"H", "horizontal"},
};
/* global description */
@@ -171,6 +177,12 @@ struct lscpu_desc {
int *addresses; /* physical cpu addresses */
};
+struct lscpu_modifier {
+ int compat;
+ int formatted;
+ int hex;
+};
+
static size_t sysrootlen;
static char pathbuf[PATH_MAX];
static int maxcpus; /* size in bits of kernel cpu mask */
@@ -869,20 +881,45 @@ read_nodes(struct lscpu_desc *desc)
i);
}
+/* asprintf version which appends the result to the given string */
static void
-print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
+asprintfc(char **str, const char *fmt, ...)
+{
+ char *buffer, *new;
+ va_list ap;
+ int rc;
+
+ va_start(ap, fmt);
+ rc = vasprintf(&new, fmt, ap);
+ va_end(ap);
+ if (rc < 0)
+ goto error;
+ rc = asprintf(&buffer, "%s%s", *str, new);
+ free(new);
+ if (rc < 0)
+ goto error;
+ *str = buffer;
+ return;
+error:
+ errx(EXIT_FAILURE, _("failed to allocate memory"));
+}
+
+static void
+print_cell(struct lscpu_desc *desc, int i, int col, int c,
+ struct lscpu_modifier *mod, struct tt_line *line)
{
- int j;
size_t setsize = CPU_ALLOC_SIZE(maxcpus);
+ char *buffer = "\0";
+ int j;
switch (col) {
case COL_CPU:
- printf("%d", i);
+ asprintfc(&buffer, "%d", i);
break;
case COL_CORE:
for (j = 0; j < desc->ncores; j++) {
if (CPU_ISSET_S(i, setsize, desc->coremaps[j])) {
- printf("%d", j);
+ asprintfc(&buffer, "%d", j);
break;
}
}
@@ -890,7 +927,7 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
case COL_SOCKET:
for (j = 0; j < desc->nsockets; j++) {
if (CPU_ISSET_S(i, setsize, desc->socketmaps[j])) {
- printf("%d", j);
+ asprintfc(&buffer, "%d", j);
break;
}
}
@@ -898,7 +935,7 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
case COL_NODE:
for (j = 0; j < desc->nnodes; j++) {
if (CPU_ISSET_S(i, setsize, desc->nodemaps[j])) {
- printf("%d", j);
+ asprintfc(&buffer, "%d", j);
break;
}
}
@@ -906,7 +943,7 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
case COL_BOOK:
for (j = 0; j < desc->nbooks; j++) {
if (CPU_ISSET_S(i, setsize, desc->bookmaps[j])) {
- printf("%d", j);
+ asprintfc(&buffer, "%d", j);
break;
}
}
@@ -918,27 +955,44 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
for (x = 0; x < ca->nsharedmaps; x++) {
if (CPU_ISSET_S(i, setsize, ca->sharedmaps[x])) {
- printf("%d", x);
+ asprintfc(&buffer, "%d", x);
break;
}
}
+ if (x == ca->nsharedmaps && mod->formatted)
+ asprintfc(&buffer, "-");
if (j != 0)
- putchar(compatible ? ',' : ':');
+ asprintfc(&buffer, mod->compat ? "," : ":");
}
break;
case COL_POLARIZATION:
- if (desc->polarization)
- printf("%s", polar_modes[desc->polarization[i]]);
+ if (!desc->polarization)
+ break;
+ if (mod->formatted)
+ asprintfc(&buffer, pmodes[desc->polarization[i]].readable);
+ else
+ asprintfc(&buffer, pmodes[desc->polarization[i]].parsable);
break;
case COL_ADDRESS:
if (desc->addresses)
- printf("%d", desc->addresses[i]);
+ asprintfc(&buffer, "%d", desc->addresses[i]);
break;
}
+ if (mod->formatted) {
+ if (strlen(buffer) == 0)
+ buffer = "-";
+ tt_line_set_data(line, c, buffer);
+ } else
+ printf(buffer);
}
+#define printf_cond(condition, ...) do { \
+ if (condition) \
+ printf(__VA_ARGS__); \
+} while (0)
+
/*
- * We support two formats:
+ * We support three formats:
*
* 1) "compatible" -- this format is compatible with the original lscpu(1)
* output and it contains fixed set of the columns. The CACHE columns are at
@@ -959,57 +1013,85 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible)
* # CPU,Core,Socket,Node,L1d:L1i:L2
* 0,0,0,0,0:0:0
* 1,1,0,0,1:1:0
+ *
+ * 3) "user defined formatted" -- this format is the same as "user defined
+ * output" except that each column is separated by spaces and has a fixed size
+ * over all rows.
+ *
+ * $ lscpu --extended=CPU,CORE,SOCKET
+ * CPU CORE SOCKET
+ * 0 0 0
+ * 1 1 0
*/
static void
-print_parsable(struct lscpu_desc *desc, int cols[], int ncols, int compatible)
+print_table(struct lscpu_desc *desc, int cols[], int ncols, struct lscpu_modifier *mod)
{
+ struct tt *tt;
+ int count = 0;
int i, c;
- printf(_(
- "# The following is the parsable format, which can be fed to other\n"
- "# programs. Each different item in every column has an unique ID\n"
- "# starting from zero.\n"));
+ if (!mod->formatted) {
+ printf(_("# The following is the parsable format, which can be fed to other\n"
+ "# programs. Each different item in every column has an unique ID\n"
+ "# starting from zero.\n"));
+ fputs("# ", stdout);
+ } else {
+ tt = tt_new_table(0);
+ }
- fputs("# ", stdout);
for (i = 0; i < ncols; i++) {
+ char *buffer = "\0";
+
if (cols[i] == COL_CACHE) {
- if (compatible && !desc->ncaches)
+ if (mod->compat && !desc->ncaches)
continue;
- if (i > 0)
- putchar(',');
- if (compatible && i != 0)
- putchar(',');
+ if (mod->compat && i != 0)
+ asprintfc(&buffer, ",");
for (c = desc->ncaches - 1; c >= 0; c--) {
- printf("%s", desc->caches[c].name);
+ asprintfc(&buffer, desc->caches[c].name);
if (c > 0)
- putchar(compatible ? ',' : ':');
+ asprintfc(&buffer, mod->compat ? "," : ":");
}
if (!desc->ncaches)
- fputs(colnames[cols[i]], stdout);
+ asprintfc(&buffer, colnames[cols[i]]);
+ } else {
+ asprintfc(&buffer, colnames[cols[i]]);
+ }
+ if (mod->formatted) {
+ char *c = buffer;
+
+ while (*c != '\0')
+ *c++ = toupper(*c);
+ tt_define_column(tt, buffer, 0, 0);
} else {
if (i > 0)
putchar(',');
- fputs(colnames[cols[i]], stdout);
+ printf(buffer);
}
}
- putchar('\n');
-
+ printf_cond(!mod->formatted, "\n");
for (i = 0; i < desc->ncpus; i++) {
+ struct tt_line *line;
+
if (desc->online && !is_cpu_online(desc, i))
continue;
+ if (mod->formatted)
+ line = tt_add_line(tt, NULL);
for (c = 0; c < ncols; c++) {
- if (compatible && cols[c] == COL_CACHE) {
+ if (mod->compat && cols[c] == COL_CACHE) {
if (!desc->ncaches)
continue;
if (c > 0)
- putchar(',');
+ printf_cond(!mod->formatted, ",");
}
if (c > 0)
- putchar(',');
- print_parsable_cell(desc, i, cols[c], compatible);
+ printf_cond(!mod->formatted, ",");
+ print_cell(desc, i, cols[c], c, mod, line);
}
- putchar('\n');
+ printf_cond(!mod->formatted, "\n");
}
+ if (mod->formatted)
+ tt_print_table(tt);
}
@@ -1035,7 +1117,7 @@ print_cpuset(const char *key, cpu_set_t *set, int hex)
}
static void
-print_readable(struct lscpu_desc *desc, int hex)
+print_readable(struct lscpu_desc *desc, struct lscpu_modifier *mod)
{
char buf[512];
int i;
@@ -1065,9 +1147,9 @@ print_readable(struct lscpu_desc *desc, int hex)
print_n(_("CPU(s):"), desc->ncpus);
if (desc->online)
- print_cpuset(hex ? _("On-line CPU(s) mask:") :
- _("On-line CPU(s) list:"),
- desc->online, hex);
+ print_cpuset(mod->hex ? _("On-line CPU(s) mask:") :
+ _("On-line CPU(s) list:"),
+ desc->online, mod->hex);
if (desc->online && CPU_COUNT_S(setsize, desc->online) != desc->ncpus) {
cpu_set_t *set;
@@ -1084,9 +1166,9 @@ print_readable(struct lscpu_desc *desc, int hex)
if (!is_cpu_online(desc, i))
CPU_SET_S(i, setsize, set);
}
- print_cpuset(hex ? _("Off-line CPU(s) mask:") :
- _("Off-line CPU(s) list:"),
- set, hex);
+ print_cpuset(mod->hex ? _("Off-line CPU(s) mask:") :
+ _("Off-line CPU(s) list:"),
+ set, mod->hex);
cpuset_free(set);
}
@@ -1164,7 +1246,7 @@ print_readable(struct lscpu_desc *desc, int hex)
for (i = 0; i < desc->nnodes; i++) {
snprintf(buf, sizeof(buf), _("NUMA node%d CPU(s):"), i);
- print_cpuset(buf, desc->nodemaps[i], hex);
+ print_cpuset(buf, desc->nodemaps[i], mod->hex);
}
}
@@ -1177,6 +1259,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
puts(_( "\nOptions:\n"
" -h, --help print this help\n"
" -p, --parse[=LIST] print out a parsable instead of a readable format\n"
+ " -e, --table[=LIST] print out a readable format\n"
" -s, --sysroot DIR use directory DIR as system root\n"
" -x, --hex print hexadecimal masks rather than lists of CPUs\n"
" -V, --version output version information and exit\n"));
@@ -1186,12 +1269,14 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
int main(int argc, char *argv[])
{
+ struct lscpu_modifier _mod, *mod = &_mod;
struct lscpu_desc _desc, *desc = &_desc;
- int parsable = 0, c, i, hex = 0;
+ int c, i;
int columns[ARRAY_SIZE(colnames)], ncolumns = 0;
- int compatible = 0;
+ int print_cpu_table = 0;
static const struct option longopts[] = {
+ { "extended", optional_argument, 0, 'e' },
{ "help", no_argument, 0, 'h' },
{ "parse", optional_argument, 0, 'p' },
{ "sysroot", required_argument, 0, 's' },
@@ -1204,12 +1289,30 @@ int main(int argc, char *argv[])
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long(argc, argv, "hp::s:xV", longopts, NULL)) != -1) {
+ memset(mod, 0, sizeof(*mod));
+ while ((c = getopt_long(argc, argv, "e::hp::s:xV", longopts, NULL)) != -1) {
+ if (print_cpu_table && strchr("ep", c))
+ errx(EXIT_FAILURE,
+ _("extended and parsable are mutually exclusive"));
switch (c) {
case 'h':
usage(stdout);
+ case 'e':
+ print_cpu_table = 1;
+ mod->formatted = 1;
+ ncolumns = -1;
+ if (optarg) {
+ if (*optarg == '=')
+ optarg++;
+ ncolumns = string_to_idarray(optarg,
+ columns, ARRAY_SIZE(columns),
+ column_name_to_id);
+ if (ncolumns < 0)
+ return EXIT_FAILURE;
+ }
+ break;
case 'p':
- parsable = 1;
+ print_cpu_table = 1;
if (optarg) {
if (*optarg == '=')
optarg++;
@@ -1224,7 +1327,7 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_SOCKET;
columns[ncolumns++] = COL_NODE;
columns[ncolumns++] = COL_CACHE;
- compatible = 1;
+ mod->compat = 1;
}
break;
case 's':
@@ -1233,7 +1336,7 @@ int main(int argc, char *argv[])
pathbuf[sizeof(pathbuf) - 1] = '\0';
break;
case 'x':
- hex = 1;
+ mod->hex = 1;
break;
case 'V':
printf(_("%s from %s\n"), program_invocation_short_name,
@@ -1263,11 +1366,31 @@ int main(int argc, char *argv[])
read_hypervisor(desc);
+ if (print_cpu_table && ncolumns == -1) {
+ /* No list was given. Just print whatever is there. */
+ ncolumns = 0;
+ columns[ncolumns++] = COL_CPU;
+ if (desc->nodemaps)
+ columns[ncolumns++] = COL_NODE;
+ if (desc->bookmaps)
+ columns[ncolumns++] = COL_BOOK;
+ if (desc->socketmaps)
+ columns[ncolumns++] = COL_SOCKET;
+ if (desc->coremaps)
+ columns[ncolumns++] = COL_CORE;
+ if (desc->caches)
+ columns[ncolumns++] = COL_CACHE;
+ if (desc->polarization)
+ columns[ncolumns++] = COL_POLARIZATION;
+ if (desc->addresses)
+ columns[ncolumns++] = COL_ADDRESS;
+ }
+
/* Show time! */
- if (parsable)
- print_parsable(desc, columns, ncolumns, compatible);
+ if (print_cpu_table)
+ print_table(desc, columns, ncolumns, mod);
else
- print_readable(desc, hex);
+ print_readable(desc, mod);
return EXIT_SUCCESS;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/11] [PATCH] lscpu: add configured state to output
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (5 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 06/11] [PATCH] lscpu: add human readable extended cpu table output Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:52 ` [PATCH 08/11] [PATCH] lscpu: add online " Heiko Carstens
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
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 | 2 +-
sys-utils/lscpu.c | 28 ++++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index db7fe72..6c18e2f 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -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.
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index bb0201b..efa5b84 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -175,6 +175,7 @@ struct lscpu_desc {
int *polarization; /* cpu polarization */
int *addresses; /* physical cpu addresses */
+ int *configured; /* cpu configured */
};
struct lscpu_modifier {
@@ -213,7 +214,8 @@ enum {
COL_BOOK,
COL_CACHE,
COL_POLARIZATION,
- COL_ADDRESS
+ COL_ADDRESS,
+ COL_CONFIGURED,
};
static const char *colnames[] =
@@ -225,7 +227,8 @@ static const char *colnames[] =
[COL_BOOK] = "Book",
[COL_CACHE] = "Cache",
[COL_POLARIZATION] = "Polarization",
- [COL_ADDRESS] = "Address"
+ [COL_ADDRESS] = "Address",
+ [COL_CONFIGURED] = "Configured",
};
@@ -787,6 +790,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)
{
@@ -977,6 +990,14 @@ print_cell(struct lscpu_desc *desc, int i, int col, int c,
if (desc->addresses)
asprintfc(&buffer, "%d", desc->addresses[i]);
break;
+ case COL_CONFIGURED:
+ if (!desc->configured)
+ break;
+ if (mod->formatted)
+ asprintfc(&buffer, desc->configured[i] ? "yes" : "no");
+ else
+ asprintfc(&buffer, "%d", desc->configured[i]);
+ break;
}
if (mod->formatted) {
if (strlen(buffer) == 0)
@@ -1358,6 +1379,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);
@@ -1380,6 +1402,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)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/11] [PATCH] lscpu: add online state to output
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (6 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 07/11] [PATCH] lscpu: add configured state to output Heiko Carstens
@ 2011-09-06 0:52 ` Heiko Carstens
2011-09-06 0:53 ` [PATCH 09/11] [PATCH] lscpu: add --all option Heiko Carstens
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:52 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
lscpu only prints lines for online CPUs. At least for the human readable
list the offline CPUs are of interest as well. In order to distinguish
between online and offline CPUs introduce the "Online" column.
By default the human readable output now displays online and offline CPUs.
The parsable output is not changed. It will print only lines for online
CPUs as it used to do.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.1 | 2 +-
sys-utils/lscpu.c | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index 6c18e2f..3bf341b 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -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, Address and Configured columns.
+Book, Cache, Polarization, Address, Configured and Online columns.
If the \fIlist\fP argument is given then all requested columns are printed in
the defined order.
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index efa5b84..2e45b05 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -182,6 +182,7 @@ struct lscpu_modifier {
int compat;
int formatted;
int hex;
+ int allcpus;
};
static size_t sysrootlen;
@@ -216,6 +217,7 @@ enum {
COL_POLARIZATION,
COL_ADDRESS,
COL_CONFIGURED,
+ COL_ONLINE,
};
static const char *colnames[] =
@@ -229,6 +231,7 @@ static const char *colnames[] =
[COL_POLARIZATION] = "Polarization",
[COL_ADDRESS] = "Address",
[COL_CONFIGURED] = "Configured",
+ [COL_ONLINE] = "Online",
};
@@ -998,6 +1001,14 @@ print_cell(struct lscpu_desc *desc, int i, int col, int c,
else
asprintfc(&buffer, "%d", desc->configured[i]);
break;
+ case COL_ONLINE:
+ if (!desc->online)
+ break;
+ if (mod->formatted)
+ asprintfc(&buffer, is_cpu_online(desc, i) ? "yes" : "no");
+ else
+ asprintfc(&buffer, "%d", !!is_cpu_online(desc, i));
+ break;
}
if (mod->formatted) {
if (strlen(buffer) == 0)
@@ -1094,7 +1105,7 @@ print_table(struct lscpu_desc *desc, int cols[], int ncols, struct lscpu_modifie
for (i = 0; i < desc->ncpus; i++) {
struct tt_line *line;
- if (desc->online && !is_cpu_online(desc, i))
+ if (!mod->allcpus && desc->online && !is_cpu_online(desc, i))
continue;
if (mod->formatted)
line = tt_add_line(tt, NULL);
@@ -1321,6 +1332,7 @@ int main(int argc, char *argv[])
case 'e':
print_cpu_table = 1;
mod->formatted = 1;
+ mod->allcpus = 1;
ncolumns = -1;
if (optarg) {
if (*optarg == '=')
@@ -1373,7 +1385,7 @@ int main(int argc, char *argv[])
read_basicinfo(desc);
for (i = 0; i < desc->ncpus; i++) {
- if (desc->online && !is_cpu_online(desc, i))
+ if (!mod->allcpus && desc->online && !is_cpu_online(desc, i))
continue;
read_topology(desc, i);
read_cache(desc, i);
@@ -1402,6 +1414,8 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_CORE;
if (desc->caches)
columns[ncolumns++] = COL_CACHE;
+ if (desc->online)
+ columns[ncolumns++] = COL_ONLINE;
if (desc->configured)
columns[ncolumns++] = COL_CONFIGURED;
if (desc->polarization)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/11] [PATCH] lscpu: add --all option
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (7 preceding siblings ...)
2011-09-06 0:52 ` [PATCH 08/11] [PATCH] lscpu: add online " Heiko Carstens
@ 2011-09-06 0:53 ` Heiko Carstens
2011-09-06 0:53 ` [PATCH 10/11] [PATCH] lscpu: add s390 test case Heiko Carstens
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:53 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
The parsable output includes only lines of online CPUs. To also include
lines for all offline CPUs the "--all" option can be specified.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.1 | 4 +++-
sys-utils/lscpu.c | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index 3bf341b..7242a6b 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -6,7 +6,7 @@
lscpu \- CPU architecture information helper
.SH SYNOPSIS
.B lscpu
-.RB [ \-ehpxV ]
+.RB [ \-aehpxV ]
.RB [ \-s
.IR directory ]
.SH DESCRIPTION
@@ -27,6 +27,8 @@ the defined order.
.SH OPTIONS
.TP
+.BR \-a , " \-\-all"
+Include online and offline CPUs in output.
.TP
.BR \-e , " \-\-extended " \fI[=list]\fP
Print CPU list out in human-readable format.
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 2e45b05..7923cc2 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1293,6 +1293,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
" -p, --parse[=LIST] print out a parsable instead of a readable format\n"
" -e, --table[=LIST] print out a readable format\n"
" -s, --sysroot DIR use directory DIR as system root\n"
+ " -a, --all print online and offline CPUs\n"
" -x, --hex print hexadecimal masks rather than lists of CPUs\n"
" -V, --version output version information and exit\n"));
@@ -1308,6 +1309,7 @@ int main(int argc, char *argv[])
int print_cpu_table = 0;
static const struct option longopts[] = {
+ { "all", no_argument, 0, 'a' },
{ "extended", optional_argument, 0, 'e' },
{ "help", no_argument, 0, 'h' },
{ "parse", optional_argument, 0, 'p' },
@@ -1322,11 +1324,14 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
memset(mod, 0, sizeof(*mod));
- while ((c = getopt_long(argc, argv, "e::hp::s:xV", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "ae::hp::s:xV", longopts, NULL)) != -1) {
if (print_cpu_table && strchr("ep", c))
errx(EXIT_FAILURE,
_("extended and parsable are mutually exclusive"));
switch (c) {
+ case 'a':
+ mod->allcpus = 1;
+ break;
case 'h':
usage(stdout);
case 'e':
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/11] [PATCH] lscpu: add s390 test case
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (8 preceding siblings ...)
2011-09-06 0:53 ` [PATCH 09/11] [PATCH] lscpu: add --all option Heiko Carstens
@ 2011-09-06 0:53 ` Heiko Carstens
2011-09-06 0:53 ` [PATCH 11/11] [PATCH] lscpu: add Hypervisor to output Heiko Carstens
2011-09-09 22:07 ` [PATCH 00/11] various lscpu changes Karel Zak
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:53 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
tests/expected/lscpu/lscpu-s390-lpar | 35 +++++++++++++++++++++++++++++++++
tests/expected/lscpu/lscpu-s390-zvm | 21 +++++++++++++++++++
tests/ts/lscpu/bla.tar.gz | Bin 0 -> 2573 bytes
tests/ts/lscpu/dumps/s390-lpar.tar.gz | Bin 0 -> 6611 bytes
tests/ts/lscpu/dumps/s390-zvm.tar.gz | Bin 0 -> 2582 bytes
tests/ts/lscpu/mk-input.sh | 4 +++
6 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 tests/expected/lscpu/lscpu-s390-lpar
create mode 100644 tests/expected/lscpu/lscpu-s390-zvm
create mode 100644 tests/ts/lscpu/bla.tar.gz
create mode 100644 tests/ts/lscpu/dumps/s390-lpar.tar.gz
create mode 100644 tests/ts/lscpu/dumps/s390-zvm.tar.gz
diff --git a/tests/expected/lscpu/lscpu-s390-lpar b/tests/expected/lscpu/lscpu-s390-lpar
new file mode 100644
index 0000000..600fd3f
--- /dev/null
+++ b/tests/expected/lscpu/lscpu-s390-lpar
@@ -0,0 +1,35 @@
+CPU op-mode(s): 32-bit, 64-bit
+CPU(s): 20
+On-line CPU(s) list: 1-5,8-19
+Off-line CPU(s) list: 0,6,7
+Thread(s) per core: 1
+Core(s) per socket: 4
+Socket(s) per book: 6
+Book(s): 4
+Vendor ID: IBM/S390
+BogoMIPS: 14367.00
+Hypervisor vendor: IBM
+Virtualization type: full
+Dispatching mode: vertical
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node
+1,0,0,
+2,1,0,
+3,2,1,
+4,3,1,
+5,4,1,
+8,5,2,
+9,6,2,
+10,7,2,
+11,8,3,
+12,9,3,
+13,10,3,
+14,11,3,
+15,12,4,
+16,13,5,
+17,14,5,
+18,15,5,
+19,16,6,
diff --git a/tests/expected/lscpu/lscpu-s390-zvm b/tests/expected/lscpu/lscpu-s390-zvm
new file mode 100644
index 0000000..9ce22d4
--- /dev/null
+++ b/tests/expected/lscpu/lscpu-s390-zvm
@@ -0,0 +1,21 @@
+CPU op-mode(s): 32-bit, 64-bit
+CPU(s): 4
+On-line CPU(s) list: 0-3
+Thread(s) per core: 1
+Core(s) per socket: 1
+Socket(s) per book: 1
+Book(s): 4
+Vendor ID: IBM/S390
+BogoMIPS: 14367.00
+Hypervisor vendor: IBM
+Virtualization type: full
+Dispatching mode: horizontal
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node
+0,0,0,
+1,1,1,
+2,2,2,
+3,3,3,
diff --git a/tests/ts/lscpu/bla.tar.gz b/tests/ts/lscpu/bla.tar.gz
new file mode 100644
index 0000000000000000000000000000000000000000..9432cbd5e4cb843477b7e97c173ffbc28a8c24b0
GIT binary patch
literal 2573
zcmZ{jdpMMN8^={zsWuyFls98FZweU_L&?;7dn1HxJ1C4&n<SDV$44k-DqC1NHA*#E
zIjwEUX|iHgF|@*rLsLe^F`6+m=I}iCKCP~OulJ9A{&}wZ`rW_l`rV)J=O)q@sXf*7
z-J`Z(GS4TZz-i^>uo_I)DSB&O3HjNL&4fDMnv?fiOvYw7#h2!>gZkbsG_Dw>Q7^4w
z$47X__a*aQE1f)zmOVV9%j6W^8*2+%6;oSn;VP*4Agz2Tk5*EIccyjs-f1t@JMrxm
zQ+D0V^$dI69K(p*BKwy%OpX-~+_OfdG@;jpmgM|sW!Sr?0m$Mvy@>QX@3B=QZ?J@?
z2EB}gL(0;|A?^0<sZtqfmvZlPH`e5G^S*dO`*`}7kJA+e(##TO_T*Gp`1>-Kepj8B
zePHgy7~WA8`9h#-=847p54k1<Wb*iI^GT!Te&WD!&szJR<*waY{m!1OAx9O1Y5S$W
za6j$sq&UOj9g*P>YF$nHVsv;!<Vp)V@N<~{<3tNy?L@nsNo2HTQ*)`1&z6r>i#Bx1
zX@gzW19D|puKO!iX&$3<q`KCa!)-WQQx)#O-f{Cm@ALl_^eGWtPG*qK>p+j6^4{6F
z2wMt*vq!p2BG^Qm9jn`Xml2QD2p9q*4uj9>7K%^5syOCVn6Di&czwoaEE&;d>igso
z<CcUQUx>LEQWcn{p|2yTcB|v{Yo6lvC${yJ_*6t{<n)-emvRpZ!UTzJU0&a`+1PQ1
zo)`0Mw{oA~k7MK>2znexR(X)kLt?0Lj|iD9mnS{QfrHj1k&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A*#^{O)4$T4tS#fmveLppY#?@9k{K+-KJdw
zr+BRNbD@G=+EpF<ZtUcD|HT-=m-5*-vBr`EUp~Mg5=mEhq$I4gZtm_?8Fj@k!N?($
z)=~xxJc3?40^@GTn8x+QD&{hv&t=d9dIi+76g-y4ummNq{##%2|MXQss_cvZ+w*_W
z7lZcbc><*7<P-2;gwpV}K2ikZHMd$cFVFvspN!*wCZg8Zy#roMT)oussvS`OfEC)9
YdqM(ctoHev{vcn|aE>&j7BElkPcZb)mH+?%
literal 0
HcmV?d00001
diff --git a/tests/ts/lscpu/dumps/s390-lpar.tar.gz b/tests/ts/lscpu/dumps/s390-lpar.tar.gz
new file mode 100644
index 0000000000000000000000000000000000000000..59aea6ac19669d5030c973745c41de0ef9ff9991
GIT binary patch
literal 6611
zcmb7IdpuNm|0mj}t=*x0HeH?Qw!2xEO1jVymD(<9yPz;hWy_XIiAo3Aok}&^WmA;V
z<v~%Bq7q{hDwiRbp)fSAGcGX(b7s!@Jl`{;+UNIsp5N>B`v+g=d~cu6`~CjBKL?9o
z={)c9SgoViajn)*;<`V##hRX>-}tEZ2);ZeG`Q-3!M4zAu~v4AjK6Zb@%DAq`N`FG
zZImqX;@#0pgh|r#?@a<^>VRRp2VRr)6;IM#ljhebpSz3k;xuBw%W~xsV+k!j)hAH#
z?-sdtrrO$c4)eb2-^X1(q4URyL3MUTX%}9x-xW2tb=h^+4B+2objjgyZ6Q}V>XuND
z>Q=9w{7Vt2yMrEi?lD)5Q|NOIj``6ZC$g+zVcssfXuCMi@8(fja7mWC<4EeJm7W8Z
zO1Xd<;0i0!-%B~u6)rbwI_A8qE%>7-d5;Ze4m&ZwwlSq<^&P(zih?z(-W~D2cd4np
zEogHm-IQ~yrl|5*kElA}m`%0ak6i_?a`w!5!bu9?UD&VqVCiO-h{asWdKO)CH>)N%
zD9Q7^R8_F5o%>3(KV$Rm$_x1F(?K>@l14X?J0H0h`8Zn$4hD5&<{KxoQ<b&5JSqiI
z8~r{EOz9lu{NA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A|Hwpf_qbTkVkzuPO-%0ZchfD-hm=g{qOb&LXvj;B
zmXqR384una6zEOt_4AivVGVW3QK_W3sOxoZQI5KKpWOFJW_3|k+(o)`xe!EafaTh?
Uf@KokD)D<(eAh~6%}||x0sX6;1ONa4
literal 0
HcmV?d00001
diff --git a/tests/ts/lscpu/dumps/s390-zvm.tar.gz b/tests/ts/lscpu/dumps/s390-zvm.tar.gz
new file mode 100644
index 0000000000000000000000000000000000000000..b13594d2b096ba82f7afac37f59ee6b8bf04b16e
GIT binary patch
literal 2582
zcma*mdpK148V7JpH??glg`?e4L>JqnZHJPjc4`mFLF6PuTd8(RwLNlQbULY&OOhBG
zrQGGxW><r8iIiI;)L>*}Fve}}xApExJ?H#;)<0{#&-+_zJ-^TQ{ULEnRC?9P2UQ5%
zOz%L}vsG8wmG~;PFxu;xUy$Hv@_~0|rL{RrjNeuNtbINHec6V?uH|iV>0_>ybS7x;
z>sc558qKZu?Dnrd;Y#dSXTMhGVv||Tu3|LG3OTScWN->|lEDBoL$>~Wn*OyR0xM%7
zzWCKn)~@O~&pXGatdKd=Em#maRRMQ~-{KUTxOTo4KM<=s8ZXSv`hbfP8ujkSsB)(r
zV}!Xw&lHv}b4?v~AWSvmy~VXH81xXc+d)ay7xWm5g1trb3OYYRl&27^i>;oGjL>Oe
zfbjuD=hz|J(arRW-^=HE^>f=tT6p`st<S!^vpAVz>QQLuRePLQdrP~`aWEf43oKmQ
zD{5*v>@$(|Of+(MY9x47&gah0X*GQ{$Jsmjuei9{BJI|jLob=9I{CEI-6hg;Vg3^y
zJx|ayDQ~cD&lUTmwi8cBJg+us_dM~OOx{6t_dK4zz3lafR7m{~Z^M>`eHspz0-v>a
z+0SKBjHAllC}wHf4zOhG3Bv$P{&e#poF7(cOP#(^<Lptf^y6@c{CbU}Vy49X$izgI
zcvnAlh?iFL>4lTWcH<l;itKluf6)ovX0NQr1ErFbw!l=K?tmh}^V27IL3jE}+cr}&
zLN)YHrZ}~xi(ZGeHKmK{3&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zdCYS!_=riPv1#_>c<JKQ&Yd_rW}2ly)UN@z$rpEyzYT|f1IvZ`xadCIrxg;T<@7Ju
z=5z3y!csj1{4DoLk##`q!Mgs}8Wtg>p?VE}w^K}yn|yT7mp8kjdzB|(J6I~KNif*m
z-?4rKDs&7L2}xjCD?^q_E6`(KS|+LzjGHsBya$YY<tM*}pz}3^L?F1;1$R2b6$$nU
zNVTmA0~tfmL4m~_lw>ELKkiY$`u}E_CBg<(b?48z=CGXJ2c&v42-G@2n0mOS^qYU9
w(%%z5sT|>s)p5xe(SY%INSMRU{dHvzEO^!o>MGx^s&HJT00#e5Ii;%dH$<%8761SM
literal 0
HcmV?d00001
diff --git a/tests/ts/lscpu/mk-input.sh b/tests/ts/lscpu/mk-input.sh
index ddf70ec..299ac08 100644
--- a/tests/ts/lscpu/mk-input.sh
+++ b/tests/ts/lscpu/mk-input.sh
@@ -30,6 +30,10 @@ if [ -d "/proc/xen" ]; then
fi
fi
+if [ -e "/proc/sysinfo" ]; then
+ $CP /proc/sysinfo $TS_DUMP
+fi
+
$CP /sys/devices/system/cpu/* $TS_DUMP
$CP /sys/devices/system/node/*/cpumap $TS_DUMP
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/11] [PATCH] lscpu: add Hypervisor to output
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (9 preceding siblings ...)
2011-09-06 0:53 ` [PATCH 10/11] [PATCH] lscpu: add s390 test case Heiko Carstens
@ 2011-09-06 0:53 ` Heiko Carstens
2011-09-09 22:07 ` [PATCH 00/11] various lscpu changes Karel Zak
11 siblings, 0 replies; 15+ messages in thread
From: Heiko Carstens @ 2011-09-06 0:53 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Heiko Carstens
Some vendors have several hypervisors. Therefore it makes sense to not only
print out the hypervisor vendor but also the name of the hypervisor.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
sys-utils/lscpu.c | 20 ++++++++++++++++++++
tests/expected/lscpu/lscpu-s390-lpar | 1 +
tests/expected/lscpu/lscpu-s390-zvm | 1 +
3 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 7923cc2..6049c3f 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -138,6 +138,7 @@ struct lscpu_desc {
char *family;
char *model;
char *virtflag; /* virtualization flag (vmx, svm) */
+ char *hypervisor; /* hypervisor software */
int hyper; /* hypervisor vendor ID */
int virtype; /* VIRT_PARA|FULL|NONE ? */
char *mhz;
@@ -666,14 +667,31 @@ read_hypervisor(struct lscpu_desc *desc)
char buf[BUFSIZ];
desc->hyper = HYPER_IBM;
+ desc->hypervisor = "PR/SM";
desc->virtype = VIRT_FULL;
while (fgets(buf, sizeof(buf), fd) != NULL) {
+ char *str;
+
if (!strstr(buf, "Control Program:"))
continue;
if (!strstr(buf, "KVM"))
desc->hyper = HYPER_IBM;
else
desc->hyper = HYPER_KVM;
+ str = strchr(buf, ':');
+ if (!str)
+ continue;
+ if (asprintf(&str, str + 1) == -1)
+ errx(EXIT_FAILURE, _("failed to allocate memory"));
+ /* remove leading, trailing and repeating whitespace */
+ while (*str == ' ')
+ str++;
+ desc->hypervisor = str;
+ str += strlen(str) - 1;
+ while ((*str == '\n') || (*str == ' '))
+ *(str--) = '\0';
+ while (str = strstr(desc->hypervisor, " "))
+ memmove(str, str + 1, strlen(str));
}
fclose(fd);
}
@@ -1259,6 +1277,8 @@ print_readable(struct lscpu_desc *desc, struct lscpu_modifier *mod)
else if (!strcmp(desc->virtflag, "vmx"))
print_s(_("Virtualization:"), "VT-x");
}
+ if (desc->hypervisor)
+ print_s(_("Hypervisor:"), desc->hypervisor);
if (desc->hyper) {
print_s(_("Hypervisor vendor:"), hv_vendors[desc->hyper]);
print_s(_("Virtualization type:"), virt_types[desc->virtype]);
diff --git a/tests/expected/lscpu/lscpu-s390-lpar b/tests/expected/lscpu/lscpu-s390-lpar
index 600fd3f..0799ab9 100644
--- a/tests/expected/lscpu/lscpu-s390-lpar
+++ b/tests/expected/lscpu/lscpu-s390-lpar
@@ -8,6 +8,7 @@ Socket(s) per book: 6
Book(s): 4
Vendor ID: IBM/S390
BogoMIPS: 14367.00
+Hypervisor: PR/SM
Hypervisor vendor: IBM
Virtualization type: full
Dispatching mode: vertical
diff --git a/tests/expected/lscpu/lscpu-s390-zvm b/tests/expected/lscpu/lscpu-s390-zvm
index 9ce22d4..04dcf76 100644
--- a/tests/expected/lscpu/lscpu-s390-zvm
+++ b/tests/expected/lscpu/lscpu-s390-zvm
@@ -7,6 +7,7 @@ Socket(s) per book: 1
Book(s): 4
Vendor ID: IBM/S390
BogoMIPS: 14367.00
+Hypervisor: z/VM 6.1.0
Hypervisor vendor: IBM
Virtualization type: full
Dispatching mode: horizontal
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 00/11] various lscpu changes
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
` (10 preceding siblings ...)
2011-09-06 0:53 ` [PATCH 11/11] [PATCH] lscpu: add Hypervisor to output Heiko Carstens
@ 2011-09-09 22:07 ` Karel Zak
2011-09-10 10:25 ` Heiko Carstens
11 siblings, 1 reply; 15+ messages in thread
From: Karel Zak @ 2011-09-09 22:07 UTC (permalink / raw)
To: Heiko Carstens; +Cc: util-linux
On Tue, Sep 06, 2011 at 02:52:51AM +0200, Heiko Carstens wrote:
> another set of patches against lscpu. Since you didn't have chance to push
> out your local tree to kernel.org yet, I simply based them on my old lscpu
> branch which you applied on your local tree:
Merged (available on github) with some minor changes. I have also
added --online to disable by default enabled --all for -e.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 00/11] various lscpu changes
2011-09-09 22:07 ` [PATCH 00/11] various lscpu changes Karel Zak
@ 2011-09-10 10:25 ` Heiko Carstens
2011-09-12 11:55 ` Karel Zak
0 siblings, 1 reply; 15+ messages in thread
From: Heiko Carstens @ 2011-09-10 10:25 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On Sat, Sep 10, 2011 at 12:07:57AM +0200, Karel Zak wrote:
> On Tue, Sep 06, 2011 at 02:52:51AM +0200, Heiko Carstens wrote:
> > another set of patches against lscpu. Since you didn't have chance to push
> > out your local tree to kernel.org yet, I simply based them on my old lscpu
> > branch which you applied on your local tree:
>
> Merged (available on github) with some minor changes. I have also
> added --online to disable by default enabled --all for -e.
I wouldn't say that were minor changes :) But the result looks much better
than my code. Thanks!
However I'd like to see one change if you don't object: printing just "N" or
"Y" instead of "No" and "Yes" in the human readable output looks a bit ugly
to me:
[root@r35lp37 sys-utils]# ./lscpu -e
CPU BOOK SOCKET CORE ONLINE CONFIGURED POLARIZATION ADDRESS
0 0 0 0 Y Y horizontal 0
1 - - - N N - 1
2 0 0 2 Y Y horizontal 2
3 0 1 3 Y Y horizontal 3
4 0 1 4 Y Y horizontal 4
5 0 1 5 Y Y horizontal 5
6 0 1 6 Y Y horizontal 6
7 0 2 7 Y Y horizontal 7
8 0 2 8 Y Y horizontal 8
9 0 2 9 Y Y horizontal 9
10 0 3 10 Y Y horizontal 10
11 0 3 11 Y Y horizontal 11
12 0 3 12 Y Y horizontal 12
13 0 4 13 Y Y horizontal 13
14 0 4 14 Y Y horizontal 14
15 0 5 15 Y Y horizontal 15
16 1 6 16 Y Y horizontal 16
17 1 7 17 Y Y horizontal 17
18 1 7 18 Y Y horizontal 18
19 1 7 19 Y Y horizontal 19
Comparing that to the long form:
CPU BOOK SOCKET CORE ONLINE CONFIGURED POLARIZATION ADDRESS
0 0 0 0 Yes Yes horizontal 0
1 - - - No No - 1
2 0 0 1 Yes Yes horizontal 2
3 0 1 2 Yes Yes horizontal 3
4 0 1 3 Yes Yes horizontal 4
5 0 1 4 Yes Yes horizontal 5
6 0 1 5 Yes Yes horizontal 6
7 0 2 6 Yes Yes horizontal 7
8 0 2 7 Yes Yes horizontal 8
9 0 2 8 Yes Yes horizontal 9
10 0 3 9 Yes Yes horizontal 10
11 0 3 10 Yes Yes horizontal 11
12 0 3 11 Yes Yes horizontal 12
13 0 4 12 Yes Yes horizontal 13
14 0 4 13 Yes Yes horizontal 14
15 0 5 14 Yes Yes horizontal 15
16 1 6 15 Yes Yes horizontal 16
17 1 7 16 Yes Yes horizontal 17
18 1 7 17 Yes Yes horizontal 18
19 1 7 18 Yes Yes horizontal 19
I'd prefer the long form. What do you think?
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 601c872..6a37bb3 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -995,13 +995,24 @@ get_cell_data(struct lscpu_desc *desc, int cpu, int col,
snprintf(buf, bufsz, "%d", desc->addresses[cpu]);
break;
case COL_CONFIGURED:
- if (desc->configured)
+ if (!desc->configured)
+ break;
+ if (mod->mode == OUTPUT_PARSABLE)
snprintf(buf, bufsz,
desc->configured[cpu] ? _("Y") : _("N"));
+ else
+ snprintf(buf, bufsz,
+ desc->configured[cpu] ? _("Yes") : _("No"));
break;
case COL_ONLINE:
- if (desc->online)
- snprintf(buf, bufsz, is_cpu_online(desc, cpu) ? _("Y") : _("N"));
+ if (!desc->online)
+ break;
+ if (mod->mode == OUTPUT_PARSABLE)
+ snprintf(buf, bufsz,
+ is_cpu_online(desc, cpu) ? _("Y") : _("N"));
+ else
+ snprintf(buf, bufsz,
+ is_cpu_online(desc, cpu) ? _("Yes") : _("No"));
break;
}
return buf;
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 00/11] various lscpu changes
2011-09-10 10:25 ` Heiko Carstens
@ 2011-09-12 11:55 ` Karel Zak
0 siblings, 0 replies; 15+ messages in thread
From: Karel Zak @ 2011-09-12 11:55 UTC (permalink / raw)
To: Heiko Carstens; +Cc: util-linux
On Sat, Sep 10, 2011 at 12:25:04PM +0200, Heiko Carstens wrote:
> However I'd like to see one change if you don't object: printing just "N" or
> "Y" instead of "No" and "Yes" in the human readable output looks a bit ugly
> to me:
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2011-09-12 11:55 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-06 0:52 [PATCH 00/11] various lscpu changes Heiko Carstens
2011-09-06 0:52 ` [PATCH 01/11] [PATCH] lscpu: remove comma operator Heiko Carstens
2011-09-06 0:52 ` [PATCH 02/11] [PATCH] lscpu: fix cache output for extended parsable output Heiko Carstens
2011-09-06 0:52 ` [PATCH 03/11] [PATCH] lscpu: simplify cache column output function Heiko Carstens
2011-09-06 0:52 ` [PATCH 04/11] [PATCH] lscpu: allow read_cache() to be called for offline cpus Heiko Carstens
2011-09-06 0:52 ` [PATCH 05/11] [PATCH] lscpu: add --version option Heiko Carstens
2011-09-06 0:52 ` [PATCH 06/11] [PATCH] lscpu: add human readable extended cpu table output Heiko Carstens
2011-09-06 0:52 ` [PATCH 07/11] [PATCH] lscpu: add configured state to output Heiko Carstens
2011-09-06 0:52 ` [PATCH 08/11] [PATCH] lscpu: add online " Heiko Carstens
2011-09-06 0:53 ` [PATCH 09/11] [PATCH] lscpu: add --all option Heiko Carstens
2011-09-06 0:53 ` [PATCH 10/11] [PATCH] lscpu: add s390 test case Heiko Carstens
2011-09-06 0:53 ` [PATCH 11/11] [PATCH] lscpu: add Hypervisor to output Heiko Carstens
2011-09-09 22:07 ` [PATCH 00/11] various lscpu changes Karel Zak
2011-09-10 10:25 ` Heiko Carstens
2011-09-12 11:55 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).