Commit Graph

31 Commits

Author SHA1 Message Date
David Arcari 6e942c0825 selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 0d66ddb296cc46d7b72d67cfaef0de03da092fcd
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jun 10 18:14:57 2024 +0300

    selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl()

    write_bm_pid_to_resctrl() uses resctrl_val to check test name which is
    not a good interface generic resctrl FS functions should provide.

    Tests define mongrp when needed. Remove the test name check in
    write_bm_pid_to_resctrl() to only rely on the mongrp parameter being
    non-NULL.

    Remove write_bm_pid_to_resctrl() resctrl_val parameter and resctrl_val
    member from the struct resctrl_val_param that are not used anymore.
    Similarly, remove the test name constants that are no longer used.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:38:01 -04:00
David Arcari 529861053c selftests/resctrl: Remove mongrp from CMT test
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit f58e66bed1b4563c8afd35d43dbd4fd361705789
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jun 10 18:14:56 2024 +0300

    selftests/resctrl: Remove mongrp from CMT test

    The CMT selftest instantiates a monitor group to read LLC occupancy.
    Since the test also creates a control group, it is unnecessary to
    create another one for monitoring because control groups already
    provide monitoring too.

    Remove the unnecessary monitor group from the CMT selftest.

    Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:38:01 -04:00
David Arcari dc27fcaba4 selftests/resctrl: Add ->init() callback into resctrl_val_param
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit aef5efa64426396cac5b0126cbb6071e92d5da24
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jun 10 18:14:51 2024 +0300

    selftests/resctrl: Add ->init() callback into resctrl_val_param

    The struct resctrl_val_param is there to customize behavior inside
    resctrl_val() which is currently not used to full extent and there are
    number of strcmp()s for test name in resctrl_val done by resctrl_val().

    Create ->init() hook into the struct resctrl_val_param to cleanly
    do per test initialization.

    Remove also unused branches to setup paths and the related #defines
    for CMT test.

    While touching kerneldoc, make the adjacent line consistent with the
    newly added form (callback vs call back).

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:38:00 -04:00
David Arcari 0f0185ac49 selftests/resctrl: Add ->measure() callback to resctrl_val_param
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 0e251816995a1972062fc7ad32047c1aee9cd704
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jun 10 18:14:50 2024 +0300

    selftests/resctrl: Add ->measure() callback to resctrl_val_param

    The measurement done in resctrl_val() varies depending on test type.
    The decision for how to measure is decided based on the string compare
    to test name which is quite inflexible.

    Add ->measure() callback into the struct resctrl_val_param to allow
    each test to provide necessary code as a function which simplifies what
    resctrl_val() has to do.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:38:00 -04:00
David Arcari b53b361416 selftests/resctrl: fix clang build warnings related to abs(), labs() calls
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 14d28ec6f821622211aa65b4da156399c9a4a9c6
Author: John Hubbard <jhubbard@nvidia.com>
Date:   Wed May 8 13:41:01 2024 -0700

    selftests/resctrl: fix clang build warnings related to abs(), labs() calls

    When building with clang, via:

        make LLVM=1 -C tools/testing/selftests

    ...two types of warnings occur:

        warning: absolute value function 'abs' given an argument of type
        'long' but has parameter of type 'int' which may cause truncation of
        value

        warning: taking the absolute value of unsigned type 'unsigned long'
        has no effect

    Fix these by:

    a) using labs() in place of abs(), when long integers are involved, and

    b) Change to use signed integer data types, in places where subtraction
       is used (and could end up with negative values).

    c) Remove a duplicate abs() call in cmt_test.c.

    Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: John Hubbard <jhubbard@nvidia.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:59 -04:00
David Arcari 6204400418 selftests/resctrl: Move cleanups out of individual tests
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 6cd368982cf3f972e5298025af0a9d2b69045cfe
Author: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Date:   Tue Feb 27 08:21:43 2024 +0100

    selftests/resctrl: Move cleanups out of individual tests

    Every test calls its cleanup function at the end of it's test function.
    After the cleanup function pointer is added to the test framework this
    can be simplified to executing the callback function at the end of the
    generic test running function.

    Make test cleanup functions static and call them from the end of
    run_single_test() from the resctrl_test's cleanup function pointer.

    Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:59 -04:00
David Arcari 3478ef13aa selftests/resctrl: Add cleanup function to test framework
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 8780bc88d4c86cdb7e9591bde9dd1110156a203b
Author: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Date:   Tue Feb 27 08:21:41 2024 +0100

    selftests/resctrl: Add cleanup function to test framework

    Resctrl selftests use very similar functions to cleanup after
    themselves. This creates a lot of code duplication. Also not being
    hooked to the test framework means that ctrl-c handler isn't aware of
    what test is currently running and executes all cleanups even though
    only one is needed.

    Add a function pointer to the resctrl_test struct and attach to it
    cleanup functions from individual tests.

    Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:58 -04:00
David Arcari 442ed9b98b selftests/resctrl: Split validate_resctrl_feature_request()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 00616416488868a8b98343863e5ac078506e44e8
Author: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Date:   Fri Feb 16 09:35:28 2024 +0100

    selftests/resctrl: Split validate_resctrl_feature_request()

    validate_resctrl_feature_request() is used to test both if a resource is
    present in the info directory, and if a passed monitoring feature is
    present in the mon_features file.

    Refactor validate_resctrl_feature_request() into two smaller functions
    that each accomplish one check to give feature checking more
    granularity:
    - Resource directory presence in the /sys/fs/resctrl/info directory.
    - Feature name presence in the /sys/fs/resctrl/info/<RESOURCE>/mon_features
      file.

    Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:58 -04:00
David Arcari 3db2077a8d selftests/resctrl: Pass write_schemata() resource instead of test name
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit ca1608875ae21bb40a7731b81bc0e2c95622d502
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:05:12 2023 +0200

    selftests/resctrl: Pass write_schemata() resource instead of test name

    write_schemata() takes the test name as an argument and determines the
    relevant resource based on the test name. Such mapping from name to
    resource does not really belong to resctrlfs.c that should provide
    only generic, test-independent functions.

    Pass the resource stored in the test information structure to
    write_schemata() instead of the test name. The new API is also more
    flexible as it enables to use write_schemata() for more than one
    resource within a test.

    While touching the sprintf(), move the unnecessary %c that is always
    '=' directly into the format string.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:57 -04:00
David Arcari 5ed81383de selftests/resctrl: Introduce generalized test framework
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit c603ff5bb830b8c22dae56ca3ca5ceb5c103525b
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:05:11 2023 +0200

    selftests/resctrl: Introduce generalized test framework

    Each test currently has a "run test" function in per test file and
    another resctrl_tests.c. The functions in resctrl_tests.c are almost
    identical.

    Generalize the one in resctrl_tests.c such that it can be shared
    between all of the tests. It makes adding new tests easier and removes
    the per test if () forests.

    Also add comment to CPU vendor IDs that they must be defined as bits
    for a bitmask.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:57 -04:00
David Arcari bf43c68873 selftests/resctrl: Create struct for input parameters
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 15f298821289d3efba87bb34db29d0ba9780a443
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:05:10 2023 +0200

    selftests/resctrl: Create struct for input parameters

    resctrl_tests reads a set of parameters and passes them individually
    for each tests which causes variations in the call signature between
    the tests.

    Add struct input_params to hold all input parameters. It can be easily
    passed to every test without varying the call signature.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:57 -04:00
David Arcari 7374daa6d6 selftests/resctrl: Split show_cache_info() to test specific and generic parts
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 5caf1b6400d30a31363063314bddea4e5680d639
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:04:58 2023 +0200

    selftests/resctrl: Split show_cache_info() to test specific and generic parts

    show_cache_info() calculates results and provides generic cache
    information. This makes it hard to alter pass/fail conditions.

    Separate the test specific checks into CAT and CMT test files and
    leave only the generic information part into show_cache_info().

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:56 -04:00
David Arcari 88e4c07c81 selftests/resctrl: Create cache_portion_size() helper
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 19e94a2333c2babc773e51a9ed844cfc35a36064
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:04:55 2023 +0200

    selftests/resctrl: Create cache_portion_size() helper

    CAT and CMT tests calculate size of the cache portion for the n-bits
    cache allocation on their own.

    Add cache_portion_size() helper that calculates size of the cache
    portion for the given number of bits and use it to replace the existing
    span calculations. This also prepares for the new CAT test that will
    need to determine the size of the cache portion also during results
    processing.

    Rename also 'cache_size' local variables to 'cache_total_size' to
    prevent misinterpretations.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:56 -04:00
David Arcari 4930b6e21e selftests/resctrl: Refactor get_cbm_mask() and rename to get_full_cbm()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 4b357e2a6d6c364a88d50526675fe596a30766cb
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:04:53 2023 +0200

    selftests/resctrl: Refactor get_cbm_mask() and rename to get_full_cbm()

    Callers of get_cbm_mask() are required to pass a string into which the
    capacity bitmask (CBM) is read. Neither CAT nor CMT tests need the
    bitmask as string but just convert it into an unsigned long value.

    Another limitation is that the bit mask reader can only read
    .../cbm_mask files.

    Generalize the bit mask reading function into get_bit_mask() such that
    it can be used to handle other files besides the .../cbm_mask and
    handles the unsigned long conversion within get_bit_mask() using
    fscanf(). Change get_cbm_mask() to use get_bit_mask() and rename it to
    get_full_cbm() to better indicate what the function does.

    Return error from get_full_cbm() if the bitmask is zero for some reason
    because it makes the code more robust as the selftests naturally assume
    the bitmask has some bits.

    Also mark cache_type const while at it and remove useless comments that
    are related to processing of CBM bits.

    Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:55 -04:00
David Arcari c4860737f7 selftests/resctrl: Return -1 instead of errno on error
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit c90fba60f274b182f8b4df0f5a5dd23a2457f4a3
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:04:48 2023 +0200

    selftests/resctrl: Return -1 instead of errno on error

    A number of functions in the resctrl selftests return errno. It is
    problematic because errno is positive which is often counterintuitive.
    Also, every site returning errno prints the error message already with
    ksft_perror() so there is not much added value in returning the precise
    error code.

    Simply convert all places returning errno to return -1 that is typical
    userspace error code in case of failures.

    While at it, improve resctrl_val() comment to state that 0 means the
    test was run (either pass or fail).

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:55 -04:00
David Arcari 4b2a3e39e2 selftests/resctrl: Convert perror() to ksft_perror() or ksft_print_msg()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit cc8ff7f5c85c076297b18fb9f6d45ec5569d3d44
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Dec 15 17:04:47 2023 +0200

    selftests/resctrl: Convert perror() to ksft_perror() or ksft_print_msg()

    The resctrl selftest code contains a number of perror() calls. Some of
    them come with hash character and some don't. The kselftest framework
    provides ksft_perror() that is compatible with test output formatting
    so it should be used instead of adding custom hash signs.

    Some perror() calls are too far away from anything that sets error.
    For those call sites, ksft_print_msg() must be used instead.

    Convert perror() to ksft_perror() or ksft_print_msg().

    Other related changes:
    - Remove hash signs
    - Remove trailing stops & newlines from ksft_perror()
    - Add terminating newlines for converted ksft_print_msg()
    - Use consistent capitalization
    - Small fixes/tweaks to typos & grammar of the messages
    - Extract error printing out of PARENT_EXIT() to be able to
      differentiate

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:55 -04:00
David Arcari 13e037b2cc selftests/resctrl: Remove duplicate feature check from CMT test
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 030b48fb2cf045dead8ee2c5ead560930044c029
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Oct 2 12:48:09 2023 +0300

    selftests/resctrl: Remove duplicate feature check from CMT test

    The test runner run_cmt_test() in resctrl_tests.c checks for CMT
    feature and does not run cmt_resctrl_val() if CMT is not supported.
    Then cmt_resctrl_val() also check is CMT is supported.

    Remove the duplicated feature check for CMT from cmt_resctrl_val().

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:54 -04:00
David Arcari 93a0e1824f selftests/resctrl: Make benchmark command const and build it with pointers
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit e33cb5702a9f287d829b0e9e6abe57f6a4aba6d2
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Sep 4 12:53:37 2023 +0300

    selftests/resctrl: Make benchmark command const and build it with pointers

    Benchmark command is used in multiple tests so it should not be
    mutated by the tests but CMT test alters span argument. Due to the
    order of tests (CMT test runs last), mutating the span argument in CMT
    test does not trigger any real problems currently.

    Mark benchmark_cmd strings as const and setup the benchmark command
    using pointers. Because the benchmark command becomes const, the input
    arguments can be used directly. Besides being simpler, using the input
    arguments directly also removes the internal size restriction.

    CMT test has to create a copy of the benchmark command before altering
    the benchmark command.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Reviewed-by: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:53 -04:00
David Arcari 446f33007e selftests/resctrl: Simplify span lifetime
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit b1a901e078c4ee4a6fe13021c4577ef5f3155251
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Sep 4 12:53:35 2023 +0300

    selftests/resctrl: Simplify span lifetime

    struct resctrl_val_param contains span member. resctrl_val(), however,
    never uses it because the value of span is embedded into the default
    benchmark command and parsed from it by run_benchmark().

    Remove span from resctrl_val_param. Provide DEFAULT_SPAN for the code
    that needs it. CMT and CAT tests communicate span that is different
    from the DEFAULT_SPAN between their internal functions which is
    converted into passing it directly as a parameter.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:53 -04:00
David Arcari c725695697 selftests/resctrl: Pass the real number of tests to show_cache_info()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 3dad011b9ab1a3904b449c9351a6d9be4b0afbc5
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:15:06 2023 +0300

    selftests/resctrl: Pass the real number of tests to show_cache_info()

    Results include warm-up test which is discarded before passing the sum
    to show_cache_info(). show_cache_info() handles this by subtracting one
    from the number of tests in divisor. It is a trappy construct to have
    sum and number of tests parameters to disagree like this.

    A more logical place for subtracting the skipped tests is where the sum
    is calculated so move it there. Pass the correct number of tests to
    show_cache_info() so it can be used directly as the divisor for
    calculating the average.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:53 -04:00
David Arcari 3479c52031 selftests/resctrl: Move CAT/CMT test global vars to function they are used in
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 85b73447a44cd215815464a0981604e177384192
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:15:05 2023 +0300

    selftests/resctrl: Move CAT/CMT test global vars to function they are used in

    CAT and CMT tests have count_of_bits, long_mask, cbm_mask, and
    cache_size global variables that can be moved into the sole using
    function.

    Make the global variables local variables of the relevant function to
    scope them better.

    While at it, move cache_size initialization into the declaration line.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:53 -04:00
David Arcari ebd8092984 selftests/resctrl: Don't use variable argument list for ->setup()
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 8ee592a638fc246958acdb543acb42e76a72c5aa
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:15:04 2023 +0300

    selftests/resctrl: Don't use variable argument list for ->setup()

    struct resctrl_val_param has ->setup() function that accepts variable
    argument list. All test cases use only 1 argument as input and it's
    the struct resctrl_val_param pointer.

    Instead of variable argument list, directly pass struct
    resctrl_val_param pointer as the only parameter to ->setup().

    Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:52 -04:00
David Arcari bc6c09ce18 selftests/resctrl: Convert span to size_t
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 67a86643db2b12408430d1d627b3dc6208f06765
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:14:57 2023 +0300

    selftests/resctrl: Convert span to size_t

    Span is defined either as unsigned long or int.

    Consistently use size_t everywhere for span as it refers to size of the
    memory block.

    Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:52 -04:00
David Arcari 8bbdeee513 selftests/resctrl: Remove mum_resctrlfs from struct resctrl_val_param
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 48f3b68738c74941b93ef499f69da313c07f24c3
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:14:56 2023 +0300

    selftests/resctrl: Remove mum_resctrlfs from struct resctrl_val_param

    Resctrl FS mount/umount are now cleanly paired leaving .mum_resctrlfs
    in the struct resctrl_val_param unused.

    Remove .mum_resctrlfs from struct resctrl_val_param.

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:52 -04:00
David Arcari 846269ff58 selftests/resctrl: Move resctrl FS mount/umount to higher level
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit caddc0fbe4958a84b0dcd257439e9090c8fbfb8e
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Mon Jul 17 16:14:54 2023 +0300

    selftests/resctrl: Move resctrl FS mount/umount to higher level

    A few places currently lack umounting resctrl FS on error paths:
      - cmt_resctrl_val() has multiple error paths with direct return.
      - cat_perf_miss_val() has multiple error paths with direct return.
    In addition, validate_resctrl_feature_request() is called by
    run_mbm_test() and run_mba_test(). Neither MBA nor MBM test tries to
    umount resctrl FS.

    Each and every test does require resctrl FS to be present already for
    feature check. Thus, it makes sense to just mount it on higher level in
    resctrl_tests.c and properly pair it with umount.

    Move resctrl FS (re)mount/unmount into each test function in
    resctrl_tests.c. Make feature validation to simply check that resctrl
    FS is mounted.

    As there's the final umount in main() before this change, the selftest
    should not leave resctrl FS behind after the tests even if one of the
    forementioned paths is taken (thus, no fixes tag).

    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Babu Moger <babu.moger@amd.com>
    Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:51 -04:00
David Arcari 34c6d8ff46 selftests/resctrl: Remove duplicate codes that clear each test result file
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 91db4fd9019a08251a500157cf0d88de457e1a96
Author: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Date:   Thu Apr 13 16:22:59 2023 +0900

    selftests/resctrl: Remove duplicate codes that clear each test result file

    Before exiting each test function(run_cmt/cat/mbm/mba_test()),
    test results("ok","not ok") are printed by ksft_test_result() and then
    temporary result files are cleaned by function
    cmt/cat/mbm/mba_test_cleanup().
    However, before running ksft_test_result(),
    function cmt/cat/mbm/mba_test_cleanup()
    has been run in each test function as follows:
      cmt_resctrl_val()
      cat_perf_miss_val()
      mba_schemata_change()
      mbm_bw_change()

    Remove duplicate codes that clear each test result file,
    while ensuring cleanup properly even when errors occur in each test.

    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:51 -04:00
David Arcari cf3920a6d6 selftests/resctrl: Use remount_resctrlfs() consistently with boolean
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit a967e17f918400226e57335e6131572d9f456a9f
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Wed Feb 15 15:06:04 2023 +0200

    selftests/resctrl: Use remount_resctrlfs() consistently with boolean

    remount_resctrlfs() accepts a boolean value as an argument. Some tests
    pass 0/1 and some tests pass true/false.

    Make all the callers of remount_resctrlfs() use true/false so that the
    parameter usage is consistent across tests.

    Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:50 -04:00
David Arcari 025302289c selftests/resctrl: Allow ->setup() to return errors
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit fa10366cc6f4cc862871f8938426d85c2481f084
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Wed Feb 15 15:05:59 2023 +0200

    selftests/resctrl: Allow ->setup() to return errors

    resctrl_val() assumes ->setup() always returns either 0 to continue
    tests or < 0 in case of the normal termination of tests after x runs.
    The latter overlaps with normal error returns.

    Define END_OF_TESTS (=1) to differentiate the normal termination of
    tests and return errors as negative values. Alter callers of ->setup()
    to handle errors properly.

    Fixes: 790bf585b0 ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest")
    Fixes: ecdbb911f2 ("selftests/resctrl: Add MBM test")
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-16 07:37:49 -04:00
Fenghua Yu 03216ed7bb selftests/resctrl: Share show_cache_info() by CAT and CMT tests
show_cache_info() functions are defined separately in CAT and CMT
tests. But the functions are same for the tests and unnecessary
to be defined separately. Share the function by the tests.

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>
2021-04-02 13:54:14 -06:00
Fenghua Yu ca2f4214f9 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>
2021-04-02 13:54:08 -06:00
Fenghua Yu 2f320911d9 selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.

Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.

[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
    information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
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>
2021-04-02 13:53:54 -06:00