aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ksmbd/server.c
diff options
context:
space:
mode:
authorNamjae Jeon <linkinjeon@kernel.org>2022-07-28 23:35:18 +0900
committerSteve French <stfrench@microsoft.com>2022-07-31 23:14:32 -0500
commita14c573870a664386adc10526a6c2648ea56dae1 (patch)
treeb7d174950764bbaa0a81d0c927ef27d73b6db7cd /fs/ksmbd/server.c
parentksmbd: fix kernel oops from idr_remove() (diff)
downloadlinux-dev-a14c573870a664386adc10526a6c2648ea56dae1.tar.xz
linux-dev-a14c573870a664386adc10526a6c2648ea56dae1.zip
ksmbd: use wait_event instead of schedule_timeout()
ksmbd threads eating masses of cputime when connection is disconnected. If connection is disconnected, ksmbd thread waits for pending requests to be processed using schedule_timeout. schedule_timeout() incorrectly is used, and it is more efficient to use wait_event/wake_up than to check r_count every time with timeout. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/server.c')
-rw-r--r--fs/ksmbd/server.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ksmbd/server.c b/fs/ksmbd/server.c
index 4cd03d661df0..ce42bff42ef9 100644
--- a/fs/ksmbd/server.c
+++ b/fs/ksmbd/server.c
@@ -261,7 +261,13 @@ static void handle_ksmbd_work(struct work_struct *wk)
ksmbd_conn_try_dequeue_request(work);
ksmbd_free_work_struct(work);
- atomic_dec(&conn->r_count);
+ /*
+ * Checking waitqueue to dropping pending requests on
+ * disconnection. waitqueue_active is safe because it
+ * uses atomic operation for condition.
+ */
+ if (!atomic_dec_return(&conn->r_count) && waitqueue_active(&conn->r_count_q))
+ wake_up(&conn->r_count_q);
}
/**