selftests/resctrl: Simplify span lifetime
[platform/kernel/linux-rpi.git] / tools / testing / selftests / resctrl / cat_test.c
index 3848dfb..97b8728 100644 (file)
@@ -41,7 +41,7 @@ static int cat_setup(struct resctrl_val_param *p)
        return ret;
 }
 
-static int check_results(struct resctrl_val_param *param)
+static int check_results(struct resctrl_val_param *param, size_t span)
 {
        char *token_array[8], temp[512];
        unsigned long sum_llc_perf_miss = 0;
@@ -76,7 +76,7 @@ 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 / 64,
+       return show_cache_info(sum_llc_perf_miss, no_of_bits, span / 64,
                               MAX_DIFF, MAX_DIFF_PERCENT, runs - 1,
                               get_vendor() == ARCH_INTEL, false);
 }
@@ -96,6 +96,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
        char cbm_mask[256];
        int count_of_bits;
        char pipe_message;
+       size_t span;
 
        /* Get default cbm mask for L3/L2 cache */
        ret = get_cbm_mask(cache_type, cbm_mask);
@@ -140,7 +141,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
        /* Set param values for parent thread which will be allocated bitmask
         * with (max_bits - n) bits
         */
-       param.span = cache_size * (count_of_bits - n) / count_of_bits;
+       span = cache_size * (count_of_bits - n) / count_of_bits;
        strcpy(param.ctrlgrp, "c2");
        strcpy(param.mongrp, "m2");
        strcpy(param.filename, RESULT_FILE_NAME2);
@@ -162,7 +163,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
                param.mask = l_mask_1;
                strcpy(param.ctrlgrp, "c1");
                strcpy(param.mongrp, "m1");
-               param.span = cache_size * n / count_of_bits;
+               span = cache_size * n / count_of_bits;
                strcpy(param.filename, RESULT_FILE_NAME1);
                param.num_of_runs = 0;
                param.cpu_no = sibling_cpu_no;
@@ -176,9 +177,9 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
 
        remove(param.filename);
 
-       ret = cat_val(&param);
+       ret = cat_val(&param, span);
        if (ret == 0)
-               ret = check_results(&param);
+               ret = check_results(&param, span);
 
        if (bm_pid == 0) {
                /* Tell parent that child is ready */