struct path_cxt *sys = cxt->syscpu;
size_t i;
+
for (i = 0; i < cxt->ncpus; i++) {
struct lscpu_cpu *cpu = cxt->cpus[i];
int num = cpu->logical_id;
+ DBG(TYPE, ul_debugobj(cpu, "#%d reading IDs", num));
+
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)
int i;
if (!ary)
- return -1;
+ return -EINVAL;
for (i = 0; i < *items; i++) {
if (CPU_EQUAL_S(setsize, set, ary[i]))
return 1;
}
+static void free_cpuset_array(cpu_set_t **ary, int items)
+{
+ int i;
+
+ if (!ary)
+ return;
+ for (i = 0; i < items; i++)
+ free(ary[i]);
+ free(ary);
+}
+
struct lscpu_cputype *lscpu_new_cputype(void)
{
struct lscpu_cputype *ct;
free(ct->flags);
free(ct->mtid); /* maximum thread id (s390) */
free(ct->addrsz); /* address sizes */
- free(ct->coremaps);
- free(ct->socketmaps);
- free(ct->bookmaps);
- free(ct->drawermaps);
+ free_cpuset_array(ct->coremaps, ct->ncores);
+ free_cpuset_array(ct->socketmaps, ct->nsockets);
+ free_cpuset_array(ct->bookmaps, ct->nbooks);
+ free_cpuset_array(ct->drawermaps, ct->ndrawers);
free(ct);
}
}
npos = cxt->ncpuspos; /* possible CPUs */
for (i = 0; i < cxt->ncpus; i++) {
- struct lscpu_cpu *cpu = cxt->cpus[i++];
+ struct lscpu_cpu *cpu = cxt->cpus[i];
cpu_set_t *thread_siblings = NULL, *core_siblings = NULL;
cpu_set_t *book_siblings = NULL, *drawer_siblings = NULL;
int num;
"cpu%d/topology/thread_siblings", num) != 0)
continue;
+ DBG(TYPE, ul_debugobj(ct, "#%d reading topology", num));
+
/* read topology maps */
ul_path_readf_cpuset(sys, &thread_siblings, cxt->maxcpus,
"cpu%d/topology/thread_siblings", num);
* non-present cpu maps and to keep calculation easy we make
* sure that nsockets and nbooks is at least 1.
*/
- nsockets = ct->ncpus / nthreads / ncores;
+ nsockets = cxt->npresents / nthreads / ncores;
if (!nsockets)
nsockets = 1;
}
}
+
+ DBG(TYPE, ul_debugobj(ct, " nthreads: %d", ct->nthreads));
+ DBG(TYPE, ul_debugobj(ct, " ncores: %d", ct->ncores));
+ DBG(TYPE, ul_debugobj(ct, " nsockets: %d", ct->nsockets));
+ DBG(TYPE, ul_debugobj(ct, " nbooks: %d", ct->nbooks));
+ DBG(TYPE, ul_debugobj(ct, " ndrawers: %d", ct->ndrawers));
+
return 0;
}