diff options
| author | Karel Zak <kzak@redhat.com> | 2020-08-21 12:21:43 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2020-11-13 09:19:02 +0100 |
| commit | eaf32c65bed3dcff0e59cc7386856f94e417aaa9 (patch) | |
| tree | 03646669634b6d0080a17bf6e2e1266fbe8c83af /sys-utils/lscpu-topology.c | |
| parent | 05abf5944e8b21dc7cab5a261d23a84cb0af4972 (diff) | |
| download | util-linux-eaf32c65bed3dcff0e59cc7386856f94e417aaa9.tar.gz | |
lscpu: add setsize to lscpu context
Don't recalculate again and again setsize from maxcpus.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu-topology.c')
| -rw-r--r-- | sys-utils/lscpu-topology.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sys-utils/lscpu-topology.c b/sys-utils/lscpu-topology.c index e24900a4ba..05d1ae1640 100644 --- a/sys-utils/lscpu-topology.c +++ b/sys-utils/lscpu-topology.c @@ -92,13 +92,12 @@ void lscpu_sort_caches(struct lscpu_cache *caches, size_t n) /* Read topology for specified type */ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct) { - size_t i, setsize, npos; + size_t i, npos; struct path_cxt *sys; int nthreads = 0, sw_topo = 0; FILE *fd; sys = cxt->syscpu; /* /sys/devices/system/cpu/ */ - setsize = CPU_ALLOC_SIZE(cxt->maxcpus); /* CPU set size */ npos = cxt->npossibles; /* possible CPUs */ DBG(TYPE, ul_debugobj(ct, "reading %s/%s/%s topology", @@ -130,7 +129,7 @@ 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); - n = CPU_COUNT_S(setsize, thread_siblings); + n = CPU_COUNT_S(cxt->setsize, thread_siblings); if (!n) n = 1; if (n > nthreads) @@ -154,13 +153,13 @@ 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->coremaps, &ct->ncores, thread_siblings, setsize); - add_cpuset_to_array(ct->socketmaps, &ct->nsockets, core_siblings, setsize); + add_cpuset_to_array(ct->coremaps, &ct->ncores, thread_siblings, cxt->setsize); + add_cpuset_to_array(ct->socketmaps, &ct->nsockets, core_siblings, cxt->setsize); if (book_siblings) - add_cpuset_to_array(ct->bookmaps, &ct->nbooks, book_siblings, setsize); + add_cpuset_to_array(ct->bookmaps, &ct->nbooks, book_siblings, cxt->setsize); if (drawer_siblings) - add_cpuset_to_array(ct->drawermaps, &ct->ndrawers, drawer_siblings, setsize); + add_cpuset_to_array(ct->drawermaps, &ct->ndrawers, drawer_siblings, cxt->setsize); } @@ -277,7 +276,7 @@ static int read_caches(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu) char buf[256]; struct path_cxt *sys = cxt->syscpu; int num = cpu->logical_id; - size_t i, ncaches, setsize; + size_t i, ncaches; ncaches = cxt->ncaches; while (ul_path_accessf(sys, F_OK, @@ -285,8 +284,6 @@ static int read_caches(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu) num, ncaches) == 0) ncaches++; - setsize = CPU_ALLOC_SIZE(cxt->maxcpus); - for (i = 0; i < ncaches; i++) { struct lscpu_cache *ca; cpu_set_t *map; @@ -350,7 +347,7 @@ static int read_caches(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu) if (!ca->sharedmaps) ca->sharedmaps = xcalloc(cxt->npossibles, sizeof(cpu_set_t *)); - add_cpuset_to_array(ca->sharedmaps, &ca->nsharedmaps, map, setsize); + add_cpuset_to_array(ca->sharedmaps, &ca->nsharedmaps, map, cxt->setsize); } return 0; |
