[PATCH i-g-t v2 4/4] tests/intel/xe_pmu: Add multi client engine activity test

Riana Tauro riana.tauro at intel.com
Tue Jun 3 06:37:30 UTC 2025



On 5/29/2025 11:18 PM, Umesh Nerlige Ramappa wrote:
> On Thu, May 29, 2025 at 12:23:59PM +0530, Riana Tauro wrote:
>> Add a test to validate engine activity by opening multiple
>> PMU clients and check that they do not interfere with
>> each other
>>
>> Signed-off-by: Riana Tauro <riana.tauro at intel.com>
>> ---
>> tests/intel/xe_pmu.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 60 insertions(+)
>>
>> diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
>> index 21b294167..225b3b42e 100644
>> --- a/tests/intel/xe_pmu.c
>> +++ b/tests/intel/xe_pmu.c
>> @@ -46,6 +46,10 @@
>>  * SUBTEST: engine-activity-suspend
>>  * Description: Test to validate engine activity on all engines before 
>> and after s2idle
>>  *
>> + * SUBTEST: engine-activity-multi-client
>> + * Description: Test to validate engine activity with multiple PMU 
>> clients and check that
>> + *        they do not interfere with each other
>> + *
>>  * SUBTEST: engine-activity-after-load-start
>>  * Description: Validates engine activity when PMU is opened after 
>> load started
>>  *
>> @@ -612,6 +616,58 @@ static void engine_activity_load_start(int fd, 
>> struct drm_xe_engine_class_instan
>>     assert_within_epsilon(engine_active_ticks, engine_total_ticks, 
>> tolerance);
>> }
>>
>> +static void engine_activity_multi_client(int fd, struct 
>> drm_xe_engine_class_instance *eci,
>> +                     int num_clients)
>> +{
>> +    uint64_t before[num_clients][2], after[num_clients][2], 
>> pmu_fd[num_clients][2];
> 
> This can be
> 
> struct client {
>      uint64_t before;
>      uint64_t after;
>      int pmu_fd;
> }[num_clients];
> 
> Also, if num_clients is only ever going to be 2, you could drop the 
> parameter to this function and just use 2 internally (maybe as a macro).

Sure will do that. Thank you for the review
Thanks
Riana
> 
> Otherwise, the test/logic LGTM, with or without the above change, this is
> 
> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
> 
> Thanks,
> Umesh
> 
> 
>> +    uint64_t ahnd, config, engine_active_ticks, engine_total_ticks;
>> +    struct xe_cork *cork = NULL;
>> +    uint32_t vm;
>> +    int i = 0;
>> +
>> +    vm = xe_vm_create(fd, 0, 0);
>> +    ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
>> +
>> +    for (i = 0; i < num_clients; i++) {
>> +        config = get_event_config(eci->gt_id, eci, "engine-active- 
>> ticks");
>> +        pmu_fd[i][0] = open_group(fd, config, -1);
>> +        config = get_event_config(eci->gt_id, eci, "engine-total- 
>> ticks");
>> +        pmu_fd[i][1] = open_group(fd, config, pmu_fd[i][0]);
>> +    }
>> +
>> +    cork = xe_cork_create_opts(fd, eci, vm, 1, 1, .ahnd = ahnd);
>> +    xe_cork_sync_start(fd, cork);
>> +
>> +    for (i = 0; i < num_clients; i++)
>> +        pmu_read_multi(pmu_fd[i][0], 2, before[i]);
>> +
>> +    usleep(SLEEP_DURATION * USEC_PER_SEC);
>> +
>> +    for (i = 0; i < num_clients; i++)
>> +        pmu_read_multi(pmu_fd[i][0], 2, after[i]);
>> +
>> +    end_cork(fd, cork);
>> +    xe_cork_destroy(fd, cork);
>> +    xe_vm_destroy(fd, vm);
>> +    put_ahnd(ahnd);
>> +
>> +    for (i = 0; i < num_clients; i++) {
>> +        engine_active_ticks = after[i][0] - before[i][0];
>> +        engine_total_ticks = after[i][1] - before[i][1];
>> +
>> +        igt_debug("Client %d: Engine active ticks:  after %ld, before 
>> %ld delta %ld\n",
>> +              i + 1, after[i][0], before[i][0], engine_active_ticks);
>> +
>> +        igt_debug("Client %d Engine total ticks: after %ld, before 
>> %ld delta %ld\n",
>> +              i + 1, after[i][1], before[i][1], engine_total_ticks);
>> +
>> +        close(pmu_fd[i][0]);
>> +        close(pmu_fd[i][1]);
>> +
>> +        assert_within_epsilon(engine_active_ticks, 
>> engine_active_ticks, tolerance);
>> +    }
>> +}
>> +
>> static void test_gt_c6_idle(int xe, unsigned int gt)
>> {
>>     int pmu_fd;
>> @@ -889,6 +945,10 @@ igt_main
>>     test_each_engine("engine-activity-after-load-start", fd, eci)
>>         engine_activity_load_start(fd, eci);
>>
>> +    igt_describe("Validate multiple PMU clients do not interfere with 
>> each other");
>> +    test_each_engine("engine-activity-multi-client", fd, eci)
>> +        engine_activity_multi_client(fd, eci, 2);
>> +
>>     igt_subtest_group {
>>         int render_fd;
>>
>> -- 
>> 2.47.1
>>



More information about the igt-dev mailing list