igt_dummyload: Add preemptible parameter to spinning batch.
PATCH 1/3 igt_dummyload: Add preemptible parameter to spinning batch.
The recursive batch emitted in the dummyload library is always pre-emptible. This patch adds a parameter to make it conditionally pre-emptible. The batch can now be used in tests where we still want a spinning batch while not being able to preempt it.
Note: The behavior preceding this patch has been kept. All the places that used a spin batch are still using a pre-emptible spin batch.
--- lib/igt_dummyload.c | 18 +++++++++++------- lib/igt_dummyload.h | 6 ++++-- tests/drv_missed_irq.c | 2 +- tests/gem_busy.c | 4 ++-- tests/gem_exec_fence.c | 14 +++++++------- tests/gem_exec_latency.c | 2 +- tests/gem_exec_nop.c | 2 +- tests/gem_exec_reloc.c | 8 +++++--- tests/gem_exec_schedule.c | 8 ++++---- tests/gem_exec_suspend.c | 2 +- tests/gem_shrink.c | 4 ++-- tests/gem_spin_batch.c | 4 ++-- tests/gem_sync.c | 3 ++- tests/gem_wait.c | 2 +- tests/kms_busy.c | 6 +++--- tests/kms_cursor_legacy.c | 5 +++-- tests/kms_flip.c | 4 ++-- tests/perf_pmu.c | 20 ++++++++++---------- tests/pm_rps.c | 2 +- 19 files changed, 63 insertions(+), 53 deletions(-)
lib/igt_dummyload.c +11 -7
@@ -71,7 +71,7 @@ fill_reloc(struct drm_i915_gem_relocation_entry *reloc,static void emit_recursive_batch (igt_spin_t *spin,int fd,uint32_t ctx,unsigned engine, -uint32_t dep) +uint32_t dep,bool preemptible) {#define SCRATCH 0#define BATCH 1
@@ -122,8 +122,8 @@ static void emit_recursive_batch(igt_spin_t *spin, spin->batch = batch; spin->handle = obj[BATCH ].handle; -/* Allow ourselves to be preempted */ - *batch++ =MI_ARB_CHK ; +if (preemptible) + *batch++ =MI_ARB_CHK ;/* Allow ourselves to be preempted */ /* Pad with a few nops so that we do not completely hog the system. *
@@ -172,14 +172,15 @@ static void emit_recursive_batch(igt_spin_t *spin, }igt_spin_t * -__igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine,uint32_t dep) +__igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine, +uint32_t dep,bool preemptible) {igt_spin_t *spin; spin =calloc (1 ,sizeof (struct igt_spin ));igt_assert (spin); -emit_recursive_batch (spin, fd, ctx, engine, dep); +emit_recursive_batch (spin, fd, ctx, engine, dep, preemptible);igt_assert (gem_bo_busy (fd, spin->handle));igt_list_add (&spin->link, &spin_list);
@@ -194,6 +195,8 @@ __igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)* than 0, execute on all available rings. * @dep: handle to a buffer object dependency. If greater than 0, add a * relocation entry to this buffer within the batch. +* @preemptible: Whether spinning batch would execute a preemtible instruction +* or not. * * Start a recursive batch on a ring. Immediately returns a #igt_spin_t that * contains the batch's handle that can be waited upon. The returned structure
@@ -203,11 +206,12 @@ __igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)* Structure with helper internal state for igt_spin_batch_free(). */ igt_spin_t * -igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine,uint32_t dep) +igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine, +uint32_t dep,bool preemptible) {igt_require_gem (fd); -return __igt_spin_batch_new (fd, ctx, engine, dep); +return __igt_spin_batch_new (fd, ctx, engine, dep, preemptible); }static void notify (union sigval arg)
lib/igt_dummyload.h +4 -2
@@ -40,11 +40,13 @@ typedef struct igt_spin {igt_spin_t *__igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine, -uint32_t dep); +uint32_t dep, +bool preemptible);igt_spin_t *igt_spin_batch_new (int fd,uint32_t ctx,unsigned engine, -uint32_t dep); +uint32_t dep, +bool preemptible);void igt_spin_batch_set_timeout (igt_spin_t *spin,int64_t ns);void igt_spin_batch_end (igt_spin_t *spin);void igt_spin_batch_free (int fd,igt_spin_t *spin);
tests/drv_missed_irq.c +1 -1
@@ -33,7 +33,7 @@ IGT_TEST_DESCRIPTION("Inject missed interrupts and make sure they are caught");static void trigger_missed_interrupt (int fd,unsigned ring) { -igt_spin_t *spin =__igt_spin_batch_new (fd,0 , ring,0 ); +igt_spin_t *spin =__igt_spin_batch_new (fd,0 , ring,0 , true); igt_fork(child, 1) {/* We are now a low priority child on the *same* CPU as the
tests/gem_busy.c +2 -2
@@ -460,7 +460,7 @@ static bool has_semaphores(int fd)static bool has_extended_busy_ioctl (int fd) { -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,I915_EXEC_RENDER ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,I915_EXEC_RENDER ,0 , true);uint32_t read, write;__gem_busy (fd, spin->handle, &read, &write);
@@ -471,7 +471,7 @@ static bool has_extended_busy_ioctl(int fd)static void basic (int fd,unsigned ring,unsigned flags) { -igt_spin_t *spin =igt_spin_batch_new (fd,0 , ring,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 , ring,0 , true);struct timespec tv;int timeout;bool busy;
tests/gem_exec_fence.c +7 -7
@@ -438,7 +438,7 @@ static void test_parallel(int fd, unsigned int master)/* Fill the queue with many requests so that the next one has to * wait before it can be executed by the hardware. */ - spin =igt_spin_batch_new (fd,0 , master, c.handle); + spin =igt_spin_batch_new (fd,0 , master, c.handle, true);resubmit (fd, spin->handle, master,16 );/* Now queue the master request and its secondaries */
@@ -961,7 +961,7 @@ static void test_syncobj_unused_fence(int fd)struct local_gem_exec_fence fence = { .handle =syncobj_create (fd), }; -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);/* sanity check our syncobj_to_sync_file interface */ igt_assert_eq (__syncobj_to_sync_file (fd,0 ), -ENOENT );
@@ -1053,7 +1053,7 @@ static void test_syncobj_signal(int fd)struct local_gem_exec_fence fence = { .handle =syncobj_create (fd), }; -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);/* Check that the syncobj is signaled only when our request/fence is */
@@ -1103,7 +1103,7 @@ static void test_syncobj_wait(int fd)gem_quiescent_gpu (fd); - spin =igt_spin_batch_new (fd,0 ,0 ,0 ); + spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);memset (&execbuf,0 ,sizeof (execbuf)); execbuf.buffers_ptr =to_user_pointer (&obj);
@@ -1173,7 +1173,7 @@ static void test_syncobj_export(int fd) .handle = syncobj_create(fd), };int export[2 ]; -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);/* Check that if we export the syncobj prior to use it picks up * the later fence. This allows a syncobj to establish a channel
@@ -1231,7 +1231,7 @@ static void test_syncobj_repeat(int fd)struct drm_i915_gem_execbuffer2 execbuf;struct local_gem_exec_fence *fence;int export; -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);/* Check that we can wait on the same fence multiple times */ fence =calloc (nfences,sizeof (*fence));
@@ -1286,7 +1286,7 @@ static void test_syncobj_import(int fd)const uint32_t bbe =MI_BATCH_BUFFER_END ;struct drm_i915_gem_exec_object2 obj;struct drm_i915_gem_execbuffer2 execbuf; -igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 ); +igt_spin_t *spin =igt_spin_batch_new (fd,0 ,0 ,0 , true);uint32_t sync =syncobj_create (fd);int fence;
tests/gem_exec_latency.c +1 -1
@@ -344,7 +344,7 @@ static void latency_from_ring(int fd, I915_GEM_DOMAIN_GTT);if (flags &PREEMPT ) - spin =igt_spin_batch_new (fd, ctx[0 ], ring,0 ); + spin =igt_spin_batch_new (fd, ctx[0 ], ring,0 , true);if (flags &CORK ) {plug (fd, &c);
tests/gem_exec_nop.c +1 -1
@@ -620,7 +620,7 @@ static void preempt(int fd, uint32_t handle,clock_gettime (CLOCK_MONOTONIC , &start); do { igt_spin_t *spin = - __igt_spin_batch_new(fd, ctx[0], ring_id, 0); + __igt_spin_batch_new(fd, ctx[0], ring_id, 0, true); for (int loop = 0; loop < 1024; loop++) gem_execbuf(fd, &execbuf);
tests/gem_exec_reloc.c +5 -3
@@ -388,7 +388,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags) }if (flags &ACTIVE ) { - spin =igt_spin_batch_new (fd,0 ,I915_EXEC_DEFAULT , obj.handle); + spin =igt_spin_batch_new (fd,0 ,I915_EXEC_DEFAULT , + obj.handle, true);if (!(flags &HANG ))igt_spin_batch_set_timeout (spin,NSEC_PER_SEC /100 );igt_assert (gem_bo_busy (fd, obj.handle));
@@ -454,7 +455,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags) }if (flags &ACTIVE ) { - spin =igt_spin_batch_new (fd,0 ,I915_EXEC_DEFAULT , obj.handle); + spin =igt_spin_batch_new (fd,0 ,I915_EXEC_DEFAULT , + obj.handle, true);if (!(flags &HANG ))igt_spin_batch_set_timeout (spin,NSEC_PER_SEC /100 );igt_assert (gem_bo_busy (fd, obj.handle));
@@ -581,7 +583,7 @@ static void basic_range(int fd, unsigned flags) execbuf.buffer_count = n +1 ;if (flags &ACTIVE ) { - spin =igt_spin_batch_new (fd,0 ,0 , obj[n].handle); + spin =igt_spin_batch_new (fd,0 ,0 , obj[n].handle, true);if (!(flags &HANG ))igt_spin_batch_set_timeout (spin,NSEC_PER_SEC /100 );igt_assert (gem_bo_busy (fd, obj[n].handle));
tests/gem_exec_schedule.c +4 -4
@@ -147,7 +147,7 @@ static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)for (int n =0 ; n <ARRAY_SIZE (spin); n++) {uint32_t ctx =create_highest_priority (fd); - spin[n] =__igt_spin_batch_new (fd, ctx, engine,0 ); + spin[n] =__igt_spin_batch_new (fd, ctx, engine,0 , true);gem_context_destroy (fd, ctx); }
@@ -376,7 +376,7 @@ static void preempt(int fd, unsigned ring, unsigned flags) ctx[LO ] =gem_context_create (fd);gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); } - spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 ); + spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 , true);igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle);store_dword (fd, ctx[HI ], ring, result,0 , n +1 ,0 ,I915_GEM_DOMAIN_RENDER );
@@ -425,7 +425,7 @@ static void preempt_other(int fd, unsigned ring) n =0 ;for_each_engine (fd, other) { - spin[n] =__igt_spin_batch_new (fd, ctx[NOISE ], other,0 ); + spin[n] =__igt_spin_batch_new (fd, ctx[NOISE ], other,0 , true);store_dword (fd, ctx[LO ], other, result, (n +1 )*sizeof (uint32_t ), n +1 ,0 ,I915_GEM_DOMAIN_RENDER );
@@ -478,7 +478,7 @@ static void preempt_self(int fd, unsigned ring) n =0 ;gem_context_set_priority (fd, ctx[HI ],MIN_PRIO );for_each_engine (fd, other) { - spin[n] =__igt_spin_batch_new (fd, ctx[NOISE ], other,0 ); + spin[n] =__igt_spin_batch_new (fd, ctx[NOISE ], other,0 , true);store_dword (fd, ctx[HI ], other, result, (n +1 )*sizeof (uint32_t ), n +1 ,0 ,I915_GEM_DOMAIN_RENDER );
tests/gem_exec_suspend.c +1 -1
@@ -201,7 +201,7 @@ static void run_test(int fd, unsigned engine, unsigned flags) }if (flags &HANG ) - spin =igt_spin_batch_new (fd,0 , engine,0 ); + spin =igt_spin_batch_new (fd,0 , engine,0 , true);switch (mode (flags)) {case NOSLEEP :
tests/gem_shrink.c +2 -2
@@ -311,9 +311,9 @@ static void reclaim(unsigned engine, int timeout) }while (!*shared); } - spin =igt_spin_batch_new (fd,0 , engine,0 ); + spin =igt_spin_batch_new (fd,0 , engine,0 , true);igt_until_timeout (timeout) { -igt_spin_t *next =__igt_spin_batch_new (fd,0 , engine,0 ); +igt_spin_t *next =__igt_spin_batch_new (fd,0 , engine,0 , true);igt_spin_batch_set_timeout (spin, timeout_100ms);gem_sync (fd, spin->handle);
tests/gem_spin_batch.c +2 -2
@@ -41,9 +41,9 @@ static void spin(int fd, unsigned int engine, unsigned int timeout_sec)struct timespec itv = { };uint64_t elapsed; - spin =igt_spin_batch_new (fd,0 , engine,0 ); + spin =igt_spin_batch_new (fd,0 , engine,0 , true);while ((elapsed =igt_nsec_elapsed (&tv)) >>30 < timeout_sec) { -igt_spin_t *next =__igt_spin_batch_new (fd,0 , engine,0 ); +igt_spin_t *next =__igt_spin_batch_new (fd,0 , engine,0 , true);igt_spin_batch_set_timeout (spin, timeout_100ms -igt_nsec_elapsed (&itv));
tests/gem_sync.c +2 -1
@@ -759,7 +759,8 @@ preempt(int fd, unsigned ring, int num_children, int timeout)__igt_spin_batch_new (fd, ctx[0 ], execbuf.flags, -0 ); +0 , + true); do { gem_execbuf(fd, &execbuf);
tests/gem_wait.c +1 -1
@@ -110,7 +110,7 @@ static void unplug(struct cork *c)static void basic (int fd,unsigned engine,unsigned flags) {struct cork cork =plug (fd, flags); -igt_spin_t *spin =igt_spin_batch_new (fd,0 , engine, cork.handle); +igt_spin_t *spin =igt_spin_batch_new (fd,0 , engine, cork.handle, true);struct drm_i915_gem_wait wait = { flags &WRITE ? cork.handle : spin->handle };
tests/kms_busy.c +3 -3
@@ -92,7 +92,7 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,struct drm_event_vblank ev;igt_spin_t *t =igt_spin_batch_new (dpy->drm_fd, -0 , ring, fb->gem_handle); +0 , ring, fb->gem_handle, true);if (modeset) {/*
@@ -208,7 +208,7 @@ static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary, struct igt_fb *busy_fb, unsigned ring) {igt_spin_t *t =igt_spin_batch_new (dpy->drm_fd, -0 , ring, busy_fb->gem_handle); +0 , ring, busy_fb->gem_handle, true);struct pollfd pfd = { .fd = dpy->drm_fd, .events =POLLIN };unsigned flags =0 ;struct drm_event_vblank ev;
@@ -295,7 +295,7 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy,igt_display_commit2 (dpy, dpy->is_atomic ?COMMIT_ATOMIC :COMMIT_LEGACY ); - t =igt_spin_batch_new (dpy->drm_fd,0 , ring, fb.gem_handle); + t =igt_spin_batch_new (dpy->drm_fd,0 , ring, fb.gem_handle, true);do_or_die (drmModePageFlip (dpy->drm_fd, dpy->pipes[pipe].crtc_id, fb.fb_id,DRM_MODE_PAGE_FLIP_EVENT , &fb));
tests/kms_cursor_legacy.c +3 -2
@@ -532,7 +532,8 @@ static void basic_flip_cursor(igt_display_t *display, spin =NULL ;if (flags &BASIC_BUSY ) - spin =igt_spin_batch_new (display->drm_fd,0 ,0 , fb_info.gem_handle); + spin =igt_spin_batch_new (display->drm_fd,0 ,0 , + fb_info.gem_handle, true);/* Start with a synchronous query to align with the vblank */ vblank_start =get_vblank (display->drm_fd, pipe,DRM_VBLANK_NEXTONMISS );
@@ -1299,7 +1300,7 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)static const int max_crcs =8 ; spin =igt_spin_batch_new (display->drm_fd,0 ,0 , - fb_info[1 ].gem_handle); + fb_info[1 ].gem_handle, true); vblank_start =get_vblank (display->drm_fd, pipe,DRM_VBLANK_NEXTONMISS );
tests/kms_flip.c +2 -2
@@ -693,14 +693,14 @@ static unsigned int run_test_step(struct test_output *o)if (o->flags &TEST_WITH_DUMMY_BCS ) { spin_bcs =igt_spin_batch_new (drm_fd,0 ,I915_EXEC_BLT , - o->fb_info[o->current_fb_id].gem_handle); + o->fb_info[o->current_fb_id].gem_handle, true);igt_spin_batch_set_timeout (spin_bcs,NSEC_PER_SEC ); }if (o->flags &TEST_WITH_DUMMY_RCS ) { spin_rcs =igt_spin_batch_new (drm_fd,0 ,I915_EXEC_RENDER , - o->fb_info[o->current_fb_id].gem_handle); + o->fb_info[o->current_fb_id].gem_handle, true);igt_spin_batch_set_timeout (spin_rcs,NSEC_PER_SEC ); }
tests/perf_pmu.c +10 -10
@@ -141,7 +141,7 @@ single(int gem_fd, const struct intel_execution_engine2 *e, bool busy) fd =open_pmu (I915_PMU_ENGINE_BUSY (e->class, e->instance));if (busy) { - spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 ); + spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 , true);igt_spin_batch_set_timeout (spin, batch_duration_ns); }else {usleep (batch_duration_ns /1000 );
@@ -203,7 +203,7 @@ busy_check_all(int gem_fd, const struct intel_execution_engine2 *e,igt_assert_eq (i, num_engines); - spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 ); + spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 , true);igt_spin_batch_set_timeout (spin, batch_duration_ns);gem_sync (gem_fd, spin->handle);
@@ -249,7 +249,7 @@ most_busy_check_all(int gem_fd, const struct intel_execution_engine2 *e, idle_idx = i; }else { spin[i] =igt_spin_batch_new (gem_fd,0 , -e2ring (gem_fd, e_),0 ); +e2ring (gem_fd, e_),0 , true);igt_spin_batch_set_timeout (spin[i], batch_duration_ns); }
@@ -297,7 +297,7 @@ all_busy_check_all(int gem_fd, const unsigned int num_engines) fd[i] =open_group (I915_PMU_ENGINE_BUSY (e->class, e->instance), fd[0 ]); - spin[i] =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 ); + spin[i] =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 , true);igt_spin_batch_set_timeout (spin[i], batch_duration_ns); i++;
@@ -328,7 +328,7 @@ no_sema(int gem_fd, const struct intel_execution_engine2 *e, bool busy)open_group (I915_PMU_ENGINE_WAIT (e->class, e->instance), fd);if (busy) { - spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 ); + spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 , true);igt_spin_batch_set_timeout (spin, batch_duration_ns); }else {usleep (batch_duration_ns /1000 );
@@ -637,7 +637,7 @@ multi_client(int gem_fd, const struct intel_execution_engine2 *e)*/ fd[1 ] =open_pmu (config); - spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 ); + spin =igt_spin_batch_new (gem_fd,0 ,e2ring (gem_fd, e),0 , true);igt_spin_batch_set_timeout (spin,2 * batch_duration_ns); slept =measured_usleep (batch_duration_ns /1000 );
@@ -742,7 +742,7 @@ static void cpu_hotplug(int gem_fd) fd =perf_i915_open (I915_PMU_ENGINE_BUSY (I915_ENGINE_CLASS_RENDER ,0 ));igt_assert (fd >=0 ); - spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 ); + spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 , true);igt_nsec_elapsed (&start);
@@ -855,7 +855,7 @@ test_interrupts(int gem_fd)gem_quiescent_gpu (gem_fd); fd =open_pmu (I915_PMU_INTERRUPTS ); - spin =igt_spin_batch_new (gem_fd,0 ,0 ,0 ); + spin =igt_spin_batch_new (gem_fd,0 ,0 ,0 , true); obj.handle =gem_create (gem_fd, sz);gem_write (gem_fd, obj.handle, sz -sizeof (bbe), &bbe,sizeof (bbe));
@@ -937,7 +937,7 @@ test_frequency(int gem_fd)pmu_read_multi (fd,2 , start); - spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 ); + spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 , true);igt_spin_batch_set_timeout (spin, duration_ns);gem_sync (gem_fd, spin->handle);
@@ -962,7 +962,7 @@ test_frequency(int gem_fd)pmu_read_multi (fd,2 , start); - spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 ); + spin =igt_spin_batch_new (gem_fd,0 ,I915_EXEC_RENDER ,0 , true);igt_spin_batch_set_timeout (spin, duration_ns);gem_sync (gem_fd, spin->handle);
tests/pm_rps.c +1 -1
@@ -588,7 +588,7 @@ static void boost_freq(int fd, int *boost_freqs) engine =I915_EXEC_RENDER ;if (intel_gen (lh.devid) >=6 ) engine =I915_EXEC_BLT ; - load =igt_spin_batch_new (fd,0 , engine,0 ); + load =igt_spin_batch_new (fd,0 , engine,0 , true);/* Waiting will grant us a boost to maximum */ gem_wait (fd, load->handle, &timeout);
Signature · 6 lines
2.14.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/3 tests/gem_exec_schedule: Add reset on failed preemption test.
This patch adds a test where a low priority batch is going to be declared hung while a preemption is pending. The test wants to verify that a 'bad' low priority batch will not disrupt the execution of a high priority context and that the driver does due diligence in managing a reset while a preemption is pending.
--- tests/gem_exec_schedule.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
tests/gem_exec_schedule.c +11 -1
@@ -356,7 +356,8 @@ static void promotion(int fd, unsigned ring)munmap (ptr,4096 ); } -#define NEW_CTX 0x1 +#define NEW_CTX (0x1 << 0) +#define HANG_LP (0x1 << 1)static void preempt (int fd,unsigned ring,unsigned flags) {uint32_t result =gem_create (fd,4096 );
@@ -370,6 +371,9 @@ static void preempt(int fd, unsigned ring, unsigned flags) ctx[HI ] =gem_context_create (fd);gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); +if (flags &HANG_LP ) +igt_spin_batch_new (fd, ctx[LO ], ring,0 , false); +for (int n =0 ; n <16 ; n++) {if (flags &NEW_CTX ) {gem_context_destroy (fd, ctx[LO ]);
@@ -1023,6 +1027,12 @@ igt_main igt_subtest_f("preempt-self-%s", e->name)preempt_self (fd, e->exec_id | e->flags); + + igt_subtest_f("preempt-bad-%s", e->name) { +igt_stop_hang_detector (); +preempt (fd, e->exec_id | e->flags,NEW_CTX |HANG_LP ); +igt_fork_hang_detector (fd); + } }igt_subtest_f ("deep-%s" , e->name)
Signature · 6 lines
2.14.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/3] tests/gem_exec_schedule: Add reset on failed preemption test.
Quoting Antonio Argenziano (2017-12-04 17:23:14)
Quoted 28 lines
This patch adds a test where a low priority batch is going to be declared hung while a preemption is pending. The test wants to verify that a 'bad' low priority batch will not disrupt the execution of a high priority context and that the driver does due diligence in managing a reset while a preemption is pending.
Cc Chris Wilson <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>--- tests/gem_exec_schedule.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)tests/gem_exec_schedule.c +2
-1@@ -356,7 +356,8 @@ static void promotion(int fd, unsigned ring)munmap (ptr,4096 ); } -#define NEW_CTX 0x1 +#define NEW_CTX (0x1 << 0) +#define HANG_LP (0x1 << 1)static void preempt (int fd,unsigned ring,unsigned flags) {uint32_t result =gem_create (fd,4096 );
tests/gem_exec_schedule.c static void preempt(int fd, unsigned ring, unsigned flags) · line 375
Quoted 5 lines
tests/gem_exec_schedule.c +2
-0@@ -370,6 +371,9 @@ static void preempt(int fd, unsigned ring, unsigned flags) ctx[HI ] =gem_context_create (fd);gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); +if (flags &HANG_LP ) +igt_spin_batch_new (fd, ctx[LO ], ring,0 , false);
Both of the hanging batch usecases fit into igt_hang_t batch, which doesn't allow preempting atm. (Though I'd be quite happy to see patches towards unifying the two interfaces, probably with an opts struct rather than continuing to add new params ad nauseam.) Before injecting a hang, you must check with igt_allow_hang etc that hangs/resets are allowed by igt, and to clean up afterwards.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/3] tests/gem_exec_schedule: Add reset on failed preemption test.
Quoted 32 lines · Chris Wilson
Quoting Antonio Argenziano (2017-12-04 17:23:14)
Quoted 31 lines
This patch adds a test where a low priority batch is going to be declared hung while a preemption is pending. The test wants to verify that a 'bad' low priority batch will not disrupt the execution of a high priority context and that the driver does due diligence in managing a reset while a preemption is pending.
Cc Chris Wilson <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>--- tests/gem_exec_schedule.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)tests/gem_exec_schedule.c +2
-1@@ -356,7 +356,8 @@ static void promotion(int fd, unsigned ring)munmap (ptr,4096 ); } -#define NEW_CTX 0x1 +#define NEW_CTX (0x1 << 0) +#define HANG_LP (0x1 << 1)static void preempt (int fd,unsigned ring,unsigned flags) {uint32_t result =gem_create (fd,4096 );@@ -370,6 +371,9 @@ static void preempt(int fd, unsigned ring, unsigned flags) ctx[HI ] =gem_context_create (fd);gem_context_set_priority (fd, ctx[HI ],MAX_PRIO );
Quoted 9 lines
tests/gem_exec_schedule.c static void preempt(int fd, unsigned ring, unsigned flags) · line 375
Quoted 2 lines
tests/gem_exec_schedule.c +2
-0+if (flags &HANG_LP ) +igt_spin_batch_new (fd, ctx[LO ], ring,0 , false);Both of the hanging batch usecases fit into
igt_hang_tbatch, which doesn't allow preempting atm. (Though I'd be quite happy to see patches towards unifying the two interfaces, probably with an opts struct rather than continuing to add new params ad nauseam.) Before injecting a hang, you must check withigt_allow_hangetc that hangs/resets are allowed by igt, and to clean up afterwards.
I'll re-spin using igt_hang and send an RFC to put the two things together afterwards. Is that OK with you?
-Antonio
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 tests/gem_exec_schedule: Add test for resetting preemptive batch
In reply to Antonio ArgenzianoThis patch adds a test that will trigger a preemption of a low priority batch by a 'bad' batch buffer which will hang. The test aims at making sure that a hanging high priority batch will not disrupt the submission flow of low priority contexts.
--- tests/gem_exec_schedule.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
tests/gem_exec_schedule.c +39 -0
@@ -511,6 +511,39 @@ static void preempt_self(int fd, unsigned ring)gem_close (fd, result); } +static void bad_preemptive (int fd,unsigned ring) +{ +igt_spin_t *spin[16 ]; +igt_spin_t *bad; +uint32_t ctx[2 ]; + + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + ctx[HI ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + +for (int n =0 ; n <16 ; n++) { +gem_context_destroy (fd, ctx[LO ]); + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 , true); +igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle); + } + + bad =igt_spin_batch_new (fd, ctx[HI ], ring,0 , false); +gem_wait (fd, bad->handle,NULL ); + +for (int n =0 ; n <16 ; n++) { +igt_assert (gem_bo_busy (fd, spin[n]->handle)); +igt_spin_batch_free (fd, spin[n]); + } + +gem_context_destroy (fd, ctx[LO ]); +gem_context_destroy (fd, ctx[HI ]); +} +static void deep (int fd,unsigned ring) {#define XS 8
@@ -1033,6 +1066,12 @@ igt_mainpreempt (fd, e->exec_id | e->flags,NEW_CTX |HANG_LP );igt_fork_hang_detector (fd); } + + igt_subtest_f("bad-preemptive-%s", e->name) { +igt_stop_hang_detector (); +bad_preemptive (fd, e->exec_id | e->flags); +igt_fork_hang_detector (fd); + } }igt_subtest_f ("deep-%s" , e->name)
Signature · 6 lines
2.14.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 3/3] tests/gem_exec_schedule: Add test for resetting preemptive batch
Quoting Antonio Argenziano (2017-12-04 17:23:15)
Quoted 38 lines
This patch adds a test that will trigger a preemption of a low priority batch by a 'bad' batch buffer which will hang. The test aims at making sure that a hanging high priority batch will not disrupt the submission flow of low priority contexts.
Cc Chris Wilson <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>--- tests/gem_exec_schedule.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)tests/gem_exec_schedule.c +18
-0@@ -511,6 +511,39 @@ static void preempt_self(int fd, unsigned ring)gem_close (fd, result); } +static void bad_preemptive (int fd,unsigned ring) +{ +igt_spin_t *spin[16 ]; +igt_spin_t *bad; +uint32_t ctx[2 ]; + + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + ctx[HI ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + +for (int n =0 ; n <16 ; n++) { +gem_context_destroy (fd, ctx[LO ]); + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 , true);
tests/gem_exec_schedule.c static void preempt_self(int fd, unsigned ring) · line 541
Quoted 10 lines
tests/gem_exec_schedule.c +10
-0+igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle); + } + + bad =igt_spin_batch_new (fd, ctx[HI ], ring,0 , false); +gem_wait (fd, bad->handle,NULL ); + +for (int n =0 ; n <16 ; n++) { +igt_assert (gem_bo_busy (fd, spin[n]->handle)); +igt_spin_batch_free (fd, spin[n]); + }
Is this really policy you want to enforce? I certainly don't intend to mandate that the kernel isn't allowed to use RT throttling.
Quoted 9 lines
tests/gem_exec_schedule.c +5
-0+ +gem_context_destroy (fd, ctx[LO ]); +gem_context_destroy (fd, ctx[HI ]); +} +static void deep (int fd,unsigned ring) {#define XS 8
tests/gem_exec_schedule.c igt_main · line 1074
Quoted 9 lines
tests/gem_exec_schedule.c +6
-0@@ -1033,6 +1066,12 @@ igt_mainpreempt (fd, e->exec_id | e->flags,NEW_CTX |HANG_LP );igt_fork_hang_detector (fd); } + + igt_subtest_f("bad-preemptive-%s", e->name) { +igt_stop_hang_detector (); +bad_preemptive (fd, e->exec_id | e->flags); +igt_fork_hang_detector (fd); + }
Split into non-hang/hang portions and use igt_subtest_group + igt_fixture.
-Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 3/3] tests/gem_exec_schedule: Add test for resetting preemptive batch
Quoted 44 lines · Chris Wilson
Quoting Antonio Argenziano (2017-12-04 17:23:15)
Quoted 43 lines
This patch adds a test that will trigger a preemption of a low priority batch by a 'bad' batch buffer which will hang. The test aims at making sure that a hanging high priority batch will not disrupt the submission flow of low priority contexts.
Cc Chris Wilson <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>--- tests/gem_exec_schedule.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)tests/gem_exec_schedule.c +23
-0@@ -511,6 +511,39 @@ static void preempt_self(int fd, unsigned ring)gem_close (fd, result); } +static void bad_preemptive (int fd,unsigned ring) +{ +igt_spin_t *spin[16 ]; +igt_spin_t *bad; +uint32_t ctx[2 ]; + + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + ctx[HI ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + +for (int n =0 ; n <16 ; n++) { +gem_context_destroy (fd, ctx[LO ]); + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 , true); +igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle); + } + + bad =igt_spin_batch_new (fd, ctx[HI ], ring,0 , false); +gem_wait (fd, bad->handle,NULL );
Quoted 8 lines
tests/gem_exec_schedule.c static void preempt_self(int fd, unsigned ring) · line 541
Quoted 5 lines
tests/gem_exec_schedule.c +5
-0+ +for (int n =0 ; n <16 ; n++) { +igt_assert (gem_bo_busy (fd, spin[n]->handle)); +igt_spin_batch_free (fd, spin[n]); + }Is this really policy you want to enforce? I certainly don't intend to mandate that the kernel isn't allowed to use RT throttling.
Yeah, I wasn't sure about that. Is a gem_wait on each of them enough or should I put a write at the end of each low priority batch to make sure they actually executed?
Quoted 14 lines
Quoted 14 lines
tests/gem_exec_schedule.c +6
-0+ +gem_context_destroy (fd, ctx[LO ]); +gem_context_destroy (fd, ctx[HI ]); +} +static void deep (int fd,unsigned ring) {#define XS 8@@ -1033,6 +1066,12 @@ igt_mainpreempt (fd, e->exec_id | e->flags,NEW_CTX |HANG_LP );igt_fork_hang_detector (fd); } +
Quoted 8 lines
tests/gem_exec_schedule.c igt_main · line 1074
Quoted 5 lines
tests/gem_exec_schedule.c +5
-0+ igt_subtest_f("bad-preemptive-%s", e->name) { +igt_stop_hang_detector (); +bad_preemptive (fd, e->exec_id | e->flags); +igt_fork_hang_detector (fd); + }Split into non-hang/hang portions and use
igt_subtest_group+igt_fixture.
OK, will do.
-Antonio
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 3/3] tests/gem_exec_schedule: Add test for resetting preemptive batch
Quoting Antonio Argenziano (2017-12-04 18:25:16)
Quoted 56 lines · Chris Wilson
Quoted 44 lines
Quoting Antonio Argenziano (2017-12-04 17:23:15)
Quoted 43 lines
This patch adds a test that will trigger a preemption of a low priority batch by a 'bad' batch buffer which will hang. The test aims at making sure that a hanging high priority batch will not disrupt the submission flow of low priority contexts.
Cc Chris Wilson <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>--- tests/gem_exec_schedule.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)tests/gem_exec_schedule.c +23
-0@@ -511,6 +511,39 @@ static void preempt_self(int fd, unsigned ring)gem_close (fd, result); } +static void bad_preemptive (int fd,unsigned ring) +{ +igt_spin_t *spin[16 ]; +igt_spin_t *bad; +uint32_t ctx[2 ]; + + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + ctx[HI ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + +for (int n =0 ; n <16 ; n++) { +gem_context_destroy (fd, ctx[LO ]); + ctx[LO ] =gem_context_create (fd); +gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + + spin[n] =__igt_spin_batch_new (fd, ctx[LO ], ring,0 , true); +igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle); + } + + bad =igt_spin_batch_new (fd, ctx[HI ], ring,0 , false); +gem_wait (fd, bad->handle,NULL );Quoted 8 lines
tests/gem_exec_schedule.c static void preempt_self(int fd, unsigned ring) · line 541
Quoted 5 lines
tests/gem_exec_schedule.c +5
-0+ +for (int n =0 ; n <16 ; n++) { +igt_assert (gem_bo_busy (fd, spin[n]->handle)); +igt_spin_batch_free (fd, spin[n]); + }Is this really policy you want to enforce? I certainly don't intend to mandate that the kernel isn't allowed to use RT throttling.
Quoted 3 lines
Yeah, I wasn't sure about that. Is a
gem_waiton each of them enough or should I put a write at the end of each low priority batch to make sure they actually executed?
Just a comment that this is what happens right now, but we may enact a different policy when we have a real scheduler. Part of the trick is remembering which tests are allowed to be broken, because on the whole igt define the behaviour which is expected/relied on by clients. (The converse is also true in that we may scope out the limits of user behaviour in igt and then fix the kernel to suite.)
As regards gem_wait(), this here is gem_sync(), and you can neaten up ctx[LO] by scoping the context to the loop.
And call this something like preemptive_hang; bad* brings bad memories of tests that were deliberately broken as opposed to demonstrating that the code survives abuse.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [1/3] igt_dummyload: Add preemptible parameter to spinning batch.
In reply to Antonio Argenziano== Series Details ==
== Series Details ==
Series: series starting with [1/3] igt_dummyload: Add preemptible parameter to spinning batch.
URL : https://patchwork.freedesktop.org/series/34860/
State : failure
== Summary ==
IGT patchset build failed on latest successful build c7b20c950276a41badd994324e1983760e44842b igt/perf_pmu: Tighten semaphore-wait measurement
CCLD drm_import_export
CCLD drm_mm
CCLD drm_read
CCLD drm_vma_limiter
CCLD drm_vma_limiter_cached
CCLD drm_vma_limiter_cpu
CCLD drm_vma_limiter_gtt
CCLD drv_getparams_basic
CCLD drv_hangman
CCLD drv_missed_irq
CCLD drv_module_reload
CCLD drv_selftest
CCLD drv_suspend
CCLD gem_bad_reloc
CCLD gem_basic
CC gem_busy.o
gem_busy.c: In function ‘semaphore’:
gem_busy.c:116:9: error: too few arguments to function ‘igt_spin_batch_new’
spin = igt_spin_batch_new(fd, 0, ring, handle[BUSY]);
^~~~~~~~~~~~~~~~~~
In file included from ./../lib/igt.h:35:0,
from gem_busy.c:28:
./../lib/igt_dummyload.h:45:13: note: declared here
igt_spin_t *igt_spin_batch_new(int fd,
^~~~~~~~~~~~~~~~~~
gem_busy.c: In function ‘close_race’:
gem_busy.c:462:14: error: too few arguments to function ‘igt_spin_batch_new’
spin[i] = igt_spin_batch_new(fd, 0,
^~~~~~~~~~~~~~~~~~
In file included from ./../lib/igt.h:35:0,
from gem_busy.c:28:
./../lib/igt_dummyload.h:45:13: note: declared here
igt_spin_t *igt_spin_batch_new(int fd,
^~~~~~~~~~~~~~~~~~
gem_busy.c:470:15: error: too few arguments to function ‘igt_spin_batch_new’
spin[i] = igt_spin_batch_new(fd, 0,
^~~~~~~~~~~~~~~~~~
In file included from ./../lib/igt.h:35:0,
from gem_busy.c:28:
./../lib/igt_dummyload.h:45:13: note: declared here
igt_spin_t *igt_spin_batch_new(int fd,
^~~~~~~~~~~~~~~~~~Makefile:3947: recipe for target 'gem_busy.o' failed make[3]: *** [gem_busy.o] Error 1 Makefile:4348: recipe for target 'all-recursive' failed make[2]: *** [all-recursive] Error 1 Makefile:531: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 Makefile:463: recipe for target 'all' failed
make: *** [all] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx