[Intel-gfx] [igt-dev] [PATCH i-g-t] tests/gem_shrink: Exercise OOM and other routes to shrinking in reasonable time

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Mon Jan 7 12:52:28 UTC 2019


On 07/01/2019 12:31, Chris Wilson wrote:
> Quoting MichaƂ Winiarski (2019-01-07 12:27:07)
>> On Fri, Jan 04, 2019 at 03:37:09PM +0000, Tvrtko Ursulin wrote:
>>> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>>>
>>> A set of subtests which exercises different paths to our shrinker code
>>> (including the OOM killer) in predictable and reasonable time budget.
>>>
>>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>>> ---
>>>   lib/igt_core.c                        |  19 ++
>>>   lib/igt_core.h                        |   1 +
>>>   tests/i915/gem_shrink.c               | 399 ++++++++++++++++++++++++++
>>>   tests/intel-ci/blacklist.txt          |   1 +
>>>   tests/intel-ci/fast-feedback.testlist |   3 +
>>>   5 files changed, 423 insertions(+)
>>
>> [snip]
>>
>>> diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
>>> index c8e05814ee70..7c002de0ef1f 100644
>>> --- a/tests/i915/gem_shrink.c
>>> +++ b/tests/i915/gem_shrink.c
>>> @@ -26,6 +26,10 @@
>>>    *
>>>    * Exercise the shrinker by overallocating GEM objects
>>>    */
>>> +#include <sys/types.h>
>>> +#include <sys/stat.h>
>>> +#include <sys/wait.h>
>>> +#include <fcntl.h>
>>>   
>>>   #include "igt.h"
>>>   #include "igt_gt.h"
>>> @@ -366,6 +370,376 @@ static void reclaim(unsigned engine, int timeout)
>>>        close(fd);
>>>   }
>>>   
>>> +static unsigned long get_meminfo(const char *info, const char *tag)
>>> +{
>>> +     const char *str;
>>> +     unsigned long val;
>>> +
>>> +     str = strstr(info, tag);
>>> +     if (str && sscanf(str + strlen(tag), " %lu", &val) == 1)
>>> +             return val >> 10;
>>> +
>>> +     igt_warn("Unrecognised /proc/meminfo field: '%s'\n", tag);
>>> +     return 0;
>>> +}
>>> +
>>> +static unsigned long get_avail_ram_mb(void)
>>> +{
>>> +     int fd;
>>> +     int ret;
>>> +     char buf[4096];
>>> +     unsigned long ram;
>>> +
>>> +     fd = open("/proc/meminfo", O_RDONLY);
>>> +     igt_assert_fd(fd);
>>> +
>>> +     ret = read(fd, buf, sizeof(buf));
>>> +     igt_assert(ret >= 0);
>>> +
>>> +     close(fd);
>>> +
>>> +     ram = get_meminfo(buf, "MemAvailable:");
>>> +     ram += get_meminfo(buf, "Buffers:");
>>> +     ram += get_meminfo(buf, "Cached:");
>>> +     ram += get_meminfo(buf, "SwapCached:");
>>> +
>>> +     return ram;
>>> +}
>>
>> What's wrong with ones from intel_os.c?
> 
> They pull in both an i915 and mm purge, which iirc, had to be avoided
> here.

Yep. I can sense a suggestion of adding a lighter weight version to the 
library now.. :)

Regards,

Tvrtko


More information about the Intel-gfx mailing list