selftests/resctrl: Ensure sibling CPU is not same as original CPU
authorReinette Chatre <reinette.chatre@intel.com>
Wed, 17 Mar 2021 02:22:39 +0000 (02:22 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 2 Apr 2021 19:51:43 +0000 (13:51 -0600)
The resctrl tests can accept a CPU on which the tests are run and use
default of CPU #1 if it is not provided. In the CAT test a "sibling CPU"
is determined that is from the same package where another thread will be
run.

The current algorithm with which a "sibling CPU" is determined does not
take the provided/default CPU into account and when that CPU is the
first CPU in a package then the "sibling CPU" will be selected to be the
same CPU since it starts by picking the first CPU from core_siblings_list.

Fix the "sibling CPU" selection by taking the provided/default CPU into
account and ensuring a sibling that is a different CPU is selected.

Tested-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/resctrlfs.c

index 4174e48e06d1eae720caae7ad33e03ae758827d7..bc52076bee7fcfaf62d9ba6244b0e4ca8858f1d9 100644 (file)
@@ -268,7 +268,7 @@ int get_core_sibling(int cpu_no)
        while (token) {
                sibling_cpu_no = atoi(token);
                /* Skipping core 0 as we don't want to run test on core 0 */
-               if (sibling_cpu_no != 0)
+               if (sibling_cpu_no != 0 && sibling_cpu_no != cpu_no)
                        break;
                token = strtok(NULL, "-,");
        }