Re: [PATCH V5 0/3] Add unit test module for AMD P-State driver

Huang Rui
2022-05-18T05:20:10Z

On Wed, May 18, 2022 at 04:03:05AM +0800, Shuah Khan wrote:
> On 5/17/22 8:45 AM, Shuah Khan wrote:
> > On 5/5/22 12:41 AM, Huang Rui wrote:
> >> On Thu, May 05, 2022 at 10:29:10AM +0800, Meng, Li (Jassmine) wrote:
> >>> Hi all:
> >>>
> >>> AMD P-State unit test(amd-pstate-ut) is a kernel module for testing
> >>> the functions of amd-pstate driver.
> >>> It could import as a module to launch some test tasks.
> >>> 1) It can help all users to verify their processor support (SBIOS/
> >>> Firmware or Hardware).
> >>> 2) Kernel can have a basic function test to avoid the kernel regression
> >>> during the update.
> >>> 3) We can introduce more functional or performance tests to align the
> >>> together, it will benefit power and performance scale optimization.
> >>>
> >>> We upstream out AMD P-state driver into Linux kernel and use this unit
> >>> test module to verify the required conditions and basic functions of
> >>> amd-pstate before integration test.
> >>>
> >>> We use test module in the kselftest frameworks to implement it.
> >>> We create amd-pstate-ut module and tie it into kselftest.
> >>>
> >>> For example: The test case aput_acpi_cpc is used to check whether the
> >>> _CPC object is exist in SBIOS.
> >>> The amd-pstate initialization will fail if the _CPC in ACPI SBIOS is not
> >>> existed at the detected processor, so it is a necessary condition.
> >>>
> >>> At present, it only implements the basic framework and some simple test
> >>> cases.
> >>>
> >>> TODO : 1) we will add more test cases to improve the depth and coverage of
> >>> the test.
> >>>
> >>> Please check the documentation amd-pstate.rst for details of the test steps.
> >>>
> >>> See patch series in below git repo:
> >>> V1: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flinux-pm%2F20220323071502.2674156-1-li.meng%40amd.com%2F&amp;data=05%7C01%7Cray.huang%40amd.com%7C267a994f51e34371021c08da384042f1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637884145911708064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=m9BlIFlf8IEeSGjycWdppnIMoZTbfmi3tIsuRJZL6cw%3D&amp;reserved=0
> >>> V2: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220413090510.4039589-1-li.meng%40amd.com%2F&amp;data=05%7C01%7Cray.huang%40amd.com%7C267a994f51e34371021c08da384042f1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637884145911708064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=h1o69SJ5iaVChb1h8a3FZURAeKAj6vlB%2FmR%2BtfmpoE4%3D&amp;reserved=0
> >>> V3: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220421074152.599419-1-li.meng%40amd.com%2F&amp;data=05%7C01%7Cray.huang%40amd.com%7C267a994f51e34371021c08da384042f1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637884145911708064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=WcXo7q2snNWM8nUSF08HjPDB7UuwFMDTTwe6zLcXHyY%3D&amp;reserved=0
> >>> V4: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220427135315.3447550-1-li.meng%40amd.com%2F&amp;data=05%7C01%7Cray.huang%40amd.com%7C267a994f51e34371021c08da384042f1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637884145911708064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=Rnn9bLhc1sDkNyBlmwmb8Zy4IJUKwtIq0M0qhcUbdM8%3D&amp;reserved=0
> >>>
> >
> >>> Changes from V4 -> V5:
> >>> - selftests: amd-pstate:
> >>> - - add print the current scaling_driver.
> >>> - - add amd-pstate-ut.ko into TEST_GEN_FILES.
> >>> - - move "insmod/rmmod amd-pstate-ut.ko" stuff into script amd_pstate_ut.sh
> >>> - - add a check of read back from X86_FEATURE_CPPC in get_shared_mem().
> >>> - Documentation: amd-pstate:
> >>> - - delete the test step about insmod/rmmod amd-pstate-ut.ko
> >>>
> >>> Thanks,
> >>> Jasmine
> >>>
> >
> > Sorry for the delay on this. I will review the series in the next couple
> > of days.
> >
> > Did you consider using KUnit for this? I think asked that question when
> > reviewing the previous version.
> >
>
> I reviewed the patches and the test driver amd-pstate-ut doesn't belong under
> selftests. I would recommend the following approach:
>
> - add this test driver under drivers/cpufreq
>
> - KUnit is a better fit for this unit test driver unless you want
> to be able to run this without KUnit configured
>
> - add the test script under selftests - the script then can load the
> test driver and run tests and unload the driver.
>

Thanks Shuah. We would like to introduce more CPU benchmark testing based
the amd-pstate-ut next step, it may not be all the stuff in the kernel
module. E.X. use the script to trigger the tbench, gitsource, kernbench,
netperf, speedometer, and etc. testing and monitor the cpu frequency and
performance goals change, power consumption at runtime. Can the KUnit +
Kselftests work more straight forward in user scenario?

Thanks,
Ray