Commit Graph

32 Commits

Author SHA1 Message Date
David Arcari 4221469a8b selftests/resctrl: Use correct type for pids
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Use correct type for pids

    A few functions receive PIDs through int arguments. PIDs variables
    should be of type pid_t, not int.

    Convert pid arguments from int to pid_t.

    Before printing PID, match the type to %d by casting to int which is
    enough for Linux (standard would allow using a longer integer type but
    generalizing for that would complicate the code unnecessarily, the
    selftest code does not need to be portable).

    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 cd1003ea61 selftests/resctrl: Open perf fd before start & add error handling
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Open perf fd before start & add error handling

    Perf fd (pe_fd) is opened, reset, and enabled during every test the CAT
    selftest runs. Also, ioctl(pe_fd, ...) calls are not error checked even
    if ioctl() could return an error.

    Open perf fd only once before the tests and only reset and enable the
    counter within the test loop. Add error checking to pe_fd ioctl()
    calls.

    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 b17a95c407 selftests/resctrl: Move cat_val() to cat_test.c and rename to cat_test()
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Move cat_val() to cat_test.c and rename to cat_test()

    The main CAT test function is called cat_val() and resides in cache.c
    which is illogical.

    Rename the function to cat_test() and move it into cat_test.c.

    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 7582e934e3 selftests/resctrl: Convert perf related globals to locals
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Convert perf related globals to locals

    Perf related variables pea_llc_miss, pe_read, and pe_fd are globals in
    cache.c.

    Convert them to locals for better scoping and make pea_llc_miss simpler
    by renaming it to pea. Make close(pe_fd) handling easier to understand
    by doing it inside cat_val().

    Make also sizeof()s use safer way to determine the right struct.

    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 8a42dea2df selftests/resctrl: Improve perf init
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Improve perf init

    struct perf_event_attr initialization is spread into
    perf_event_initialize() and perf_event_attr_initialize() and setting
    ->config is hardcoded by the deepest level.

    perf_event_attr init belongs to perf_event_attr_initialize() so move it
    entirely there. Rename the other function
    perf_event_initialized_read_format().

    Call each init function directly from the test as they will take
    different parameters (especially true after the perf related global
    variables are moved to local variables).

    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 742767023a selftests/resctrl: Consolidate naming of perf event related things
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Consolidate naming of perf event related things

    Naming for perf event related functions, types, and variables is
    inconsistent.

    Make struct read_format and all functions related to perf events start
    with "perf_". Adjust variable names towards the same direction but use
    shorter names for variables where appropriate (pe prefix).

    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 98a21d2c84 selftests/resctrl: Remove nested calls in perf event handling
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Remove nested calls in perf event handling

    Perf event handling has functions that are the sole caller of another
    perf event handling related function:
      - reset_enable_llc_perf() calls perf_event_open_llc_miss()
      - perf_event_measure() calls get_llc_perf()

    Remove the extra layer of calls to make the code easier to follow by
    moving the code into the calling function.

    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 415643571f selftests/resctrl: Remove unnecessary __u64 -> unsigned long conversion
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Remove unnecessary __u64 -> unsigned long conversion

    Perf counters are __u64 but the code converts them to unsigned long
    before printing them out.

    Remove unnecessary type conversion and retain the perf originating
    value as __u64.

    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 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 dbd524d7b1 selftests/resctrl: Split measure_cache_vals()
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Split measure_cache_vals()

    measure_cache_vals() does a different thing depending on the test case
    that called it:
      - For CAT, it measures LLC misses through perf.
      - For CMT, it measures LLC occupancy through resctrl.

    Split these two functionalities into own functions the CAT and CMT
    tests can call directly. Replace passing the struct resctrl_val_param
    parameter with the filename because it's more generic and all those
    functions need out of resctrl_val.

    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:56 -04:00
David Arcari de4fff09fa selftests/resctrl: Change function comments to say < 0 on error
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Change function comments to say < 0 on error

    A number function comments state the function return non-zero on
    failure but in reality they can only return 0 on success and < 0 on
    error.

    Update the comments to say < 0 on error to match the behavior.

    While at it, improve cat_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 fa534cba0c selftests/resctrl: Don't use ctrlc_handler() outside signal handling
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Don't use ctrlc_handler() outside signal handling

    perf_event_open_llc_miss() calls ctrlc_handler() to cleanup if
    perf_event_open() returns an error. Those cleanups, however, are not
    the responsibility of perf_event_open_llc_miss() and it thus interferes
    unnecessarily with the usual cleanup pattern. Worse yet,
    ctrlc_handler() calls exit() in the end preventing the ordinary cleanup
    done in the calling function from executing.

    ctrlc_handler() should only be used as a signal handler, not during
    normal error handling.

    Remove call to ctrlc_handler() from perf_event_open_llc_miss(). As
    unmounting resctrlfs and test cleanup are already handled properly
    by error rollbacks in the calling functions, no other changes are
    necessary.

    Suggested-by: Reinette Chatre <reinette.chatre@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 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 965eca8823 selftests/resctrl: Fix wrong format specifier
JIRA: https://issues.redhat.com/browse/RHEL-20790

commit 27c734f4402243f478348108d8a2ebd6e3e5e8a3
Author: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Date:   Fri Oct 13 13:36:32 2023 +0200

    selftests/resctrl: Fix wrong format specifier

    Compiling resctrl selftest after adding a __printf() attribute to
    ksft_print_msg() exposes -Wformat warning in show_cache_info().
    The format specifier used expects a variable of type int but a long
    unsigned int variable is passed instead.

    Change the format specifier to match the passed variable.

    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:53 -04:00
David Arcari ebb8837e7a selftests/resctrl: Remove test type checks from cat_val()
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Remove test type checks from cat_val()

    cat_val() is only used during CAT test but it checks for test type.

    Remove test type checks and the unused else branch from cat_val().

    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 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 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 adf87b4681 selftests/resctrl: Don't pass test name to fill_buf
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Don't pass test name to fill_buf

    Test name is passed to fill_buf functions so that they can loop around
    buffer only once. This is required for CAT test case.

    To loop around buffer only once, caller doesn't need to let fill_buf
    know which test case it is. Instead, pass a boolean argument 'once'
    which makes fill_buf more generic.

    As run_benchmark() no longer needs to pass the test name to
    run_fill_buf(), a few test running functions can be simplified to not
    write the test name into the default benchmark_cmd. The has_ben
    argument can also be removed now from those test running functions.

    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 44a246d216 selftests/resctrl: Remove "malloc_and_init_memory" param from run_fill_buf()
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Remove "malloc_and_init_memory" param from run_fill_buf()

    run_fill_buf()'s malloc_and_init_memory parameter is always 1. There's
    also duplicated memory init code for malloc_and_init_memory == 0 case
    in fill_buf() which is unused.

    Remove the malloc_and_init_memory parameter and the duplicated mem init
    code.

    While at it, fix also a typo in run_fill_buf() prototype's argument.

    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 a3524a6daa selftests/resctrl: Close perf value read fd on errors
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Close perf value read fd on errors

    Perf event fd (fd_lm) is not closed when run_fill_buf() returns error.

    Close fd_lm only in cat_val() to make it easier to track it is always
    closed.

    Fixes: 790bf585b0 ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest")
    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 37f25a277c selftests/resctrl: Correct get_llc_perf() param in function comment
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Correct get_llc_perf() param in function comment

    get_llc_perf() function comment refers to cpu_no parameter that does
    not exist.

    Correct get_llc_perf() the comment to document llc_perf_miss instead.

    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 f967eb5fa1 selftests/resctrl: Change initialize_llc_perf() return type to void
JIRA: https://issues.redhat.com/browse/RHEL-20790

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

    selftests/resctrl: Change initialize_llc_perf() return type to void

    initialize_llc_perf() unconditionally returns 0.

    initialize_llc_perf() performs only memory initialization, none of
    which can fail.

    Change the return type from int to void to accurately reflect that its
    return value doesn't need to be checked. Remove the error checking from
    the only callsite.

    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 e75074781f selftests/resctrl: Change a few printed messages
Change a few printed messages to report test progress more clearly.

Add a missing "\n" at the end of one printed message.

Suggested-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-04-07 16:37:49 -06: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 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
Fenghua Yu 2428673638 selftests/resctrl: Clean up resctrl features check
Checking resctrl features call strcmp() to compare feature strings
(e.g. "mba", "cat" etc). The checkings are error prone and don't have
good coding style. Define the constant strings in macros and call
strncmp() to solve the potential issues.

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:51:36 -06:00
Fenghua Yu 790bf585b0 selftests/resctrl: Add Cache Allocation Technology (CAT) selftest
Cache Allocation Technology (CAT) selftest allocates a portion of
last level cache and starts a benchmark to read each cache
line in this portion of cache. Measure the cache misses in perf and
the misses should be equal to the number of cache lines in this
portion of cache.

We don't use CQM to calculate cache usage because some CAT enabled
platforms don't have CQM.

Co-developed-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Co-developed-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2020-02-10 18:43:07 -07:00
Fenghua Yu 78941183d1 selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest
Cache QoS Monitoring (CQM) selftest starts stressful cache benchmark
with specified size of memory to access the cache. Last Level cache
occupancy reported by CQM should be close to the size of the memory.

Co-developed-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Co-developed-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2020-02-10 18:42:57 -07:00