drm/i915/selftests/blt: add some kthreads into the mix
Subsystems (2)
PATCH 1/1 drm/i915/selftests/blt: add some kthreads into the mix
We can be more aggressive in our testing by launching a number of kthreads, where each is submitting its own copy or fill batches on a set of random sized objects. Also since the underlying fill and copy batches can be pre-empted mid-batch(for particularly large objects), throw in a random mixture of ctx priorities per thread to make pre-emption a possibility.
--- .../i915/gem/selftests/i915_gem_object_blt.c | 144 +++++++++++++++--- 1 file changed, 121 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +121 -23
@@ -7,34 +7,53 @@#include "i915_selftest.h" +#include "gem/i915_gem_context.h" #include "selftests/igt_flush_test.h" +#include "selftests/i915_random.h" #include "selftests/mock_drm.h" #include "huge_gem_object.h" #include "mock_context.h" -static int igt_fill_blt (void *arg) +struct igt_thread_arg { +struct drm_i915_private *i915; +struct rnd_state *prng; +}; + +static int igt_fill_blt_thread (void *arg) { -struct drm_i915_private *i915 = arg; -struct intel_context *ce = i915->engine[BCS0 ]->kernel_context; +struct igt_thread_arg *thread = arg; +struct drm_i915_private *i915 = thread->i915; +struct rnd_state *prng = thread->prng;struct drm_i915_gem_object *obj; -struct rnd_state prng; +struct i915_gem_context *ctx; +struct intel_context *ce; +struct drm_file *file; +unsigned int prio;IGT_TIMEOUT (end); -u32 *vaddr; -int err =0 ; +int err; + + file =mock_file (i915); +if (IS_ERR (file)) +return PTR_ERR (file); + + ctx =live_context (i915, file); +if (IS_ERR (ctx)) { + err =PTR_ERR (ctx); + goto out_file; + } -prandom_seed_state (&prng, i915_selftest.random_seed); + prio =prandom_u32_state (prng) %I915_PRIORITY_MAX ; + ctx->sched.priority =I915_USER_PRIORITY (prio); -/* -* XXX: needs some threads to scale all these tests, also maybe throw -* in submission from higher priority context to see if we are -* preempted for very large objects... -*/ + ce =i915_gem_context_get_engine (ctx,BCS0 ); +GEM_BUG_ON (IS_ERR (ce)); do { const u32 max_block_size = S16_MAX * PAGE_SIZE; - u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(&prng)); + u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(prng)); u32 phys_sz = sz % (max_block_size + 1); - u32 val = prandom_u32_state(&prng); + u32 val = prandom_u32_state(prng); + u32 *vaddr; u32 i; sz = round_up(sz, PAGE_SIZE);
@@ -98,26 +117,47 @@ static int igt_fill_blt(void *arg)if (err == -ENOMEM ) err =0 ; +intel_context_put (ce); +out_file: +mock_file_free (i915, file);return err; } -static int igt_copy_blt (void *arg) +static int igt_copy_blt_thread (void *arg) { -struct drm_i915_private *i915 = arg; -struct intel_context *ce = i915->engine[BCS0 ]->kernel_context; +struct igt_thread_arg *thread = arg; +struct drm_i915_private *i915 = thread->i915; +struct rnd_state *prng = thread->prng;struct drm_i915_gem_object *src, *dst; -struct rnd_state prng; +struct i915_gem_context *ctx; +struct intel_context *ce; +struct drm_file *file; +unsigned int prio;IGT_TIMEOUT (end); -u32 *vaddr; -int err =0 ; +int err; + + file =mock_file (i915); +if (IS_ERR (file)) +return PTR_ERR (file); + + ctx =live_context (i915, file); +if (IS_ERR (ctx)) { + err =PTR_ERR (ctx); + goto out_file; + } -prandom_seed_state (&prng, i915_selftest.random_seed); + prio =prandom_u32_state (prng) %I915_PRIORITY_MAX ; + ctx->sched.priority =I915_USER_PRIORITY (prio); + + ce =i915_gem_context_get_engine (ctx,BCS0 ); +GEM_BUG_ON (IS_ERR (ce)); do { const u32 max_block_size = S16_MAX * PAGE_SIZE; - u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(&prng)); + u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(prng)); u32 phys_sz = sz % (max_block_size + 1); - u32 val = prandom_u32_state(&prng); + u32 val = prandom_u32_state(prng); + u32 *vaddr; u32 i; sz = round_up(sz, PAGE_SIZE);
@@ -201,9 +241,67 @@ static int igt_copy_blt(void *arg)if (err == -ENOMEM ) err =0 ; +intel_context_put (ce); +out_file: +mock_file_free (i915, file); +return err; +} + +static int igt_threaded_blt (struct drm_i915_private *i915, +int (*blt_fn)(void *arg)) +{ + +I915_RND_STATE (prng); +struct igt_thread_arg thread = { i915, &prng, }; +struct task_struct **tsk; +unsigned int n_cpus; +unsigned int i; +int err =0 ; + + n_cpus =num_online_cpus () +1 ; + + tsk =kzalloc (n_cpus *sizeof (struct task_struct *),GFP_KERNEL ); +if (!tsk) +return 0 ; + +for (i =0 ; i < n_cpus; ++i) { + tsk[i] =kthread_run (blt_fn, &thread,"igt/blt-%d" , i); +if (IS_ERR (tsk[i])) { + err =PTR_ERR (tsk[i]); +break ; + } + +get_task_struct (tsk[i]); + } + +for (i =0 ; i < n_cpus; ++i) { +int status; + +if (IS_ERR_OR_NULL (tsk[i])) +continue ; + + status =kthread_stop (tsk[i]); +if (status && !err) + err = status; + +put_task_struct (tsk[i]); + } + +kfree (tsk); +return err; } +static int igt_fill_blt (void *arg) +{ +return igt_threaded_blt (arg, igt_fill_blt_thread); +} + +static int igt_copy_blt (void *arg) +{ +return igt_threaded_blt (arg, igt_copy_blt_thread); +} +int i915_gem_object_blt_live_selftests (struct drm_i915_private *i915) {static const struct i915_subtest tests[] = {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Matthew Auld (2019-10-25 12:24:42)
Quoted 116 lines
We can be more aggressive in our testing by launching a number of kthreads, where each is submitting its own copy or fill batches on a set of random sized objects. Also since the underlying fill and copy batches can be pre-empted mid-batch(for particularly large objects), throw in a random mixture of ctx priorities per thread to make pre-emption a possibility.
Signed-off-by Matthew Auld <[email protected]>Cc Chris Wilson <[email protected]>--- .../i915/gem/selftests/i915_gem_object_blt.c | 144 +++++++++++++++--- 1 file changed, 121 insertions(+), 23 deletions(-)drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +48
-20@@ -7,34 +7,53 @@#include "i915_selftest.h" +#include "gem/i915_gem_context.h" #include "selftests/igt_flush_test.h" +#include "selftests/i915_random.h" #include "selftests/mock_drm.h" #include "huge_gem_object.h" #include "mock_context.h" -static int igt_fill_blt (void *arg) +struct igt_thread_arg { +struct drm_i915_private *i915; +struct rnd_state *prng; +}; + +static int igt_fill_blt_thread (void *arg) { -struct drm_i915_private *i915 = arg; -struct intel_context *ce = i915->engine[BCS0 ]->kernel_context; +struct igt_thread_arg *thread = arg; +struct drm_i915_private *i915 = thread->i915; +struct rnd_state *prng = thread->prng;struct drm_i915_gem_object *obj; -struct rnd_state prng; +struct i915_gem_context *ctx; +struct intel_context *ce; +struct drm_file *file; +unsigned int prio;IGT_TIMEOUT (end); -u32 *vaddr; -int err =0 ; +int err; + + file =mock_file (i915); +if (IS_ERR (file)) +return PTR_ERR (file); + + ctx =live_context (i915, file); +if (IS_ERR (ctx)) { + err =PTR_ERR (ctx); + goto out_file; + } -prandom_seed_state (&prng, i915_selftest.random_seed); + prio =prandom_u32_state (prng) %I915_PRIORITY_MAX ; + ctx->sched.priority =I915_USER_PRIORITY (prio); -/* -* XXX: needs some threads to scale all these tests, also maybe throw -* in submission from higher priority context to see if we are -* preempted for very large objects... -*/ + ce =i915_gem_context_get_engine (ctx,BCS0 ); +GEM_BUG_ON (IS_ERR (ce)); do { const u32 max_block_size = S16_MAX * PAGE_SIZE; - u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(&prng)); + u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(prng)); u32 phys_sz = sz % (max_block_size + 1); - u32 val = prandom_u32_state(&prng); + u32 val = prandom_u32_state(prng); + u32 *vaddr; u32 i; sz = round_up(sz, PAGE_SIZE);@@ -98,26 +117,47 @@ static int igt_fill_blt(void *arg)if (err == -ENOMEM ) err =0 ; +intel_context_put (ce); +out_file: +mock_file_free (i915, file);return err; } -static int igt_copy_blt (void *arg) +static int igt_copy_blt_thread (void *arg) { -struct drm_i915_private *i915 = arg; -struct intel_context *ce = i915->engine[BCS0 ]->kernel_context; +struct igt_thread_arg *thread = arg; +struct drm_i915_private *i915 = thread->i915; +struct rnd_state *prng = thread->prng;struct drm_i915_gem_object *src, *dst; -struct rnd_state prng; +struct i915_gem_context *ctx; +struct intel_context *ce; +struct drm_file *file; +unsigned int prio;IGT_TIMEOUT (end); -u32 *vaddr; -int err =0 ; +int err; + + file =mock_file (i915); +if (IS_ERR (file))
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c static int igt_fill_blt(void *arg) · line 149
Quoted 10 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +8
-1+return PTR_ERR (file); + + ctx =live_context (i915, file); +if (IS_ERR (ctx)) { + err =PTR_ERR (ctx); + goto out_file; + } -prandom_seed_state (&prng, i915_selftest.random_seed); + prio =prandom_u32_state (prng) %I915_PRIORITY_MAX ;
prio = i915_prandom_u32_max_state(prng, I915_PRIORITY_MAX);
Usual prng dilemma of high bits being more random than low bits, and it avoids the divide. (Nice trick to remember :)
Quoted 22 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +9
-2+ ctx->sched.priority =I915_USER_PRIORITY (prio); + + ce =i915_gem_context_get_engine (ctx,BCS0 ); +GEM_BUG_ON (IS_ERR (ce)); do { const u32 max_block_size = S16_MAX * PAGE_SIZE; - u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(&prng)); + u32 sz = min_t(u64, ce->vm->total >> 4, prandom_u32_state(prng)); u32 phys_sz = sz % (max_block_size + 1); - u32 val = prandom_u32_state(&prng); + u32 val = prandom_u32_state(prng); + u32 *vaddr; u32 i; sz = round_up(sz, PAGE_SIZE);@@ -201,9 +241,67 @@ static int igt_copy_blt(void *arg)if (err == -ENOMEM ) err =0 ; +intel_context_put (ce); +out_file:
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c static int igt_copy_blt(void *arg) · line 255
Quoted 10 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +10
-0+mock_file_free (i915, file); +return err; +} + +static int igt_threaded_blt (struct drm_i915_private *i915, +int (*blt_fn)(void *arg)) +{ + +I915_RND_STATE (prng); +struct igt_thread_arg thread = { i915, &prng, };
Each thread is using the same prng state then?
Bah. It's not thread safe so would lead to non-deterministic behaviour. At least it's not every thread using the exact same sequence.
thread = kmalloc_array(n_cpus, sizeof(*thread), GFP_KERNEL);
for(...) {
thread[i]->prng = I915_RND_STATE_INITIALIZER(prandom_u32_state(&prng));I suspect we may end up pretifying that as I expect we'll do more and more parallelised smoketesting.
Quoted 20 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +20
-0+struct task_struct **tsk; +unsigned int n_cpus; +unsigned int i; +int err =0 ; + + n_cpus =num_online_cpus () +1 ; + + tsk =kzalloc (n_cpus *sizeof (struct task_struct *),GFP_KERNEL ); +if (!tsk) +return 0 ; + +for (i =0 ; i < n_cpus; ++i) { + tsk[i] =kthread_run (blt_fn, &thread,"igt/blt-%d" , i); +if (IS_ERR (tsk[i])) { + err =PTR_ERR (tsk[i]); +break ; + } + +get_task_struct (tsk[i]); + }
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c static int igt_copy_blt(void *arg) · line 285
Quoted 10 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +10
-0+ +for (i =0 ; i < n_cpus; ++i) { +int status; + +if (IS_ERR_OR_NULL (tsk[i])) +continue ; + + status =kthread_stop (tsk[i]); +if (status && !err) + err = status;
Looks good.
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c static int igt_copy_blt(void *arg) · line 289
Quoted 3 lines
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +3
-0+put_task_struct (tsk[i]); + } +
I think per-thread deterministic "random" behaviour is critical. But that's the only drawback spotted, so with that resolved one way or another,
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests/blt: add some kthreads into the mix
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: drm/i915/selftests/blt: add some kthreads into the mix
URL : https://patchwork.freedesktop.org/series/68563/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip
f43a0146b3fc drm/i915/selftests/blt: add some kthreads into the mix
-:159: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'
#159: FILE: drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c:253:
+{
+-:169: WARNING:ALLOC_WITH_MULTIPLY: Prefer kcalloc over kzalloc with multiply #169: FILE: drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c:263:
+ tsk = kzalloc(n_cpus * sizeof(struct task_struct *), GFP_KERNEL);
total: 0 errors, 1 warnings, 1 checks, 190 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915/selftests/blt: add some kthreads into the mix
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: drm/i915/selftests/blt: add some kthreads into the mix
URL : https://patchwork.freedesktop.org/series/68563/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_7186 -> Patchwork_14981
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_14981 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_14981, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_14981:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live_blt:
- fi-bsw-n3050: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-bsw-n3050/igt@i915_selftest@live_blt.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-bsw-n3050/igt@i915_selftest@live_blt.html
* igt@i915_selftest@live_gem_contexts:
- fi-bsw-kefka: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-bsw-kefka/igt@i915_selftest@live_gem_contexts.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-bsw-kefka/igt@i915_selftest@live_gem_contexts.html
Known issues
------------
Here are the changes found in Patchwork_14981 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_flink_basic@flink-lifetime:
- fi-icl-u3: [PASS][5] -> [DMESG-WARN][6] ([fdo#107724]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-icl-u3/igt@[email protected]
* igt@kms_chamelium@dp-edid-read:
- fi-kbl-7500u: [PASS][7] -> [WARN][8] ([fdo#109483])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-kbl-7500u/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-kbl-7500u/igt@[email protected]
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][9] -> [DMESG-WARN][10] ([fdo#102614])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-hsw-peppy/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-hsw-peppy/igt@[email protected]
#### Possible fixes ####
* {igt@i915_selftest@live_gt_heartbeat}:
- fi-byt-n2820: [DMESG-FAIL][11] ([fdo#112096]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-byt-n2820/igt@i915_selftest@live_gt_heartbeat.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-byt-n2820/igt@i915_selftest@live_gt_heartbeat.html
* igt@kms_busy@basic-flip-a:
- {fi-tgl-u2}: [DMESG-WARN][13] ([fdo#111600]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-tgl-u2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-tgl-u2/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][15] ([fdo#111407]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-kbl-7500u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-kbl-7500u/igt@[email protected]
* igt@prime_vgem@basic-wait-default:
- fi-icl-u3: [DMESG-WARN][17] ([fdo#107724]) -> [PASS][18] +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7186/fi-icl-u3/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/fi-icl-u3/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
[fdo#111600]: https://bugs.freedesktop.org/show_bug.cgi?id=111600
[fdo#111747]: https://bugs.freedesktop.org/show_bug.cgi?id=111747
[fdo#112096]: https://bugs.freedesktop.org/show_bug.cgi?id=112096
Participating hosts (49 -> 43)
------------------------------
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7186 -> Patchwork_14981
CI-20190529: 20190529
CI_DRM_7186: ce03ec86789ef8fc41a56176e5f2a9251182183c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5241: 17b87c378fa155390b13a43f141371fd899d567b @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14981: f43a0146b3fc17ede2a7d765ced368f493ae2585 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
f43a0146b3fc drm/i915/selftests/blt: add some kthreads into the mix
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14981/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx