diff options
author | Fenghua Yu <fenghua.yu@intel.com> | 2021-03-17 05:22:42 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2021-04-02 22:54:08 +0300 |
commit | ca2f4214f9671dfc08b6c5723188e03574203dc5 (patch) | |
tree | d44d208f746dbf39b091e981935346a03ef52fc4 /tools/testing/selftests/resctrl/cat_test.c | |
parent | 2f320911d9fab38597d2a32d91b4f31165e0c9b4 (diff) | |
download | linux-ca2f4214f9671dfc08b6c5723188e03574203dc5.tar.xz |
selftests/resctrl: Call kselftest APIs to log test results
Call kselftest APIs instead of using printf() to log test results
for cleaner code and better future extension.
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.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 20823725daca..1daf911076c7 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -52,25 +52,28 @@ static int cat_setup(int num, ...) return ret; } -static void show_cache_info(unsigned long sum_llc_perf_miss, int no_of_bits, - unsigned long span) +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; - printf("%sok CAT: cache miss rate within %d%%\n", - !is_amd && abs((int)diff_percent) > MAX_DIFF_PERCENT ? - "not " : "", MAX_DIFF_PERCENT); - tests_run++; - printf("# Percent diff=%d\n", abs((int)diff_percent)); - printf("# Number of bits: %d\n", no_of_bits); - printf("# Avg_llc_perf_miss: %lu\n", avg_llc_perf_miss); - printf("# Allocated cache lines: %lu\n", allocated_cache_lines); + 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) @@ -80,7 +83,7 @@ static int check_results(struct resctrl_val_param *param) int runs = 0, no_of_bits = 0; FILE *fp; - printf("# Checking for pass/fail\n"); + ksft_print_msg("Checking for pass/fail\n"); fp = fopen(param->filename, "r"); if (!fp) { perror("# Cannot open file"); @@ -108,9 +111,7 @@ static int check_results(struct resctrl_val_param *param) fclose(fp); no_of_bits = count_bits(param->mask); - show_cache_info(sum_llc_perf_miss, no_of_bits, param->span); - - return 0; + return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span); } void cat_test_cleanup(void) @@ -146,15 +147,15 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) ret = get_cache_size(cpu_no, cache_type, &cache_size); if (ret) return ret; - printf("cache size :%lu\n", cache_size); + ksft_print_msg("Cache size :%lu\n", cache_size); /* Get max number of bits from default-cabm mask */ count_of_bits = count_bits(long_mask); if (n < 1 || n > count_of_bits - 1) { - printf("Invalid input value for no_of_bits n!\n"); - printf("Please Enter value in range 1 to %d\n", - count_of_bits - 1); + ksft_print_msg("Invalid input value for no_of_bits n!\n"); + ksft_print_msg("Please enter value in range 1 to %d\n", + count_of_bits - 1); return -1; } |