summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorHeiko Carstens2011-08-10 10:34:34 +0200
committerHeiko Carstens2011-08-14 17:34:39 +0200
commit596b884510f9e8958ce3c6c8f159cb58f0e273e0 (patch)
tree7ef8c080e3607b04efdefe563696f0db1954c344 /sys-utils/lscpu.c
parentlscpu: add cpu polarization to parseable output (diff)
downloadkernel-qcow2-util-linux-596b884510f9e8958ce3c6c8f159cb58f0e273e0.tar.gz
kernel-qcow2-util-linux-596b884510f9e8958ce3c6c8f159cb58f0e273e0.tar.xz
kernel-qcow2-util-linux-596b884510f9e8958ce3c6c8f159cb58f0e273e0.zip
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 <heiko.carstens@de.ibm.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c22
1 files changed, 20 insertions, 2 deletions
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);