From cf3b6b71ebb1f3da975ad12d95a6fa3a15591e63 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 6 Jun 2019 14:05:26 +0200 Subject: 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 --- sys-utils/lscpu.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'sys-utils/lscpu.c') 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; -- cgit v1.2.3-55-g7522 From 25b7045e5db032df5354c0749cb454a20b89c522 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 13 Jun 2019 13:22:32 +0200 Subject: misc: replaces atexit(close_stdout) with new close_stdout_atexit() Signed-off-by: Karel Zak --- sys-utils/fsfreeze.c | 2 +- sys-utils/ldattach.c | 2 +- sys-utils/losetup.c | 2 +- sys-utils/lscpu.c | 2 +- sys-utils/lsipc.c | 2 +- text-utils/colrm.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sys-utils/lscpu.c') diff --git a/sys-utils/fsfreeze.c b/sys-utils/fsfreeze.c index 4da1a6fa3..6035a1010 100644 --- a/sys-utils/fsfreeze.c +++ b/sys-utils/fsfreeze.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "hfuV", longopts, NULL)) != -1) { diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index 3019e5a9f..c2d2f8397 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -314,7 +314,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); /* parse options */ if (argc == 0) diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index d862fd8e7..27884df73 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -642,7 +642,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (loopcxt_init(&lc, 0)) err(EXIT_FAILURE, _("failed to initialize loopcxt")); diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 7411994fa..4f1ab47e9 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -2296,7 +2296,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "aBbC::ce::hJp::s:xyV", longopts, NULL)) != -1) { diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index 5ba9cd7bf..5a1a3d7ac 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -1137,7 +1137,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); ctl->time_mode = 0; diff --git a/text-utils/colrm.c b/text-utils/colrm.c index d0ef2eb66..f9dfd5938 100644 --- a/text-utils/colrm.c +++ b/text-utils/colrm.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((opt = getopt_long(argc, argv, "bfhl:pxVH", longopts, -- cgit v1.2.3-55-g7522