Commit 414e9f52 authored by Philip Yang's avatar Philip Yang Committed by Alex Deucher

drm/amdkfd: Asynchronously free smi_client

The synchronize_rcu may take several ms, which noticeably slows down
applications close SMI event handle. Use call_rcu to free client->fifo
and client asynchronously and eliminate the synchronize_rcu call in the
user thread.
Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 46ae2af9
...@@ -38,6 +38,7 @@ struct kfd_smi_client { ...@@ -38,6 +38,7 @@ struct kfd_smi_client {
uint64_t events; uint64_t events;
struct kfd_dev *dev; struct kfd_dev *dev;
spinlock_t lock; spinlock_t lock;
struct rcu_head rcu;
pid_t pid; pid_t pid;
bool suser; bool suser;
}; };
...@@ -137,6 +138,14 @@ static ssize_t kfd_smi_ev_write(struct file *filep, const char __user *user, ...@@ -137,6 +138,14 @@ static ssize_t kfd_smi_ev_write(struct file *filep, const char __user *user,
return sizeof(events); return sizeof(events);
} }
static void kfd_smi_ev_client_free(struct rcu_head *p)
{
struct kfd_smi_client *ev = container_of(p, struct kfd_smi_client, rcu);
kfifo_free(&ev->fifo);
kfree(ev);
}
static int kfd_smi_ev_release(struct inode *inode, struct file *filep) static int kfd_smi_ev_release(struct inode *inode, struct file *filep)
{ {
struct kfd_smi_client *client = filep->private_data; struct kfd_smi_client *client = filep->private_data;
...@@ -146,10 +155,7 @@ static int kfd_smi_ev_release(struct inode *inode, struct file *filep) ...@@ -146,10 +155,7 @@ static int kfd_smi_ev_release(struct inode *inode, struct file *filep)
list_del_rcu(&client->list); list_del_rcu(&client->list);
spin_unlock(&dev->smi_lock); spin_unlock(&dev->smi_lock);
synchronize_rcu(); call_rcu(&client->rcu, kfd_smi_ev_client_free);
kfifo_free(&client->fifo);
kfree(client);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment