tests/gem_userptr_blits: Expanded userptr test cases
PATCH 1/1 tests/gem_userptr_blits: Expanded userptr test cases
From: Tvrtko Ursulin <[email protected]>
A set of userptr test cases to support the new feature.
For the eviction and swapping stress testing I have extracted some common behaviour from gem_evict_everything and made both test cases use it to avoid duplicating the code.
Both unsynchronized and synchronized userptr objects are tested but the latter set of tests will be skipped if kernel is compiled without MMU_NOTIFIERS.
Also, with 32-bit userspace swapping tests are skipped if the system has a lot more RAM than process address space. Forking swapping tests are not skipped since they can still trigger swapping by cumulative effect.
Tested with userptr v14 on Android (with some swap added).
--- lib/drmtest.c | 185 +++++++++ lib/drmtest.h | 32 ++ tests/.gitignore | 2 +- tests/Makefile.sources | 2 +- tests/gem_evict_everything.c | 182 ++------- tests/gem_userptr_blits.c | 869 +++++++++++++++++++++++++++++++++++++++++++ tests/gem_vmap_blits.c | 344 ----------------- 7 files changed, 1114 insertions(+), 502 deletions(-) create mode 100644 tests/gem_userptr_blits.c delete mode 100644 tests/gem_vmap_blits.c
lib/drmtest.c +185 -0
@@ -1685,3 +1685,188 @@ void igt_drop_root(void)igt_assert (getgid () ==2 );igt_assert (getuid () ==2 ); } + +static void igt_exchange_uint32_t (void *array,unsigned i,unsigned j) +{ +uint32_t *i_arr = array; +uint32_t i_tmp; + + i_tmp = i_arr[i]; + i_arr[i] = i_arr[j]; + i_arr[j] = i_tmp; +} + +int igt_minor_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int nr_surfaces) +{ +uint32_t *bo, *sel; +int n, m, pass, fail; + +igt_require ((uint64_t )nr_surfaces * surface_size / (1024 *1024 ) + <intel_get_total_ram_mb () *9 /10 ); + + bo =malloc (3 *nr_surfaces*sizeof (*bo)); +igt_assert (bo); + +for (n =0 ; n <2 *nr_surfaces; n++) + bo[n] = ops->create (fd, surface_size); + + sel = bo + n; +for (fail =0 , m =0 ; fail <10 ; fail++) { +for (pass =0 ; pass <100 ; pass++) { +for (n =0 ; n < nr_surfaces; n++, m +=7 ) + sel[n] = bo[m%(2 *nr_surfaces)]; + ops->copy (fd, sel[0 ], sel[1 ], sel, nr_surfaces,0 ); + } + ops->copy (fd, bo[0 ], bo[0 ], bo,2 *nr_surfaces,ENOSPC ); + } + +for (n =0 ; n <2 *nr_surfaces; n++) + ops->close (fd, bo[n]); +free (bo); + +return 0 ; +} + +int igt_major_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int nr_surfaces) +{ +int n, m, loop; +uint32_t *bo; + +igt_require ((uint64_t )nr_surfaces * surface_size / (1024 *1024 ) + <intel_get_total_ram_mb () *9 /10 ); + + bo =malloc (nr_surfaces*sizeof (*bo)); +igt_assert (bo); + +for (n =0 ; n < nr_surfaces; n++) + bo[n] = ops->create (fd, surface_size); + +for (loop =0 , m =0 ; loop <100 ; loop++, m +=17 ) { + n = m % nr_surfaces; + ops->copy (fd, bo[n], bo[n], &bo[n],1 ,0 ); + } + +for (n =0 ; n < nr_surfaces; n++) + ops->close (fd, bo[n]); +free (bo); + +return 0 ; +} + +int igt_swapping_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size, +int working_surfaces, +int trash_surfaces) +{ +uint32_t *bo; +int i, n, pass; + +igt_require ((uint64_t )working_surfaces * surface_size / (1024 *1024 ) + <intel_get_total_ram_mb () *9 /10 ); + +if (trash_surfaces < working_surfaces) + trash_surfaces = working_surfaces; + + bo =malloc (trash_surfaces*sizeof (*bo)); +igt_assert (bo); + +for (n =0 ; n < trash_surfaces; n++) + bo[n] = ops->create (fd, surface_size); + +for (i =0 ; i < trash_surfaces/32 ; i++) { +igt_permute_array (bo, trash_surfaces, igt_exchange_uint32_t); + +for (pass =0 ; pass <100 ; pass++) { + ops->copy (fd, bo[0 ], bo[1 ], bo, working_surfaces,0 ); + } + } + +for (n =0 ; n < trash_surfaces; n++) + ops->close (fd, bo[n]); +free (bo); + +return 0 ; +} + +#define min (a, b) ((a) < (b) ? (a) : (b)) + +int igt_forking_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int working_surfaces, +int trash_surfaces,unsigned flags) +{ +uint32_t *bo; +int n, pass, l; +int num_threads =sysconf (_SC_NPROCESSORS_ONLN); +int bo_count; + +igt_require ((uint64_t )working_surfaces * surface_size / (1024 *1024 ) + <intel_get_total_ram_mb () *9 /10 ); + +if (flags &FORKING_EVICTIONS_SWAPPING ) { +igt_require (intel_get_total_ram_mb () /4 + <intel_get_total_swap_mb ()); + bo_count = trash_surfaces; + +if (bo_count < working_surfaces) + bo_count = working_surfaces; + }else + bo_count = working_surfaces; + + bo =malloc (bo_count*sizeof (*bo)); +igt_assert (bo); + +for (n =0 ; n < bo_count; n++) + bo[n] = ops->create (fd, surface_size); + + igt_fork(i, min(num_threads * 4, 12)) { +int realfd = fd; +int num_passes = flags &FORKING_EVICTIONS_SWAPPING ?10 :100 ; + +/* Every fork should have a different permutation! */ +srand (i *63 ); + +if (flags &FORKING_EVICTIONS_INTERRUPTIBLE ) +igt_fork_signal_helper (); + +igt_permute_array (bo, bo_count, igt_exchange_uint32_t); + +if (flags &FORKING_EVICTIONS_DUP_DRMFD ) { + realfd =drm_open_any (); + +/* We can overwrite the bo array since we're forked. */ +for (l =0 ; l < bo_count; l++) { +uint32_t flink; + + flink =gem_flink (fd, bo[l]); + bo[l] =gem_open (realfd, flink); + } + } + +for (pass =0 ; pass < num_passes; pass++) { + ops->copy (realfd, bo[0 ], bo[1 ], bo, working_surfaces,0 ); + +for (l =0 ; l < working_surfaces && + (flags &FORKING_EVICTIONS_MEMORY_PRESSURE ); + l++) { + ops->clear (realfd, bo[l], surface_size); + } + } + +if (flags &FORKING_EVICTIONS_INTERRUPTIBLE ) +igt_stop_signal_helper (); + +/* drmfd closing will take care of additional bo refs */ +if (flags &FORKING_EVICTIONS_DUP_DRMFD ) +close (realfd); + } + +igt_waitchildren (); + +for (n =0 ; n < bo_count; n++) + ops->close (fd, bo[n]); +free (bo); + +return 0 ; +}
lib/drmtest.h +32 -0
@@ -361,4 +361,36 @@ void igt_system_suspend_autoresume(void);/* dropping priviledges */ void igt_drop_root (void ); +struct igt_eviction_test_ops +{ +uint32_t (*create)(int fd,int size); +void (*close)(int fd,uint32_t bo); +void (*copy)(int fd,uint32_t dst,uint32_t src, +uint32_t *all_bo,int nr_bos,int error); +void (*clear)(int fd,uint32_t bo,int size); +}; + +int igt_minor_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int nr_surfaces); + +int igt_major_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int nr_surfaces); + +int igt_swapping_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int working_surfaces, +int trash_surfaces); + +#define FORKING_EVICTIONS_INTERRUPTIBLE (1 << 0) +#define FORKING_EVICTIONS_SWAPPING (1 << 1) +#define FORKING_EVICTIONS_DUP_DRMFD (1 << 2) +#define FORKING_EVICTIONS_MEMORY_PRESSURE (1 << 3) +#define ALL_FORKING_EVICTIONS (FORKING_EVICTIONS_INTERRUPTIBLE | \ + FORKING_EVICTIONS_SWAPPING | \ + FORKING_EVICTIONS_DUP_DRMFD | \ + FORKING_EVICTIONS_MEMORY_PRESSURE) + +int igt_forking_evictions (int fd,struct igt_eviction_test_ops *ops, +int surface_size,int working_surfaces, +int trash_surfaces,unsigned flags); +#endif /* DRMTEST_H */
tests/.gitignore +1 -1
@@ -91,7 +91,7 @@ gem_tiled_swapping gem_tiling_max_stride gem_unfence_active_buffers gem_unref_active_buffers -gem_vmap_blits +gem_userptr_blits gem_wait_render_timeout gem_write_read_ring_switch gen3_mixed_blits
tests/Makefile.sources +1 -1
@@ -115,7 +115,7 @@ TESTS_progs = \ gem_tiling_max_stride \ gem_unfence_active_buffers \ gem_unref_active_buffers \ - gem_vmap_blits \ + gem_userptr_blits \ gem_wait_render_timeout \ gen3_mixed_blits \ gen3_render_linear_blits \
tests/gem_evict_everything.c +26 -156
221 lines not on this page · raw message
tests/gem_userptr_blits.c new file +869 -0
869 lines not on this page · raw message
tests/gem_vmap_blits.c deleted +0 -344
344 lines not on this page · raw message
Signature · 6 lines
1.8.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
A set of userptr test cases to support the new feature.
There's just a couple of interface tests I'd like added.
1. Overlapping objects are not allowed (if sync)
2. a mmap() arena containing multiple objects invaldates all i.e. (if sync)
ptr = mmap(fd, 4 * OBJECT_SIZE);
for (i = 0; i < 4; i++)
bo[i] = userptr(ptr + i * OBJECT_SIZE, OBJECT_SIZE) blit(bo[i]);munmap(ptr, 4 * OBJECT_SIZE); /* can do subranges if evil! */ for (i = 0; i < 4; i++)
blit(bo[i]) == EFAULT
Otherwise this has been a very useful testcase. Many, many thanks. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
A set of userptr test cases to support the new feature.
Oh, and another thing...
I guess we will want some benchmarks for mmu_notifier scaling since tracking the performance implications seems important. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 9 lines · Chris Wilson
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
A set of userptr test cases to support the new feature.
Oh, and another thing...
I guess we will want some benchmarks for
mmu_notifierscaling since tracking the performance implications seems important.
What would be a realistic benchmark? My first thoughts were something like:
for each [unsync, sync]
for each N [1, 10, 100, 1000]
create N userptr bos
benchmark for T seconds: malloc/realloc/free benchmark for T seconds: mmap/unmap ???
Add this as tests/gem_userptr_benchmark ?
Tvrtko
Quoted 9 lines · Tvrtko Ursulin
Quoted 7 lines · Chris Wilson
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
A set of userptr test cases to support the new feature.
Oh, and another thing...
Quoted 7 lines
Quoted 2 lines
I guess we will want some benchmarks for
mmu_notifierscaling since tracking the performance implications seems important.What would be a realistic benchmark? My first thoughts were something like:
for each [unsync, sync]
for each N [1, 10, 100, 1000]
Also zero userptr objects of course!
Quoted 4 lines
create N userptr bos
benchmark for T seconds: malloc/realloc/free benchmark for T seconds: mmap/unmap ???
+ benchmark for T seconds: normal bo create/destroy
+ benchmark for T seconds: userptr bo create/destroy
Tvrtko
Quoted 5 lines · Tvrtko Ursulin
Quoted 3 lines · Chris Wilson
Quoted 2 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
A set of userptr test cases to support the new feature.
Oh, and another thing...
I guess we will want some benchmarks for
mmu_notifierscaling since tracking the performance implications seems important.What would be a realistic benchmark? My first thoughts were something like:
Here we can be purely synthetic. :)
Have a broad scope of lots of little tests so that we can detect changes easily and later correlate those with realworld measurements.
Quoted 6 lines
for each [unsync, sync]
for each N [1, 10, 100, 1000]
create N userptr bos
benchmark for T seconds: malloc/realloc/free benchmark for T seconds: mmap/unmap ???
Yes, that will check that creating our userptr bo does not impact on the rest of system/application performance.
I think we also want basic measurement of load, so
(mmap, create bo, [blit,] munmap) x N
mmap region, create N bo, [blit,] munmap region
and a bit of random order vs sequential
Double checking that speed of pointer access is not affected by creating a userptr bo is also a good idea.
Quoted 1 line
Add this as tests/gem_userptr_benchmark ?
Yes. This may be something that Akash would like to contribute ideas to...
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre