]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add shared cached info for s390 lscpu -C
authorKarel Zak <kzak@redhat.com>
Tue, 3 Nov 2020 11:10:35 +0000 (12:10 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Nov 2020 08:19:02 +0000 (09:19 +0100)
Port commit
 commit 318542e060ff68e012bea7ee498f12a6ce7e5593
 Author: Sumanth Korikkar <sumanthk@linux.ibm.com>
 Date:   Fri Jun 5 18:15:10 2020 +0200

to new lscpu code.

References: 318542e060ff68e012bea7ee498f12a6ce7e5593
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu-cputype.c

index ec89b3c09f504d072b8e52d0d0a01500d8536440..18369267a42dbd2aaa9dd63307944be38e163c2c 100644 (file)
@@ -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") :