* [PATCH] drm/i915/gtt: Defer address space cleanup to an RCU worker @ 2019-06-18 23:31 Chris Wilson 2019-06-18 23:48 ` ✗ Fi.CI.SPARSE: warning for " Patchwork 2019-06-19 0:16 ` ✗ Fi.CI.BAT: failure " Patchwork 0 siblings, 2 replies; 3+ messages in thread From: Chris Wilson @ 2019-06-18 23:31 UTC (permalink / raw) To: intel-gfx Enable RCU protection of i915_address_space and its ppgtt superclasses, and defer its cleanup into a worker executed after an RCU grace period. In the future we will be able to use the RCU protection to reduce the locking around VM lookups, but the immediate benefit is being able to defer the release into a kworker (process context). This is required as we may need to sleep to reap the WC pages stashed away inside the ppgtt. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110934 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- drivers/gpu/drm/i915/Makefile.header-test | 1 + drivers/gpu/drm/i915/i915_gem_gtt.c | 109 ++++++++++-------- drivers/gpu/drm/i915/i915_gem_gtt.h | 5 + drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 2 - 4 files changed, 66 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/i915/Makefile.header-test b/drivers/gpu/drm/i915/Makefile.header-test index e6ba66f787f9..cb74242f9c3b 100644 --- a/drivers/gpu/drm/i915/Makefile.header-test +++ b/drivers/gpu/drm/i915/Makefile.header-test @@ -6,6 +6,7 @@ header_test := \ i915_active_types.h \ i915_debugfs.h \ i915_drv.h \ + i915_gem_gtt.h \ i915_irq.h \ i915_params.h \ i915_priolist_types.h \ diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 8ab820145ea6..d9eddbd79670 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -482,9 +482,69 @@ static void vm_free_page(struct i915_address_space *vm, struct page *page) spin_unlock(&vm->free_pages.lock); } +static void i915_address_space_fini(struct i915_address_space *vm) +{ + spin_lock(&vm->free_pages.lock); + if (pagevec_count(&vm->free_pages.pvec)) + vm_free_pages_release(vm, true); + GEM_BUG_ON(pagevec_count(&vm->free_pages.pvec)); + spin_unlock(&vm->free_pages.lock); + + drm_mm_takedown(&vm->mm); + + mutex_destroy(&vm->mutex); +} + +static void ppgtt_destroy_vma(struct i915_address_space *vm) +{ + struct list_head *phases[] = { + &vm->bound_list, + &vm->unbound_list, + NULL, + }, **phase; + + mutex_lock(&vm->i915->drm.struct_mutex); + for (phase = phases; *phase; phase++) { + struct i915_vma *vma, *vn; + + list_for_each_entry_safe(vma, vn, *phase, vm_link) + i915_vma_destroy(vma); + } + mutex_unlock(&vm->i915->drm.struct_mutex); +} + +static void __i915_vm_release(struct work_struct *work) +{ + struct i915_address_space *vm = + container_of(work, struct i915_address_space, rcu.work); + + ppgtt_destroy_vma(vm); + + GEM_BUG_ON(!list_empty(&vm->bound_list)); + GEM_BUG_ON(!list_empty(&vm->unbound_list)); + + vm->cleanup(vm); + i915_address_space_fini(vm); + + kfree(vm); +} + +void i915_vm_release(struct kref *kref) +{ + struct i915_address_space *vm = + container_of(kref, struct i915_address_space, ref); + + GEM_BUG_ON(i915_is_ggtt(vm)); + trace_i915_ppgtt_release(vm); + + vm->closed = true; + queue_rcu_work(system_unbound_wq, &vm->rcu); +} + static void i915_address_space_init(struct i915_address_space *vm, int subclass) { kref_init(&vm->ref); + INIT_RCU_WORK(&vm->rcu, __i915_vm_release); /* * The vm->mutex must be reclaim safe (for use in the shrinker). @@ -505,19 +565,6 @@ static void i915_address_space_init(struct i915_address_space *vm, int subclass) INIT_LIST_HEAD(&vm->bound_list); } -static void i915_address_space_fini(struct i915_address_space *vm) -{ - spin_lock(&vm->free_pages.lock); - if (pagevec_count(&vm->free_pages.pvec)) - vm_free_pages_release(vm, true); - GEM_BUG_ON(pagevec_count(&vm->free_pages.pvec)); - spin_unlock(&vm->free_pages.lock); - - drm_mm_takedown(&vm->mm); - - mutex_destroy(&vm->mutex); -} - static int __setup_page_dma(struct i915_address_space *vm, struct i915_page_dma *p, gfp_t gfp) @@ -2250,42 +2297,6 @@ i915_ppgtt_create(struct drm_i915_private *i915) return ppgtt; } -static void ppgtt_destroy_vma(struct i915_address_space *vm) -{ - struct list_head *phases[] = { - &vm->bound_list, - &vm->unbound_list, - NULL, - }, **phase; - - vm->closed = true; - for (phase = phases; *phase; phase++) { - struct i915_vma *vma, *vn; - - list_for_each_entry_safe(vma, vn, *phase, vm_link) - i915_vma_destroy(vma); - } -} - -void i915_vm_release(struct kref *kref) -{ - struct i915_address_space *vm = - container_of(kref, struct i915_address_space, ref); - - GEM_BUG_ON(i915_is_ggtt(vm)); - trace_i915_ppgtt_release(vm); - - ppgtt_destroy_vma(vm); - - GEM_BUG_ON(!list_empty(&vm->bound_list)); - GEM_BUG_ON(!list_empty(&vm->unbound_list)); - - vm->cleanup(vm); - i915_address_space_fini(vm); - - kfree(vm); -} - /* Certain Gen5 chipsets require require idling the GPU before * unmapping anything from the GTT when VT-d is enabled. */ diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h index 812717ccc69b..8de57f67a911 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.h +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h @@ -35,8 +35,12 @@ #define __I915_GEM_GTT_H__ #include <linux/io-mapping.h> +#include <linux/kref.h> #include <linux/mm.h> #include <linux/pagevec.h> +#include <linux/workqueue.h> + +#include <drm/drm_mm.h> #include "gt/intel_reset.h" #include "i915_gem_fence_reg.h" @@ -280,6 +284,7 @@ struct pagestash { struct i915_address_space { struct kref ref; + struct rcu_work rcu; struct drm_mm mm; struct drm_i915_private *i915; diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c index 1a60b9fe8221..0c47276ed5df 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c @@ -208,9 +208,7 @@ static int igt_ppgtt_alloc(void *arg) } err_ppgtt_cleanup: - mutex_lock(&dev_priv->drm.struct_mutex); i915_vm_put(&ppgtt->vm); - mutex_unlock(&dev_priv->drm.struct_mutex); return err; } -- 2.20.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 3+ messages in thread
* ✗ Fi.CI.SPARSE: warning for drm/i915/gtt: Defer address space cleanup to an RCU worker 2019-06-18 23:31 [PATCH] drm/i915/gtt: Defer address space cleanup to an RCU worker Chris Wilson @ 2019-06-18 23:48 ` Patchwork 2019-06-19 0:16 ` ✗ Fi.CI.BAT: failure " Patchwork 1 sibling, 0 replies; 3+ messages in thread From: Patchwork @ 2019-06-18 23:48 UTC (permalink / raw) To: Chris Wilson; +Cc: intel-gfx == Series Details == Series: drm/i915/gtt: Defer address space cleanup to an RCU worker URL : https://patchwork.freedesktop.org/series/62356/ State : warning == Summary == $ dim sparse origin/drm-tip Sparse version: v0.5.2 Commit: drm/i915/gtt: Defer address space cleanup to an RCU worker +./include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0) _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 3+ messages in thread
* ✗ Fi.CI.BAT: failure for drm/i915/gtt: Defer address space cleanup to an RCU worker 2019-06-18 23:31 [PATCH] drm/i915/gtt: Defer address space cleanup to an RCU worker Chris Wilson 2019-06-18 23:48 ` ✗ Fi.CI.SPARSE: warning for " Patchwork @ 2019-06-19 0:16 ` Patchwork 1 sibling, 0 replies; 3+ messages in thread From: Patchwork @ 2019-06-19 0:16 UTC (permalink / raw) To: Chris Wilson; +Cc: intel-gfx == Series Details == Series: drm/i915/gtt: Defer address space cleanup to an RCU worker URL : https://patchwork.freedesktop.org/series/62356/ State : failure == Summary == CI Bug Log - changes from CI_DRM_6299 -> Patchwork_13338 ==================================================== Summary ------- **FAILURE** Serious unknown changes coming with Patchwork_13338 absolutely need to be verified manually. If you think the reported changes have nothing to do with the changes introduced in Patchwork_13338, 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_13338/ Possible new issues ------------------- Here are the unknown changes that may have been introduced in Patchwork_13338: ### IGT changes ### #### Possible regressions #### * igt@i915_selftest@live_contexts: - fi-byt-n2820: [PASS][1] -> [DMESG-WARN][2] [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-byt-n2820/igt@i915_selftest@live_contexts.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-byt-n2820/igt@i915_selftest@live_contexts.html * igt@runner@aborted: - fi-byt-n2820: NOTRUN -> [FAIL][3] [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-byt-n2820/igt@runner@aborted.html #### Warnings #### * igt@i915_selftest@live_contexts: - fi-skl-gvtdvm: [DMESG-FAIL][4] ([fdo#110235]) -> [INCOMPLETE][5] [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-skl-gvtdvm/igt@i915_selftest@live_contexts.html [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-skl-gvtdvm/igt@i915_selftest@live_contexts.html Known issues ------------ Here are the changes found in Patchwork_13338 that come from known issues: ### IGT changes ### #### Possible fixes #### * igt@gem_cpu_reloc@basic: - fi-icl-dsi: [INCOMPLETE][6] ([fdo#107713] / [fdo#110246]) -> [PASS][7] [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-icl-dsi/igt@gem_cpu_reloc@basic.html [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-icl-dsi/igt@gem_cpu_reloc@basic.html * igt@gem_sync@basic-store-each: - fi-kbl-7567u: [FAIL][8] -> [PASS][9] [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-kbl-7567u/igt@gem_sync@basic-store-each.html [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-kbl-7567u/igt@gem_sync@basic-store-each.html * igt@i915_module_load@reload: - fi-blb-e6850: [INCOMPLETE][10] ([fdo#107718]) -> [PASS][11] [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-blb-e6850/igt@i915_module_load@reload.html [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-blb-e6850/igt@i915_module_load@reload.html * igt@i915_pm_rpm@module-reload: - fi-skl-6770hq: [FAIL][12] ([fdo#108511]) -> [PASS][13] [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html * igt@i915_selftest@live_contexts: - fi-bdw-gvtdvm: [DMESG-FAIL][14] ([fdo#110235]) -> [PASS][15] [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html * igt@kms_frontbuffer_tracking@basic: - fi-hsw-peppy: [DMESG-WARN][16] ([fdo#102614]) -> [PASS][17] [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html - fi-icl-u3: [FAIL][18] ([fdo#103167]) -> [PASS][19] [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6299/fi-icl-u3/igt@kms_frontbuffer_tracking@basic.html [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/fi-icl-u3/igt@kms_frontbuffer_tracking@basic.html [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614 [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167 [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713 [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718 [fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511 [fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235 [fdo#110246]: https://bugs.freedesktop.org/show_bug.cgi?id=110246 Participating hosts (44 -> 36) ------------------------------ Additional (1): fi-bdw-5557u Missing (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus Build changes ------------- * Linux: CI_DRM_6299 -> Patchwork_13338 CI_DRM_6299: 2a6cf9f4dc05b77beab4b7d9d1c9f16c7e55a001 @ git://anongit.freedesktop.org/gfx-ci/linux IGT_5059: 1f67ee0d09d6513f487f2be74aae9700e755258a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools Patchwork_13338: 3c684eca1151fbbd64112ea7377ee865b419f8e9 @ git://anongit.freedesktop.org/gfx-ci/linux == Linux commits == 3c684eca1151 drm/i915/gtt: Defer address space cleanup to an RCU worker == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13338/ _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-19 0:16 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-06-18 23:31 [PATCH] drm/i915/gtt: Defer address space cleanup to an RCU worker Chris Wilson 2019-06-18 23:48 ` ✗ Fi.CI.SPARSE: warning for " Patchwork 2019-06-19 0:16 ` ✗ Fi.CI.BAT: failure " Patchwork
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox