Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/resctrl: Make wraparound handling obvious

Within mba_setup() the programmed bandwidth delay value starts
at the maximum (100, or rather ALLOCATION_MAX) and progresses
towards ALLOCATION_MIN by decrementing with ALLOCATION_STEP.

The programmed bandwidth delay should never be negative, so
representing it with an unsigned int is most appropriate. This
may introduce confusion because of the "allocation > ALLOCATION_MAX"
check used to check wraparound of the subtraction.

Modify the mba_setup() flow to start at the minimum, ALLOCATION_MIN,
and incrementally, with ALLOCATION_STEP steps, adjust the
bandwidth delay value. This avoids wraparound while making the purpose
of "allocation > ALLOCATION_MAX" clear and eliminates the
need for the "allocation < ALLOCATION_MIN" check.

Reported-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Closes: https://lore.kernel.org/lkml/1903ac13-5c9c-ef8d-78e0-417ac34a971b@linux.intel.com/
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Reinette Chatre and committed by
Shuah Khan
efffa8c4 46058430

+7 -5
+7 -5
tools/testing/selftests/resctrl/mba_test.c
··· 39 39 const struct user_params *uparams, 40 40 struct resctrl_val_param *p) 41 41 { 42 - static int runs_per_allocation, allocation = 100; 42 + static unsigned int allocation = ALLOCATION_MIN; 43 + static int runs_per_allocation; 43 44 char allocation_str[64]; 44 45 int ret; 45 46 ··· 51 50 if (runs_per_allocation++ != 0) 52 51 return 0; 53 52 54 - if (allocation < ALLOCATION_MIN || allocation > ALLOCATION_MAX) 53 + if (allocation > ALLOCATION_MAX) 55 54 return END_OF_TESTS; 56 55 57 56 sprintf(allocation_str, "%d", allocation); ··· 60 59 if (ret < 0) 61 60 return ret; 62 61 63 - allocation -= ALLOCATION_STEP; 62 + allocation += ALLOCATION_STEP; 64 63 65 64 return 0; 66 65 } ··· 73 72 74 73 static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) 75 74 { 76 - int allocation, runs; 75 + unsigned int allocation; 77 76 bool ret = false; 77 + int runs; 78 78 79 79 ksft_print_msg("Results are displayed in (MB)\n"); 80 80 /* Memory bandwidth from 100% down to 10% */ ··· 105 103 avg_diff_per > MAX_DIFF_PERCENT ? 106 104 "Fail:" : "Pass:", 107 105 MAX_DIFF_PERCENT, 108 - ALLOCATION_MAX - ALLOCATION_STEP * allocation); 106 + ALLOCATION_MIN + ALLOCATION_STEP * allocation); 109 107 110 108 ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per); 111 109 ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc);