mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
cpumf/lshwc: Allocate memory for per-cpu counter
Allocate the memory required to save the per CPU CPUMF counter value at the beginning of program execution when the involved number of CPUs is known. This a bit faster then checking for memory allocation each time a counter value is retrieved. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
283ae4dd2f
commit
9df45d4256
@@ -490,11 +490,7 @@ static bool add_countervalue(size_t idx, unsigned int cpu, unsigned long value)
|
||||
warnx("Invalid CPU number %d", cpu);
|
||||
return false;
|
||||
}
|
||||
if (!ctrname[idx].ccv) /* Unknown counter */
|
||||
ctrname[idx].ccv = calloc(max_possible_cpus,
|
||||
sizeof(unsigned long));
|
||||
if (ctrname[idx].ccv)
|
||||
ctrname[idx].ccv[cpu] = value;
|
||||
ctrname[idx].ccv[cpu] = value;
|
||||
ctrname[idx].total += value;
|
||||
ctrname[idx].hitcnt = true;
|
||||
return true;
|
||||
@@ -757,6 +753,9 @@ int main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(ctrname); ++i)
|
||||
ctrname[i].ccv = util_zalloc(max_possible_cpus * sizeof(unsigned long));
|
||||
|
||||
if (optind >= argc) {
|
||||
ch = do_it(NULL);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user