COL_CACHE_ONESIZE,
COL_CACHE_TYPE,
COL_CACHE_WAYS,
+ COL_CACHE_ALLOCPOL,
+ COL_CACHE_WRITEPOL,
+ COL_CACHE_PHYLINE,
+ COL_CACHE_SETS,
+ COL_CACHE_COHERENCYSIZE
};
[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 }
};
read_physical_info_powerpc(desc);
if ((fp = ul_path_fopen(desc->procfs, "r", "sysinfo"))) {
- while (fgets(buf, sizeof(buf), fp) != NULL && !desc->machinetype)
- lookup(buf, "Type", &desc->machinetype);
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ if (lookup(buf, "Type", &desc->machinetype))
+ break;
+ }
fclose(fp);
}
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),
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);
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))
int c;
int cpu = real_cpu_num(desc, i);
- if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
- continue;
- if (!mod->online && desc->online && is_cpu_online(desc, cpu))
- continue;
+ if (desc->online) {
+ if (!mod->offline && !is_cpu_online(desc, cpu))
+ continue;
+ if (!mod->online && is_cpu_online(desc, cpu))
+ continue;
+ }
if (desc->present && !is_cpu_present(desc, cpu))
continue;
for (c = 0; c < ncols; c++) {
struct libscols_line *line;
int cpu = real_cpu_num(desc, i);
- if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
- continue;
- if (!mod->online && desc->online && is_cpu_online(desc, cpu))
- continue;
+ if (desc->online) {
+ if (!mod->offline && !is_cpu_online(desc, cpu))
+ continue;
+ if (!mod->online && is_cpu_online(desc, cpu))
+ continue;
+ }
if (desc->present && !is_cpu_present(desc, cpu))
continue;
err(EXIT_FAILURE, _("failed to allocate output line"));
/* description column */
- scols_line_set_data(ln, 0, txt);
+ if (txt && scols_line_set_data(ln, 0, txt))
+ err(EXIT_FAILURE, _("failed to add output data"));
/* data column */
va_start(args, fmt);
/* Correction for CPU threads */
if (desc->nthreads > desc->ncores)
nshares /= (desc->nthreads / desc->ncores);
+ if (nshares < 1)
+ nshares = 1;
*res = (desc->ncores / nshares) * ca->size;
return 0;
}
if (scols_table_new_column(tb, "field", 0, 0) == NULL ||
- scols_table_new_column(tb, "data", 0, SCOLS_FL_NOEXTREMES) == NULL)
+ scols_table_new_column(tb, "data", 0, SCOLS_FL_NOEXTREMES | SCOLS_FL_WRAP) == NULL)
err(EXIT_FAILURE, _("failed to initialize output column"));
add_summary_s(tb, _("Architecture:"), desc->arch);
tmp = size_to_human_string(
SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
sz);
- snprintf(buf, sizeof(buf), _("%s cache: "), ca->name);
+ snprintf(buf, sizeof(buf), _("%s cache:"), ca->name);
add_summary_s(tb, buf, tmp);
free(tmp);
}
tmp = size_to_human_string(
SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
ca->size);
- snprintf(buf, sizeof(buf), _("%s cache: "), ca->name);
+ snprintf(buf, sizeof(buf), _("%s cache:"), ca->name);
add_summary_s(tb, buf, tmp);
free(tmp);
}
if (desc->vuls) {
for (i = 0; i < desc->nvuls; i++) {
- snprintf(buf, sizeof(buf), ("Vulnerability %s: "), desc->vuls[i].name);
+ snprintf(buf, sizeof(buf), ("Vulnerability %s:"), desc->vuls[i].name);
add_summary_s(tb, buf, desc->vuls[i].text);
}
}
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) {
}
mod->mode = OUTPUT_CACHES;
break;
- case 'h':
- usage();
case 'J':
mod->json = 1;
break;
case 'y':
mod->physical = 1;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case OPT_OUTPUT_ALL:
all = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
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;