drm/amdkfd: Asynchronously free events
authorFelix Kuehling <Felix.Kuehling@amd.com>
Fri, 8 Apr 2022 02:08:03 +0000 (22:08 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 12 Apr 2022 18:20:13 +0000 (14:20 -0400)
The synchronize_rcu call in destroy_events can take several ms, which
noticeably slows down applications destroying many events. Use kfree_rcu
to free the event structure asynchronously and eliminate the
synchronize_rcu call in the user thread.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_events.c
drivers/gpu/drm/amd/amdkfd/kfd_events.h

index 0fef24b..75847c5 100644 (file)
@@ -262,8 +262,7 @@ static void destroy_event(struct kfd_process *p, struct kfd_event *ev)
                p->signal_event_count--;
 
        idr_remove(&p->event_idr, ev->event_id);
-       synchronize_rcu();
-       kfree(ev);
+       kfree_rcu(ev, rcu);
 }
 
 static void destroy_events(struct kfd_process *p)
index 55d376f..1c62c8d 100644 (file)
@@ -70,6 +70,8 @@ struct kfd_event {
                struct kfd_hsa_memory_exception_data memory_exception_data;
                struct kfd_hsa_hw_exception_data hw_exception_data;
        };
+
+       struct rcu_head rcu; /* for asynchronous kfree_rcu */
 };
 
 #define KFD_EVENT_TIMEOUT_IMMEDIATE 0