[igt-dev] [PATCH i-g-t v28 29/36] tests/api_intel_allocator: Verify child can use its standalone allocator
From: Zbigniew Kempczyński <hidden>
Date: 2021-03-22 12:38:37
Subsystem:
the rest · Maintainer:
Linus Torvalds
Sometimes we don't want to use common allocator provided by main IGT process. Verify it is able to "detach" from it and initialize its own version of allocator. Signed-off-by: Zbigniew Kempczyński <redacted> Cc: Chris Wilson <redacted> Acked-by: Daniel Vetter <redacted> --- tests/i915/api_intel_allocator.c | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index 16c75b388..bb17c8829 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c@@ -282,6 +282,45 @@ static void parallel_one(int fd, uint8_t type) igt_assert_eq(intel_allocator_close(ahnd), true); } +static void standalone(int fd) +{ + uint64_t ahnd, offset, size = 4096; + uint32_t handle = 1, child_handle = 2; + uint64_t *shared; + + shared = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); + + intel_allocator_multiprocess_start(); + + ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE); + offset = intel_allocator_alloc(ahnd, handle, size, 0); + + igt_fork(child, 2) { + /* + * Use standalone allocator for child 1, detach from parent, + * child 2 use allocator from parent. + */ + if (child == 1) + intel_allocator_init(); + + ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE); + shared[child] = intel_allocator_alloc(ahnd, child_handle, size, 0); + + intel_allocator_free(ahnd, child_handle); + intel_allocator_close(ahnd); + } + igt_waitchildren(); + igt_assert_eq(offset, shared[1]); + igt_assert_neq(offset, shared[2]); + + intel_allocator_free(ahnd, handle); + igt_assert_eq(intel_allocator_close(ahnd), true); + + intel_allocator_multiprocess_stop(); + + munmap(shared, 4096); +} + #define SIMPLE_GROUP_ALLOCS 8 static void __simple_allocs(int fd) {
@@ -620,6 +659,9 @@ igt_main } } + igt_subtest_f("standalone") + standalone(fd); + igt_subtest_f("fork-simple-once") fork_simple_once(fd);
--
2.26.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev