userfaultfd: non-cooperative: Split the find_userfault() routine
PATCH 51/142 userfaultfd: non-cooperative: Split the find_userfault() routine
From: Pavel Emelyanov <[email protected]>
Subject: userfaultfd: non-cooperative: Split the find_userfault() routine
I will need one to lookup for userfaultfd_wait_queue-s in different wait queue
Signed-off-by Pavel Emelyanov <[email protected]>
Signed-off-by Mike Rapoport <[email protected]>
Signed-off-by Andrea Arcangeli <[email protected]>
Cc "Dr. David Alan Gilbert" <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Michael Rapoport <[email protected]>
Cc Mike Kravetz <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/userfaultfd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
fs/userfaultfd.c renamed from fs/userfaultfd.c~userfaultfd-non-cooperative-split-the-find_userfault-routine +11 -6
@@ -522,25 +522,30 @@ wakeup: }/* fault_pending_wqh.lock must be hold by the caller */ -static inline struct userfaultfd_wait_queue *find_userfault ( -struct userfaultfd_ctx *ctx) +static inline struct userfaultfd_wait_queue *find_userfault_in ( +wait_queue_head_t *wqh) {wait_queue_t *wq;struct userfaultfd_wait_queue *uwq; -VM_BUG_ON (!spin_is_locked (&ctx->fault_pending_wqh.lock)); +VM_BUG_ON (!spin_is_locked (&wqh->lock)); uwq =NULL ; -if (!waitqueue_active (&ctx->fault_pending_wqh)) +if (!waitqueue_active (wqh)) goto out;/* walk in reverse to provide FIFO behavior to read userfaults */ - wq =list_last_entry (&ctx->fault_pending_wqh.task_list, -typeof (*wq), task_list); + wq =list_last_entry (&wqh->task_list,typeof (*wq), task_list); uwq = container_of(wq, struct userfaultfd_wait_queue, wq); out:return uwq; } +static inline struct userfaultfd_wait_queue *find_userfault ( +struct userfaultfd_ctx *ctx) +{ +return find_userfault_in (&ctx->fault_pending_wqh); +} +static unsigned int userfaultfd_poll (struct file *file,poll_table *wait) {struct userfaultfd_ctx *ctx = file->private_data;
_