lscpu: Add shared cached info for s390 lscpu -C
The shared cache info for s390 can be found in /proc/cpuinfo. lscpu without any options already processes this info. Fix this in lscpu -C and provide detailed stat. Test for s390: ./lscpu -C NAME ONE-SIZE ALL-SIZE WAYS TYPE LEVEL SETS PHY-LINE COHERENCY-SIZE L1d 128K 256K 8 Data 1 64 256 L1i 128K 256K 8 Instruction 1 64 256 L2d 4M 8M 8 Data 2 2048 256 L2i 2M 4M 8 Instruction 2 1024 256 L3 128M 32 Unified 3 16384 256 L4 672M 42 Unified 4 65536 256 Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
This commit is contained in:
parent
9147d2ad8a
commit
318542e060
|
@ -319,7 +319,7 @@ lookup_cache(char *line, struct lscpu_desc *desc)
|
||||||
struct cpu_cache *cache;
|
struct cpu_cache *cache;
|
||||||
long long size;
|
long long size;
|
||||||
char *p, type;
|
char *p, type;
|
||||||
int level;
|
int level, line_size, associativity;
|
||||||
|
|
||||||
/* Make sure line starts with "cache<nr> :" */
|
/* Make sure line starts with "cache<nr> :" */
|
||||||
if (strncmp(line, "cache", 5) != 0)
|
if (strncmp(line, "cache", 5) != 0)
|
||||||
|
@ -350,6 +350,14 @@ lookup_cache(char *line, struct lscpu_desc *desc)
|
||||||
if (!p || sscanf(p, "size=%lld", &size) != 1)
|
if (!p || sscanf(p, "size=%lld", &size) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
p = strstr(line, "line_size=");
|
||||||
|
if (!p || sscanf(p, "line_size=%u", &line_size) != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p = strstr(line, "associativity=");
|
||||||
|
if (!p || sscanf(p, "associativity=%u", &associativity) != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
desc->necaches++;
|
desc->necaches++;
|
||||||
desc->ecaches = xrealloc(desc->ecaches,
|
desc->ecaches = xrealloc(desc->ecaches,
|
||||||
desc->necaches * sizeof(struct cpu_cache));
|
desc->necaches * sizeof(struct cpu_cache));
|
||||||
|
@ -363,6 +371,11 @@ lookup_cache(char *line, struct lscpu_desc *desc)
|
||||||
|
|
||||||
cache->level = level;
|
cache->level = level;
|
||||||
cache->size = size * 1024;
|
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") :
|
cache->type = type == 'i' ? xstrdup("Instruction") :
|
||||||
type == 'd' ? xstrdup("Data") :
|
type == 'd' ? xstrdup("Data") :
|
||||||
|
@ -1673,8 +1686,25 @@ print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
|
||||||
err(EXIT_FAILURE, _("failed to allocate output column"));
|
err(EXIT_FAILURE, _("failed to allocate output column"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = desc->ncaches - 1; i >= 0; i--) {
|
struct cpu_cache *ca, *cachesrc;
|
||||||
struct cpu_cache *ca = &desc->caches[i];
|
int end, j, shared_allsize;
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
/* First check the caches from /sys/devices */
|
||||||
|
if (j == 0) {
|
||||||
|
cachesrc = desc->caches;
|
||||||
|
end = desc->ncaches - 1;
|
||||||
|
shared_allsize = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Check shared caches from /proc/cpuinfo s390 */
|
||||||
|
cachesrc = desc->ecaches;
|
||||||
|
end = desc->necaches - 1;
|
||||||
|
/* Dont use get_cache_full_size */
|
||||||
|
shared_allsize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = end; i >= 0; i--) {
|
||||||
|
ca = &cachesrc[i];
|
||||||
struct libscols_line *line;
|
struct libscols_line *line;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
@ -1702,7 +1732,8 @@ print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
|
||||||
case COL_CACHE_ALLSIZE:
|
case COL_CACHE_ALLSIZE:
|
||||||
{
|
{
|
||||||
uint64_t sz = 0;
|
uint64_t sz = 0;
|
||||||
|
if (shared_allsize)
|
||||||
|
break;
|
||||||
if (get_cache_full_size(desc, ca, &sz) != 0)
|
if (get_cache_full_size(desc, ca, &sz) != 0)
|
||||||
break;
|
break;
|
||||||
if (mod->bytes)
|
if (mod->bytes)
|
||||||
|
@ -1751,6 +1782,8 @@ print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
scols_print_table(table);
|
scols_print_table(table);
|
||||||
scols_unref_table(table);
|
scols_unref_table(table);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue