Skip to content

Commit

Permalink
drm/i915/selftests: Start kthreads before stopping
Browse files Browse the repository at this point in the history
An interesting observation made with our parallel selftests was that on
our small/single cpu systems we would call kthread_stop() before the
kthreads were spawned. If this happens, the kthread is never run at all;
completely bypassing the test.

A simple yield() from the parent will ensure that all children have the
opportunity to start before we reap them.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191101084940.31838-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Nov 1, 2019
1 parent 292a27b commit e5661c6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ static int live_parallel_switch(void *arg)
get_task_struct(data[n].tsk);
}

yield(); /* start all threads before we kthread_stop() */

for (n = 0; n < count; n++) {
int status;

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ static int igt_threaded_blt(struct drm_i915_private *i915,
get_task_struct(tsk[i]);
}

yield(); /* start all threads before we kthread_stop() */

for (i = 0; i < n_cpus; ++i) {
int status;

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gt/selftest_hangcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ static int __igt_reset_engines(struct intel_gt *gt,
get_task_struct(tsk);
}

yield(); /* start all threads before we begin */

intel_engine_pm_get(engine);
set_bit(I915_RESET_ENGINE + id, &gt->reset.flags);
do {
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gt/selftest_lrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
get_task_struct(tsk[id]);
}

yield(); /* start all threads before we kthread_stop() */

count = 0;
for_each_engine(engine, smoke->gt, id) {
int status;
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/selftests/i915_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ static int mock_breadcrumbs_smoketest(void *arg)
get_task_struct(threads[n]);
}

yield(); /* start all threads before we begin */
msleep(jiffies_to_msecs(i915_selftest.timeout_jiffies));

for (n = 0; n < ncpus; n++) {
Expand Down Expand Up @@ -1158,6 +1159,8 @@ static int live_parallel_engines(void *arg)
get_task_struct(tsk[idx++]);
}

yield(); /* start all threads before we kthread_stop() */

idx = 0;
for_each_uabi_engine(engine, i915) {
int status;
Expand Down Expand Up @@ -1314,6 +1317,7 @@ static int live_breadcrumbs_smoketest(void *arg)
idx++;
}

yield(); /* start all threads before we begin */
msleep(jiffies_to_msecs(i915_selftest.timeout_jiffies));

out_flush:
Expand Down

0 comments on commit e5661c6

Please sign in to comment.