From ddc92e39930598e6db8d7556ed458564b16a51a5 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 3 Nov 2020 12:10:35 +0100 Subject: [PATCH] lscpu: add shared cached info for s390 lscpu -C Port commit commit 318542e060ff68e012bea7ee498f12a6ce7e5593 Author: Sumanth Korikkar Date: Fri Jun 5 18:15:10 2020 +0200 to new lscpu code. References: 318542e060ff68e012bea7ee498f12a6ce7e5593 Signed-off-by: Karel Zak --- sys-utils/lscpu-cputype.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c index ec89b3c09f..18369267a4 100644 --- a/sys-utils/lscpu-cputype.c +++ b/sys-utils/lscpu-cputype.c @@ -375,6 +375,7 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data) long long size; char *p, type; int level; + unsigned int line_size, associativity; DBG(GATHER, ul_debugobj(cxt, " parse cpuinfo cache '%s'", data)); @@ -397,7 +398,15 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data) type = 'u'; p = strstr(data, "size="); if (!p || sscanf(p, "size=%lld", &size) != 1) - return 0; + return 0; + + p = strstr(data, "line_size="); + if (!p || sscanf(p, "line_size=%u", &line_size) != 1) + return 0; + + p = strstr(data, "associativity="); + if (!p || sscanf(p, "associativity=%u", &associativity) != 1) + return 0; cxt->necaches++; cxt->ecaches = xrealloc(cxt->ecaches, @@ -413,6 +422,11 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data) cache->nth = keynum; cache->level = level; cache->size = size * 1024; + cache->ways_of_associativity = associativity; + cache->coherency_line_size = line_size; + /* Number of sets for s390. For safety, just check divide by zero */ + cache->number_of_sets = line_size ? (cache->size / line_size): 0; + cache->number_of_sets = associativity ? (cache->number_of_sets / associativity) : 0; cache->type = type == 'i' ? xstrdup("Instruction") : type == 'd' ? xstrdup("Data") : -- 2.47.3