From 2b8fcb8138ab8d6455c60b23bf75b7b3e687c6d7 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 10 Aug 2011 10:34:33 +0200 Subject: lscpu: add cpu polarization to parseable output When running in different dispatching mode the virtual cpus may have different polarizations. E.g. in "vertical" mode cpus may have a polarization of "vertical:high" which means the virtual cpu has dedicated physical cpu assigned. Print this information in the parsable output. Note that this breaks the current rule that a) the parseable output contains only numbers b) these numbers are equal or increased in each line Since however this new item must be selected with the "list" argument this shouldn't be a problem. Signed-off-by: Heiko Carstens --- sys-utils/lscpu.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys-utils/lscpu.1') diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1 index 4795e91c8..f9b8fa443 100644 --- a/sys-utils/lscpu.1 +++ b/sys-utils/lscpu.1 @@ -32,7 +32,7 @@ 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 and Cache columns. If the +supported are CPU, Core, Node, Socket, Book, Cache and Polarization 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 ':'. -- cgit v1.2.3-55-g7522 From 596b884510f9e8958ce3c6c8f159cb58f0e273e0 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 10 Aug 2011 10:34:34 +0200 Subject: lscpu: add physical cpu address to parseable output Print also the physical cpu address for each logical cpu in parsable output if selected and present via sysfs. Signed-off-by: Heiko Carstens --- sys-utils/lscpu.1 | 5 +++-- sys-utils/lscpu.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'sys-utils/lscpu.1') diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1 index f9b8fa443..684059092 100644 --- a/sys-utils/lscpu.1 +++ b/sys-utils/lscpu.1 @@ -32,8 +32,9 @@ 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 and Polarization columns. If the -\fIlist\fP argument is given then always all requested columns are printed in +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 ':'. Note that the optional \fIlist\fP argument cannot be separated from the diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 65ff96ce1..fb65d8e27 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -168,6 +168,7 @@ struct lscpu_desc { struct cpu_cache *caches; int *polarization; /* cpu polarization */ + int *addresses; /* physical cpu addresses */ }; static size_t sysrootlen; @@ -199,7 +200,8 @@ enum { COL_NODE, COL_BOOK, COL_CACHE, - COL_POLARIZATION + COL_POLARIZATION, + COL_ADDRESS }; static const char *colnames[] = @@ -210,7 +212,8 @@ static const char *colnames[] = [COL_NODE] = "Node", [COL_BOOK] = "Book", [COL_CACHE] = "Cache", - [COL_POLARIZATION] = "Polarization" + [COL_POLARIZATION] = "Polarization", + [COL_ADDRESS] = "Address" }; @@ -762,6 +765,16 @@ read_polarization(struct lscpu_desc *desc, int num) desc->polarization[num] = POLAR_UNKNOWN; } +static void +read_address(struct lscpu_desc *desc, int num) +{ + if (!path_exist(_PATH_SYS_CPU "/cpu%d/address", num)) + return; + if (!desc->addresses) + desc->addresses = xcalloc(desc->ncpus, sizeof(int)); + desc->addresses[num] = path_getnum(_PATH_SYS_CPU "/cpu%d/address", num); +} + static int cachecmp(const void *a, const void *b) { @@ -916,6 +929,10 @@ print_parsable_cell(struct lscpu_desc *desc, int i, int col, int compatible) if (desc->polarization) printf("%s", polar_modes[desc->polarization[i]]); break; + case COL_ADDRESS: + if (desc->addresses) + printf("%d", desc->addresses[i]); + break; } } @@ -1230,6 +1247,7 @@ int main(int argc, char *argv[]) read_topology(desc, i); read_cache(desc, i); read_polarization(desc, i); + read_address(desc, i); } qsort(desc->caches, desc->ncaches, sizeof(struct cpu_cache), cachecmp); -- cgit v1.2.3-55-g7522