FAILED: patch "[PATCH] drm/amd: fix scheduler fence teardown order v2" failed to apply to 4.8-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.8-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
c24784f01549ecdf23fc00d0588423bcf8956714Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <[email protected]>
Date: Fri, 28 Oct 2016 17:04:07 +0200
Subject: [PATCH] drm/amd: fix scheduler fence teardown order v2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some fences might be alive even after we have stopped the scheduler leading to warnings about leaked objects from the SLUB allocator.
Fix this by allocating/freeing the SLUB allocator from the module init/fini functions just like we do it for hw fences.
v2: make variable static, add link to bug
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -737,6 +737,7 @@ static int __init amdgpu_init(void) {amdgpu_sync_init ();amdgpu_fence_slab_init (); +amd_sched_fence_slab_init ();if (vgacon_text_force ()) {DRM_ERROR ("VGACON disables amdgpu kernel modesetting.\n" );return -EINVAL ;
@@ -756,6 +757,7 @@ static void __exit amdgpu_exit(void)drm_pci_exit (driver, pdriver);amdgpu_unregister_atpx_handler ();amdgpu_sync_fini (); +amd_sched_fence_slab_fini ();amdgpu_fence_slab_fini (); }
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +0 -13
@@ -34,9 +34,6 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity);static void amd_sched_wakeup (struct amd_gpu_scheduler *sched);static void amd_sched_process_job (struct fence *f,struct fence_cb *cb); -struct kmem_cache *sched_fence_slab; -atomic_t sched_fence_slab_ref =ATOMIC_INIT (0 ); -/* Initialize a given run queue struct */ static void amd_sched_rq_init (struct amd_sched_rq *rq) {
@@ -618,13 +615,6 @@ int amd_sched_init(struct amd_gpu_scheduler *sched,INIT_LIST_HEAD (&sched->ring_mirror_list);spin_lock_init (&sched->job_list_lock);atomic_set (&sched->hw_rq_count,0 ); -if (atomic_inc_return (&sched_fence_slab_ref) ==1 ) { - sched_fence_slab =kmem_cache_create ( -"amd_sched_fence" ,sizeof (struct amd_sched_fence ),0 , -SLAB_HWCACHE_ALIGN ,NULL ); -if (!sched_fence_slab) -return -ENOMEM ; - }/* Each scheduler will run on a seperate kernel thread */ sched->thread =kthread_run (amd_sched_main, sched, sched->name);
@@ -645,7 +635,4 @@ void amd_sched_fini(struct amd_gpu_scheduler *sched) {if (sched->thread)kthread_stop (sched->thread); -rcu_barrier (); -if (atomic_dec_and_test (&sched_fence_slab_ref)) -kmem_cache_destroy (sched_fence_slab); }
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +3 -3
@@ -30,9 +30,6 @@struct amd_gpu_scheduler ;struct amd_sched_rq ; -extern struct kmem_cache *sched_fence_slab; -extern atomic_t sched_fence_slab_ref; -/** * A scheduler entity is a wrapper around a job queue or a group * of other entities. Entities take turns emitting jobs from their
@@ -145,6 +142,9 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, struct amd_sched_entity *entity);void amd_sched_entity_push_job (struct amd_sched_job *sched_job); +int amd_sched_fence_slab_init (void ); +void amd_sched_fence_slab_fini (void ); +struct amd_sched_fence *amd_sched_fence_create (struct amd_sched_entity *s_entity,void *owner);void amd_sched_fence_scheduled (struct amd_sched_fence *fence);
drivers/gpu/drm/amd/scheduler/sched_fence.c +19 -0
@@ -27,6 +27,25 @@#include <drm/drmP.h> #include "gpu_scheduler.h" +static struct kmem_cache *sched_fence_slab; + +int amd_sched_fence_slab_init (void ) +{ + sched_fence_slab =kmem_cache_create ( +"amd_sched_fence" ,sizeof (struct amd_sched_fence ),0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!sched_fence_slab) +return -ENOMEM ; + +return 0 ; +} + +void amd_sched_fence_slab_fini (void ) +{ +rcu_barrier (); +kmem_cache_destroy (sched_fence_slab); +} +struct amd_sched_fence *amd_sched_fence_create (struct amd_sched_entity *entity,void *owner) {
Hi,
please apply a053fb7e512c77f0742bceb578b10025256e1911 first, and then this failed one (c24784f01549ecdf23fc00d0588423bcf8956714).
Gražvydas
Quoted 147 lines · On Tue, Nov 15, 2016 at 9:07 PM, <[email protected]> wrote:
The patch below does not apply to the 4.8-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
c24784f01549ecdf23fc00d0588423bcf8956714Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <[email protected]>
Date: Fri, 28 Oct 2016 17:04:07 +0200
Subject: [PATCH] drm/amd: fix scheduler fence teardown order v2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitSome fences might be alive even after we have stopped the scheduler leading to warnings about leaked objects from the SLUB allocator.
Fix this by allocating/freeing the SLUB allocator from the module init/fini functions just like we do it for hw fences.
v2: make variable static, add link to bug
Reported-by Grazvydas Ignotas <[email protected]>Signed-off-by Christian König <[email protected]>Reviewed-by Alex Deucher <[email protected]> (v1)Signed-off-by Alex Deucher <[email protected]>drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-0@@ -737,6 +737,7 @@ static int __init amdgpu_init(void) {amdgpu_sync_init ();amdgpu_fence_slab_init (); +amd_sched_fence_slab_init ();if (vgacon_text_force ()) {DRM_ERROR ("VGACON disables amdgpu kernel modesetting.\n" );return -EINVAL ;@@ -756,6 +757,7 @@ static void __exit amdgpu_exit(void)drm_pci_exit (driver, pdriver);amdgpu_unregister_atpx_handler ();amdgpu_sync_fini (); +amd_sched_fence_slab_fini ();amdgpu_fence_slab_fini (); }drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +0
-13@@ -34,9 +34,6 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity);static void amd_sched_wakeup (struct amd_gpu_scheduler *sched);static void amd_sched_process_job (struct fence *f,struct fence_cb *cb); -struct kmem_cache *sched_fence_slab; -atomic_t sched_fence_slab_ref =ATOMIC_INIT (0 ); -/* Initialize a given run queue struct */ static void amd_sched_rq_init (struct amd_sched_rq *rq) {@@ -618,13 +615,6 @@ int amd_sched_init(struct amd_gpu_scheduler *sched,INIT_LIST_HEAD (&sched->ring_mirror_list);spin_lock_init (&sched->job_list_lock);atomic_set (&sched->hw_rq_count,0 ); -if (atomic_inc_return (&sched_fence_slab_ref) ==1 ) { - sched_fence_slab =kmem_cache_create ( -"amd_sched_fence" ,sizeof (struct amd_sched_fence ),0 , -SLAB_HWCACHE_ALIGN ,NULL ); -if (!sched_fence_slab) -return -ENOMEM ; - }/* Each scheduler will run on a seperate kernel thread */ sched->thread =kthread_run (amd_sched_main, sched, sched->name);@@ -645,7 +635,4 @@ void amd_sched_fini(struct amd_gpu_scheduler *sched) {if (sched->thread)kthread_stop (sched->thread); -rcu_barrier (); -if (atomic_dec_and_test (&sched_fence_slab_ref)) -kmem_cache_destroy (sched_fence_slab); }drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +3
-3@@ -30,9 +30,6 @@struct amd_gpu_scheduler ;struct amd_sched_rq ; -extern struct kmem_cache *sched_fence_slab; -extern atomic_t sched_fence_slab_ref; -/** * A scheduler entity is a wrapper around a job queue or a group * of other entities. Entities take turns emitting jobs from their @@ -145,6 +142,9 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, struct amd_sched_entity *entity);void amd_sched_entity_push_job (struct amd_sched_job *sched_job); +int amd_sched_fence_slab_init (void ); +void amd_sched_fence_slab_fini (void ); +struct amd_sched_fence *amd_sched_fence_create (struct amd_sched_entity *s_entity,void *owner);void amd_sched_fence_scheduled (struct amd_sched_fence *fence);drivers/gpu/drm/amd/scheduler/sched_fence.c +19
-0@@ -27,6 +27,25 @@#include <drm/drmP.h> #include "gpu_scheduler.h" +static struct kmem_cache *sched_fence_slab; + +int amd_sched_fence_slab_init (void ) +{ + sched_fence_slab =kmem_cache_create ( +"amd_sched_fence" ,sizeof (struct amd_sched_fence ),0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!sched_fence_slab) +return -ENOMEM ; + +return 0 ; +} + +void amd_sched_fence_slab_fini (void ) +{ +rcu_barrier (); +kmem_cache_destroy (sched_fence_slab); +} +struct amd_sched_fence *amd_sched_fence_create (struct amd_sched_entity *entity,void *owner) {
Greg KH
maintainerQuoted 4 lines · Grazvydas Ignotas
Hi,
please apply
a053fb7e512c77f0742bceb578b10025256e1911first, and then this failed one (c24784f01549ecdf23fc00d0588423bcf8956714).
Thanks, that worked.
greg k-h