mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 01:46:14 +00:00
lib/os: Pust igt_require into memory check function
More in line with the usual igt pattern and simplifies the code - every called just wrapped it in igt_require. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
This commit is contained in:
parent
aa63fc740c
commit
a535cdedfb
@ -82,7 +82,7 @@ uint64_t intel_get_avail_ram_mb(void);
|
||||
uint64_t intel_get_total_ram_mb(void);
|
||||
uint64_t intel_get_total_swap_mb(void);
|
||||
|
||||
bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode);
|
||||
void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
|
||||
#define CHECK_RAM 0x1
|
||||
#define CHECK_SWAP 0x2
|
||||
|
||||
|
@ -193,7 +193,7 @@ intel_get_total_swap_mb(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* intel_check_memory:
|
||||
* intel_require_memory:
|
||||
* @count: number of surfaces that will be created
|
||||
* @size: the size in bytes of each surface
|
||||
* @mode: a bitfield declaring whether the test will be run in RAM or in SWAP
|
||||
@ -209,11 +209,10 @@ intel_get_total_swap_mb(void)
|
||||
* for their tests. oom-killer tests should only run if this reports that
|
||||
* there is not enough RAM + SWAP!
|
||||
*
|
||||
* Returns:
|
||||
* Whether the estimated amount of memory required for the objects
|
||||
* fits in the available memory on the system.
|
||||
* If there is not enough RAM this function calls igt_skip with an appropriate
|
||||
* message. It only ever returns if the requirement is fullfilled.
|
||||
*/
|
||||
bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode)
|
||||
void intel_require_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
|
||||
@ -235,19 +234,13 @@ bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode)
|
||||
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 | CHECK_SWAP) ? "RAM" : "",
|
||||
mode & CHECK_SWAP ? " + swap": "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
igt_skip_on_f(total <= required,
|
||||
"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 | CHECK_SWAP) ? "RAM" : "",
|
||||
mode & CHECK_SWAP ? " + swap": "");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
intel_purge_vm_caches(void)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||
|
||||
total_surfaces = gem_aperture_size(fd) / surface_size + 1;
|
||||
igt_require(nr_surfaces < total_surfaces);
|
||||
igt_require(intel_check_memory(total_surfaces, surface_size, CHECK_RAM));
|
||||
intel_require_memory(total_surfaces, surface_size, CHECK_RAM);
|
||||
|
||||
bo = malloc((nr_surfaces + total_surfaces)*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
@ -112,7 +112,7 @@ static int major_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||
uint32_t *bo;
|
||||
int ret;
|
||||
|
||||
igt_require(intel_check_memory(nr_surfaces, surface_size, CHECK_RAM));
|
||||
intel_require_memory(nr_surfaces, surface_size, CHECK_RAM);
|
||||
|
||||
bo = malloc(nr_surfaces*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
@ -141,12 +141,12 @@ static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||
uint32_t *bo;
|
||||
int i, n, pass, ret;
|
||||
|
||||
igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
|
||||
intel_require_memory(working_surfaces, surface_size, CHECK_RAM);
|
||||
|
||||
if (trash_surfaces < working_surfaces)
|
||||
trash_surfaces = working_surfaces;
|
||||
|
||||
igt_require(intel_check_memory(trash_surfaces, surface_size, CHECK_RAM | CHECK_SWAP));
|
||||
intel_require_memory(trash_surfaces, surface_size, CHECK_RAM | CHECK_SWAP);
|
||||
|
||||
bo = malloc(trash_surfaces*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
@ -179,7 +179,7 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||
int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
int bo_count;
|
||||
|
||||
igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
|
||||
intel_require_memory(working_surfaces, surface_size, CHECK_RAM);
|
||||
|
||||
if (flags & FORKING_EVICTIONS_SWAPPING) {
|
||||
bo_count = trash_surfaces;
|
||||
@ -190,7 +190,7 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||
bo_count = working_surfaces;
|
||||
|
||||
igt_assert(working_surfaces <= bo_count);
|
||||
igt_require(intel_check_memory(bo_count, surface_size, CHECK_RAM | CHECK_SWAP));
|
||||
intel_require_memory(bo_count, surface_size, CHECK_RAM | CHECK_SWAP);
|
||||
|
||||
bo = malloc(bo_count*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
|
@ -183,7 +183,7 @@ igt_simple_main
|
||||
if (igt_run_in_simulation())
|
||||
count = 10;
|
||||
|
||||
igt_require(intel_check_memory(1+count, 4096, CHECK_RAM));
|
||||
intel_require_memory(1+count, 4096, CHECK_RAM);
|
||||
|
||||
handles = malloc (count * sizeof(uint32_t));
|
||||
igt_assert(handles);
|
||||
|
@ -134,7 +134,7 @@ static void minor_evictions(int fd, int size, int count)
|
||||
uint32_t *bo, *sel;
|
||||
int n, m, alignment, pass, fail;
|
||||
|
||||
igt_require(intel_check_memory(2*count, size, CHECK_RAM));
|
||||
intel_require_memory(2 * count, size, CHECK_RAM);
|
||||
|
||||
bo = malloc(3*count*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
@ -164,7 +164,7 @@ static void major_evictions(int fd, int size, int count)
|
||||
int n, m, loop, alignment, max;
|
||||
uint32_t *bo;
|
||||
|
||||
igt_require(intel_check_memory(count, size, CHECK_RAM));
|
||||
intel_require_memory(count, size, CHECK_RAM);
|
||||
|
||||
bo = malloc(count*sizeof(*bo));
|
||||
igt_assert(bo);
|
||||
|
@ -151,7 +151,7 @@ static void test_forking_evictions(int fd, int size, int count,
|
||||
int trash_count;
|
||||
|
||||
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
||||
igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
|
||||
intel_require_memory(trash_count, size, CHECK_RAM | CHECK_SWAP);
|
||||
|
||||
forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
|
||||
}
|
||||
@ -161,7 +161,7 @@ static void test_swapping_evictions(int fd, int size, int count)
|
||||
int trash_count;
|
||||
|
||||
trash_count = intel_get_total_ram_mb() * 11 / 10;
|
||||
igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
|
||||
intel_require_memory(trash_count, size, CHECK_RAM | CHECK_SWAP);
|
||||
|
||||
swapping_evictions(fd, &fault_ops, size, count, trash_count);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ int main(int argc, char **argv)
|
||||
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
igt_require(count > 1);
|
||||
igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
|
||||
intel_require_memory(count, sizeof(linear), CHECK_RAM);
|
||||
run_test(fd, count);
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ int main(int argc, char **argv)
|
||||
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
igt_require(count > 1);
|
||||
igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
|
||||
intel_require_memory(count, sizeof(linear), CHECK_RAM);
|
||||
igt_fork_signal_helper();
|
||||
run_test(fd, count);
|
||||
igt_stop_signal_helper();
|
||||
|
@ -218,7 +218,7 @@ int main(int argc, char **argv)
|
||||
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
count += (count & 1) == 0;
|
||||
igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM));
|
||||
intel_require_memory(count, 1024*1024, CHECK_RAM);
|
||||
|
||||
run_test(count);
|
||||
}
|
||||
@ -230,7 +230,7 @@ int main(int argc, char **argv)
|
||||
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
count += (count & 1) == 0;
|
||||
igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM));
|
||||
intel_require_memory(count, 1024*1024, CHECK_RAM);
|
||||
|
||||
igt_fork_signal_helper();
|
||||
run_test(count);
|
||||
|
@ -169,7 +169,7 @@ igt_simple_main
|
||||
(long)intel_get_avail_ram_mb(),
|
||||
(long)intel_get_total_ram_mb(),
|
||||
(long)intel_get_total_swap_mb());
|
||||
igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP));
|
||||
intel_require_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP);
|
||||
|
||||
for (n = 0; n < count; n++) {
|
||||
bo_handles[n] = create_bo_and_fill(fd);
|
||||
|
@ -891,7 +891,7 @@ static int test_coherency(int fd, int count)
|
||||
uint32_t start = 0;
|
||||
int i, ret;
|
||||
|
||||
igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
|
||||
intel_require_memory(count, sizeof(linear), CHECK_RAM);
|
||||
igt_info("Using 2x%d 1MiB buffers\n", count);
|
||||
|
||||
ret = posix_memalign((void **)&memory, PAGE_SIZE, count*sizeof(linear));
|
||||
|
Loading…
x
Reference in New Issue
Block a user