int lscpu_read_vulnerabilities(struct lscpu_cxt *cxt);
int lscpu_read_numas(struct lscpu_cxt *cxt);
int lscpu_read_topology(struct lscpu_cxt *cxt);
+int lscpu_read_topolgy_ids(struct lscpu_cxt *cxt);
struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt);
void lscpu_free_architecture(struct lscpu_arch *ar);
if (type) {
cpu->type = type;
lscpu_ref_cputype(type);
+ type->ncpus++;
}
return 0;
if (!cpu->type) {
cpu->type = type;
lscpu_ref_cputype(type);
+ type->ncpus++;
}
}
return 0;
}
-/* returns first CPU which represents the type */
-struct lscpu_cpu *lscpu_cpus_loopup_by_type(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
+
+int lscpu_read_topolgy_ids(struct lscpu_cxt *cxt)
{
+ struct path_cxt *sys = cxt->syscpu;
size_t i;
for (i = 0; i < cxt->ncpus; i++) {
struct lscpu_cpu *cpu = cxt->cpus[i];
-
- if (cpu->type == ct)
- return cpu;
+ int num = cpu->logical_id;
+
+ if (ul_path_readf_s32(sys, &cpu->coreid, "cpu%d/topology/core_id", num) != 0)
+ cpu->coreid = -1;
+ if (ul_path_readf_s32(sys, &cpu->socketid, "cpu%d/topology/physical_package_id", num) != 0)
+ cpu->socketid = -1;
+ if (ul_path_readf_s32(sys, &cpu->bookid, "cpu%d/topology/book_id", num) != 0)
+ cpu->bookid = -1;
+ if (ul_path_readf_s32(sys, &cpu->drawerid, "cpu%d/topology/drawer_id", num) != 0)
+ cpu->drawerid = -1;
}
- return NULL;
+
+ return 0;
}
+
+
for (i = 0; i < cxt->ncpus; i++) {
struct lscpu_cpu *cpu = cxt->cpus[i++];
- cpu_set_t *thread_siblings, *core_siblings;
- cpu_set_t *book_siblings, *drawer_siblings;
+ cpu_set_t *thread_siblings = NULL, *core_siblings = NULL;
+ cpu_set_t *book_siblings = NULL, *drawer_siblings = NULL;
int num;
if (cpu->type != ct)
continue;
num = cpu->logical_id;
- if (ul_path_accessf(sys, F_OK, "cpu%d/topology/thread_siblings", num) != 0)
+ if (ul_path_accessf(sys, F_OK,
+ "cpu%d/topology/thread_siblings", num) != 0)
continue;
/* read topology maps */
ul_path_readf_cpuset(sys, &drawer_siblings, cxt->maxcpus,
"cpu%d/topology/drawer_siblings", num);
-
/* Allocate arrays for topology maps.
*
* For each map we make sure that it can have up to ncpuspos
ct->drawermaps = xcalloc(npos, sizeof(cpu_set_t *));
/* add to topology maps */
- add_cpuset_to_array(ct->socketmaps, &ct->nsockets, core_siblings, setsize);
add_cpuset_to_array(ct->coremaps, &ct->ncores, thread_siblings, setsize);
+ add_cpuset_to_array(ct->socketmaps, &ct->nsockets, core_siblings, setsize);
if (book_siblings)
add_cpuset_to_array(ct->bookmaps, &ct->nbooks, book_siblings, setsize);
lscpu_read_vulnerabilities(cxt);
lscpu_read_numas(cxt);
lscpu_read_topology(cxt);
+ lscpu_read_topolgy_ids(cxt);
lscpu_decode_arm(cxt);