mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-24 00:06:09 +00:00
Factor in kernel object overhead when checking available memory for tests
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
e4ba3b75e6
commit
321273ff76
@ -77,4 +77,8 @@ uint64_t intel_get_avail_ram_mb(void);
|
|||||||
uint64_t intel_get_total_ram_mb(void);
|
uint64_t intel_get_total_ram_mb(void);
|
||||||
uint64_t intel_get_total_swap_mb(void);
|
uint64_t intel_get_total_swap_mb(void);
|
||||||
|
|
||||||
|
bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode);
|
||||||
|
#define CHECK_RAM 0x1
|
||||||
|
#define CHECK_SWAP 0x2
|
||||||
|
|
||||||
#endif /* IGT_AUX_H */
|
#endif /* IGT_AUX_H */
|
||||||
|
@ -185,6 +185,36 @@ intel_get_total_swap_mb(void)
|
|||||||
return retval / (1024*1024);
|
return retval / (1024*1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode)
|
||||||
|
{
|
||||||
|
/* rough estimate of how many bytes the kernel requires to track each object */
|
||||||
|
#define KERNEL_BO_OVERHEAD 512
|
||||||
|
uint64_t required, total;
|
||||||
|
|
||||||
|
required = count;
|
||||||
|
required *= size + KERNEL_BO_OVERHEAD;
|
||||||
|
required = ALIGN(required, 4096);
|
||||||
|
|
||||||
|
total = 0;
|
||||||
|
if (mode & (CHECK_RAM | CHECK_SWAP))
|
||||||
|
total += intel_get_avail_ram_mb();
|
||||||
|
if (mode & CHECK_SWAP)
|
||||||
|
total += intel_get_total_swap_mb();
|
||||||
|
total *= 1024 * 1024;
|
||||||
|
|
||||||
|
if (total <= required) {
|
||||||
|
igt_log(IGT_LOG_INFO,
|
||||||
|
"Estimated that we need %llu bytes for the test, but only have %llu bytes available (%s%s)\n",
|
||||||
|
(long long)required, (long long)total,
|
||||||
|
mode & CHECK_RAM ? "RAM" : "",
|
||||||
|
mode & CHECK_SWAP ? " + swap": "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
intel_purge_vm_caches(void)
|
intel_purge_vm_caches(void)
|
||||||
{
|
{
|
||||||
|
@ -106,8 +106,7 @@ static int major_evictions(int fd, struct igt_eviction_test_ops *ops,
|
|||||||
int n, m, loop;
|
int n, m, loop;
|
||||||
uint32_t *bo;
|
uint32_t *bo;
|
||||||
|
|
||||||
igt_require((uint64_t)nr_surfaces * surface_size / (1024 * 1024)
|
igt_require(intel_check_memory(nr_surfaces, surface_size, CHECK_RAM));
|
||||||
< intel_get_total_ram_mb() * 9 / 10);
|
|
||||||
|
|
||||||
bo = malloc(nr_surfaces*sizeof(*bo));
|
bo = malloc(nr_surfaces*sizeof(*bo));
|
||||||
igt_assert(bo);
|
igt_assert(bo);
|
||||||
@ -135,12 +134,13 @@ static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
|
|||||||
uint32_t *bo;
|
uint32_t *bo;
|
||||||
int i, n, pass;
|
int i, n, pass;
|
||||||
|
|
||||||
igt_require((uint64_t)working_surfaces * surface_size / (1024 * 1024)
|
igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
|
||||||
< intel_get_total_ram_mb() * 9 / 10);
|
|
||||||
|
|
||||||
if (trash_surfaces < working_surfaces)
|
if (trash_surfaces < working_surfaces)
|
||||||
trash_surfaces = working_surfaces;
|
trash_surfaces = working_surfaces;
|
||||||
|
|
||||||
|
igt_require(intel_check_memory(trash_surfaces, surface_size, CHECK_RAM | CHECK_SWAP));
|
||||||
|
|
||||||
bo = malloc(trash_surfaces*sizeof(*bo));
|
bo = malloc(trash_surfaces*sizeof(*bo));
|
||||||
igt_assert(bo);
|
igt_assert(bo);
|
||||||
|
|
||||||
@ -173,19 +173,18 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
|
|||||||
int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
|
int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
int bo_count;
|
int bo_count;
|
||||||
|
|
||||||
igt_require((uint64_t)working_surfaces * surface_size / (1024 * 1024)
|
igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
|
||||||
< intel_get_total_ram_mb() * 9 / 10);
|
|
||||||
|
|
||||||
if (flags & FORKING_EVICTIONS_SWAPPING) {
|
if (flags & FORKING_EVICTIONS_SWAPPING) {
|
||||||
igt_require(intel_get_total_ram_mb() / 4
|
|
||||||
< intel_get_total_swap_mb());
|
|
||||||
bo_count = trash_surfaces;
|
bo_count = trash_surfaces;
|
||||||
|
|
||||||
if (bo_count < working_surfaces)
|
if (bo_count < working_surfaces)
|
||||||
bo_count = working_surfaces;
|
bo_count = working_surfaces;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
bo_count = working_surfaces;
|
bo_count = working_surfaces;
|
||||||
|
|
||||||
|
igt_require(intel_check_memory(bo_count, surface_size, CHECK_RAM | CHECK_SWAP));
|
||||||
|
|
||||||
bo = malloc(bo_count*sizeof(*bo));
|
bo = malloc(bo_count*sizeof(*bo));
|
||||||
igt_assert(bo);
|
igt_assert(bo);
|
||||||
|
|
||||||
|
@ -150,6 +150,7 @@ static void test_forking_evictions(int fd, int size, int count,
|
|||||||
int trash_count;
|
int trash_count;
|
||||||
|
|
||||||
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
||||||
|
igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
|
||||||
|
|
||||||
forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
|
forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
|
||||||
}
|
}
|
||||||
@ -158,9 +159,8 @@ static void test_swapping_evictions(int fd, int size, int count)
|
|||||||
{
|
{
|
||||||
int trash_count;
|
int trash_count;
|
||||||
|
|
||||||
igt_require(intel_get_total_ram_mb() / 4 < intel_get_total_swap_mb());
|
|
||||||
|
|
||||||
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
||||||
|
igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
|
||||||
|
|
||||||
swapping_evictions(fd, &fault_ops, size, count, trash_count);
|
swapping_evictions(fd, &fault_ops, size, count, trash_count);
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,7 @@ igt_simple_main
|
|||||||
(long)intel_get_avail_ram_mb(),
|
(long)intel_get_avail_ram_mb(),
|
||||||
(long)intel_get_total_ram_mb(),
|
(long)intel_get_total_ram_mb(),
|
||||||
(long)intel_get_total_swap_mb());
|
(long)intel_get_total_swap_mb());
|
||||||
|
igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP));
|
||||||
igt_require(count < intel_get_avail_ram_mb() + intel_get_total_swap_mb());
|
|
||||||
|
|
||||||
for (n = 0; n < count; n++) {
|
for (n = 0; n < count; n++) {
|
||||||
bo_handles[n] = create_bo_and_fill(fd);
|
bo_handles[n] = create_bo_and_fill(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user