summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2019-06-06 14:05:26 +0200
committerKarel Zak2019-06-17 15:46:10 +0200
commitcf3b6b71ebb1f3da975ad12d95a6fa3a15591e63 (patch)
treec6775ba0d765d89cac14dbfa24ddb2f5bd2694dd /sys-utils
parentdocs: we have 2019 already (diff)
downloadkernel-qcow2-util-linux-cf3b6b71ebb1f3da975ad12d95a6fa3a15591e63.tar.gz
kernel-qcow2-util-linux-cf3b6b71ebb1f3da975ad12d95a6fa3a15591e63.tar.xz
kernel-qcow2-util-linux-cf3b6b71ebb1f3da975ad12d95a6fa3a15591e63.zip
lscpu: add a new columns to --cache
References: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/lscpu.c54
-rw-r--r--sys-utils/lscpu.h9
2 files changed, 57 insertions, 6 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 0e775805e..7411994fa 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -178,6 +178,11 @@ enum {
COL_CACHE_ONESIZE,
COL_CACHE_TYPE,
COL_CACHE_WAYS,
+ COL_CACHE_ALLOCPOL,
+ COL_CACHE_WRITEPOL,
+ COL_CACHE_PHYLINE,
+ COL_CACHE_SETS,
+ COL_CACHE_COHERENCYSIZE
};
@@ -215,7 +220,12 @@ static struct lscpu_coldesc coldescs_cache[] =
[COL_CACHE_NAME] = { "NAME", N_("cache name") },
[COL_CACHE_ONESIZE] = { "ONE-SIZE", N_("size of one cache"), SCOLS_FL_RIGHT },
[COL_CACHE_TYPE] = { "TYPE", N_("cache type") },
- [COL_CACHE_WAYS] = { "WAYS", N_("ways of associativity"), SCOLS_FL_RIGHT }
+ [COL_CACHE_WAYS] = { "WAYS", N_("ways of associativity"), SCOLS_FL_RIGHT },
+ [COL_CACHE_ALLOCPOL] = { "ALLOC-POLICY", N_("allocation policy") },
+ [COL_CACHE_WRITEPOL] = { "WRITE-POLICY", N_("write policy") },
+ [COL_CACHE_PHYLINE] = { "PHY-LINE", N_("number of physical cache line per cache t"), SCOLS_FL_RIGHT },
+ [COL_CACHE_SETS] = { "SETS", N_("number of sets in the cache; set lines has the same cache index"), SCOLS_FL_RIGHT },
+ [COL_CACHE_COHERENCYSIZE] = { "COHERENCY-SIZE", N_("minimum amount of data in bytes transferred from memory to cache"), SCOLS_FL_RIGHT }
};
@@ -1354,9 +1364,19 @@ read_cache(struct lscpu_desc *desc, int idx)
ca->name = xstrdup(buf);
- /* cache ways */
- ul_path_readf_s32(desc->syscpu, &ca->ways,
+ ul_path_readf_u32(desc->syscpu, &ca->ways_of_associativity,
"cpu%d/cache/index%d/ways_of_associativity", num, i);
+ ul_path_readf_u32(desc->syscpu, &ca->physical_line_partition,
+ "cpu%d/cache/index%d/physical_line_partition", num, i);
+ ul_path_readf_u32(desc->syscpu, &ca->number_of_sets,
+ "cpu%d/cache/index%d/number_of_sets", num, i);
+ ul_path_readf_u32(desc->syscpu, &ca->coherency_line_size,
+ "cpu%d/cache/index%d/coherency_line_size", num, i);
+
+ ul_path_readf_string(desc->syscpu, &ca->allocation_policy,
+ "cpu%d/cache/index%d/allocation_policy", num, i);
+ ul_path_readf_string(desc->syscpu, &ca->write_policy,
+ "cpu%d/cache/index%d/write_policy", num, i);
/* cache size */
if (ul_path_readf_buffer(desc->syscpu, buf, sizeof(buf),
@@ -1682,9 +1702,10 @@ print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
break;
}
case COL_CACHE_WAYS:
- if (ca->ways)
- xasprintf(&data, "%d", ca->ways);
+ if (ca->ways_of_associativity)
+ xasprintf(&data, "%u", ca->ways_of_associativity);
break;
+
case COL_CACHE_TYPE:
if (ca->type)
data = xstrdup(ca->type);
@@ -1693,6 +1714,26 @@ print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
if (ca->level)
xasprintf(&data, "%d", ca->level);
break;
+ case COL_CACHE_ALLOCPOL:
+ if (ca->allocation_policy)
+ data = xstrdup(ca->allocation_policy);
+ break;
+ case COL_CACHE_WRITEPOL:
+ if (ca->write_policy)
+ data = xstrdup(ca->write_policy);
+ break;
+ case COL_CACHE_PHYLINE:
+ if (ca->physical_line_partition)
+ xasprintf(&data, "%u", ca->physical_line_partition);
+ break;
+ case COL_CACHE_SETS:
+ if (ca->number_of_sets)
+ xasprintf(&data, "%u", ca->number_of_sets);
+ break;
+ case COL_CACHE_COHERENCYSIZE:
+ if (ca->coherency_line_size)
+ xasprintf(&data, "%u", ca->coherency_line_size);
+ break;
}
if (data && scols_line_refer_data(line, c, data))
@@ -2414,6 +2455,9 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_CACHE_WAYS;
columns[ncolumns++] = COL_CACHE_TYPE;
columns[ncolumns++] = COL_CACHE_LEVEL;
+ columns[ncolumns++] = COL_CACHE_SETS;
+ columns[ncolumns++] = COL_CACHE_PHYLINE;
+ columns[ncolumns++] = COL_CACHE_COHERENCYSIZE;
}
print_caches_readable(desc, columns, ncolumns, mod);
break;
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 56c97e2e8..5bbdb348e 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -49,10 +49,17 @@ enum {
struct cpu_cache {
char *name;
char *type;
+ char *allocation_policy;
+ char *write_policy;
+
int level;
- int ways;
uint64_t size;
+ unsigned int ways_of_associativity;
+ unsigned int physical_line_partition;
+ unsigned int number_of_sets;
+ unsigned int coherency_line_size;
+
int nsharedmaps;
cpu_set_t **sharedmaps;
};