[PATCH libdrm v2] amdgpu: Add memory over allocation test.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 14.11.2017 um 13:53 schrieb Andrey Grodzovsky:
>
>
> On 11/14/2017 03:44 AM, Christian König wrote:
>> Am 13.11.2017 um 18:01 schrieb Andrey Grodzovsky:
>>> Allocates 1 TB of memory. Test is disabled by default
>>> since it's triggers OOM killer.
>>>
>>> v2:
>>> FIx the test to only alloc the BO and assert if return value
>>> not equal to -ENOMEM and remove test disable on start.
>>>
>>> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
>>
>> I was just about to scream that you need to fix the helper first, but 
>> then I saw that you now directly use amdgpu_bo_alloc().
>>
>> The commit message could be changed and for the unlikely case that we 
>> actually can allocate a BO of 1TB size we should free it.
>
> The patch already does this
>
> if (!r) {
>         r = amdgpu_bo_free(bo);
>         CU_ASSERT_EQUAL(r, 0);
>     }

Not enough sleep last night.

Going to review and push the patch now.

Thanks,
Christian.

>
>
> Thanks,
> Andrey
>
>>
>> But apart from that the patch looks good to me and is Acked-by: 
>> Christian König <christian.koenig at amd.com>.
>>
>> Regards,
>> Christian.
>>
>>> ---
>>>   tests/amdgpu/bo_tests.c | 24 ++++++++++++++++++++++++
>>>   1 file changed, 24 insertions(+)
>>>
>>> diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
>>> index 4545196..53e76c1 100644
>>> --- a/tests/amdgpu/bo_tests.c
>>> +++ b/tests/amdgpu/bo_tests.c
>>> @@ -47,6 +47,7 @@ static void amdgpu_bo_export_import(void);
>>>   static void amdgpu_bo_metadata(void);
>>>   static void amdgpu_bo_map_unmap(void);
>>>   static void amdgpu_memory_alloc(void);
>>> +static void amdgpu_mem_fail_alloc(void);
>>>     CU_TestInfo bo_tests[] = {
>>>       { "Export/Import",  amdgpu_bo_export_import },
>>> @@ -55,6 +56,7 @@ CU_TestInfo bo_tests[] = {
>>>   #endif
>>>       { "CPU map/unmap",  amdgpu_bo_map_unmap },
>>>       { "Memory alloc Test",  amdgpu_memory_alloc },
>>> +    { "Memory fail alloc Test",  amdgpu_mem_fail_alloc },
>>>       CU_TEST_INFO_NULL,
>>>   };
>>>   @@ -244,3 +246,25 @@ static void amdgpu_memory_alloc(void)
>>>       r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
>>>       CU_ASSERT_EQUAL(r, 0);
>>>   }
>>> +
>>> +static void amdgpu_mem_fail_alloc(void)
>>> +{
>>> +    amdgpu_bo_handle bo;
>>> +    int r;
>>> +    struct amdgpu_bo_alloc_request req = {0};
>>> +    amdgpu_bo_handle buf_handle;
>>> +
>>> +    /* Test impossible mem allocation, 1TB */
>>> +    req.alloc_size = 0xE8D4A51000;
>>> +    req.phys_alignment = 4096;
>>> +    req.preferred_heap = AMDGPU_GEM_DOMAIN_VRAM;
>>> +    req.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
>>> +
>>> +    r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
>>> +    CU_ASSERT_EQUAL(r, -ENOMEM);
>>> +
>>> +    if (!r) {
>>> +        r = amdgpu_bo_free(bo);
>>> +        CU_ASSERT_EQUAL(r, 0);
>>> +    }
>>> +}
>>
>>
>



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux