lscpu: add lscpu_read_topolgy_ids()
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
9d5f3b4873
commit
314aa95fd5
|
@ -191,6 +191,7 @@ int lscpu_read_archext(struct lscpu_cxt *cxt);
|
|||
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);
|
||||
|
|
|
@ -55,6 +55,7 @@ int lscpu_add_cpu(struct lscpu_cxt *cxt,
|
|||
if (type) {
|
||||
cpu->type = type;
|
||||
lscpu_ref_cputype(type);
|
||||
type->ncpus++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -70,21 +71,33 @@ int lscpu_cpus_apply_type(struct lscpu_cxt *cxt, struct lscpu_cputype *type)
|
|||
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];
|
||||
int num = cpu->logical_id;
|
||||
|
||||
if (cpu->type == ct)
|
||||
return cpu;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,15 +213,16 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
|
|||
|
||||
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 */
|
||||
|
@ -234,7 +235,6 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
|
|||
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
|
||||
|
@ -253,8 +253,8 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
|
|||
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);
|
||||
|
@ -949,6 +949,7 @@ int main(int argc, char **argv)
|
|||
lscpu_read_vulnerabilities(cxt);
|
||||
lscpu_read_numas(cxt);
|
||||
lscpu_read_topology(cxt);
|
||||
lscpu_read_topolgy_ids(cxt);
|
||||
|
||||
lscpu_decode_arm(cxt);
|
||||
|
||||
|
|
Loading…
Reference in New Issue