diff options
author | Ankur Arora <ankur.a.arora@oracle.com> | 2025-09-17 08:24:04 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-09-19 12:42:40 -0300 |
commit | 07e257245d5ee0c5393ae2fe8c7fc18071c5a637 (patch) | |
tree | 2ec3583b2587afebe7e03c6d64f8ba56c7e4599a | |
parent | 79a0194f2f28abca7a17c37d5384762355d17c26 (diff) |
perf bench mem: Defer type munging of size to float
Do type conversion to double at the point of use.
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Raghavendra K T <raghavendra.kt@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20250917152418.4077386-3-ankur.a.arora@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/bench/mem-functions.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c index 8599ed96ee1f..fddb2acd2d3a 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c @@ -139,7 +139,7 @@ struct bench_mem_info { bool alloc_src; }; -static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, double size_total) +static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, size_t size_total) { const struct function *r = &info->functions[r_idx]; double result_bps = 0.0; @@ -165,18 +165,18 @@ static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t switch (bench_format) { case BENCH_FORMAT_DEFAULT: if (use_cycles) { - printf(" %14lf cycles/byte\n", (double)rt.cycles/size_total); + printf(" %14lf cycles/byte\n", (double)rt.cycles/(double)size_total); } else { - result_bps = size_total/timeval2double(&rt.tv); + result_bps = (double)size_total/timeval2double(&rt.tv); print_bps(result_bps); } break; case BENCH_FORMAT_SIMPLE: if (use_cycles) { - printf("%lf\n", (double)rt.cycles/size_total); + printf("%lf\n", (double)rt.cycles/(double)size_total); } else { - result_bps = size_total/timeval2double(&rt.tv); + result_bps = (double)size_total/timeval2double(&rt.tv); printf("%lf\n", result_bps); } break; @@ -199,7 +199,7 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info * { int i; size_t size; - double size_total; + size_t size_total; argc = parse_options(argc, argv, options, info->usage, 0); @@ -212,7 +212,7 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info * } size = (size_t)perf_atoll((char *)size_str); - size_total = (double)size * nr_loops; + size_total = size * nr_loops; if ((s64)size <= 0) { fprintf(stderr, "Invalid size:%s\n", size_str); |