summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/resctrl/cat_test.c
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2021-03-17 02:22:43 +0000
committerShuah Khan <skhan@linuxfoundation.org>2021-04-02 13:54:14 -0600
commit03216ed7bb4de8ce707eb4de23a08516a542770f (patch)
treeba3c7b98f16e13c26b41181422b27820e07d34a3 /tools/testing/selftests/resctrl/cat_test.c
parentca2f4214f9671dfc08b6c5723188e03574203dc5 (diff)
selftests/resctrl: Share show_cache_info() by CAT and CMT tests
show_cache_info() functions are defined separately in CAT and CMT tests. But the functions are same for the tests and unnecessary to be defined separately. Share the function by the tests. Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Tested-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl/cat_test.c')
-rw-r--r--tools/testing/selftests/resctrl/cat_test.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index 1daf911076c78..090d3afc7a780 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -52,30 +52,6 @@ static int cat_setup(int num, ...)
return ret;
}
-static int show_cache_info(unsigned long sum_llc_perf_miss, int no_of_bits,
- unsigned long span)
-{
- unsigned long allocated_cache_lines = span / 64;
- unsigned long avg_llc_perf_miss = 0;
- float diff_percent;
- int ret;
-
- avg_llc_perf_miss = sum_llc_perf_miss / (NUM_OF_RUNS - 1);
- diff_percent = ((float)allocated_cache_lines - avg_llc_perf_miss) /
- allocated_cache_lines * 100;
-
- ret = !is_amd && abs((int)diff_percent) > MAX_DIFF_PERCENT;
- ksft_print_msg("Cache miss rate %swithin %d%%\n",
- ret ? "not " : "", MAX_DIFF_PERCENT);
-
- ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent));
- ksft_print_msg("Number of bits: %d\n", no_of_bits);
- ksft_print_msg("Avg_llc_perf_miss: %lu\n", avg_llc_perf_miss);
- ksft_print_msg("Allocated cache lines: %lu\n", allocated_cache_lines);
-
- return ret;
-}
-
static int check_results(struct resctrl_val_param *param)
{
char *token_array[8], temp[512];
@@ -111,7 +87,9 @@ static int check_results(struct resctrl_val_param *param)
fclose(fp);
no_of_bits = count_bits(param->mask);
- return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span);
+ return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64,
+ MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS,
+ !is_amd, false);
}
void cat_test_cleanup(void)